Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mhausenblas/yages
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: projectcontour/yages
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 6 commits
  • 19 files changed
  • 1 contributor

Commits on Jul 27, 2022

  1. remove extra files

    Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
    sunjayBhatia committed Jul 27, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    LinusU Linus Unnebäck
    Copy the full SHA
    9f3070b View commit details

Commits on Aug 3, 2022

  1. move to goreleaser and health checked service

    Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
    sunjayBhatia committed Aug 3, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    LinusU Linus Unnebäck
    Copy the full SHA
    69d81a6 View commit details
  2. remove extra file

    Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
    sunjayBhatia committed Aug 3, 2022

    Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    d649ce5 View commit details
  3. Update README.md

    Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
    sunjayBhatia committed Aug 3, 2022
    Copy the full SHA
    9dda79e View commit details
  4. fix image name to ghcr

    Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
    sunjayBhatia committed Aug 3, 2022
    Copy the full SHA
    2d3f1d2 View commit details
  5. move to projectcontour

    Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
    sunjayBhatia committed Aug 3, 2022
    Copy the full SHA
    07d781e View commit details
Showing with 565 additions and 605 deletions.
  1. +2 −0 .gitignore
  2. +45 −0 .goreleaser.yaml
  3. +0 −12 .travis.yml
  4. +7 −12 Dockerfile
  5. +15 −18 Makefile
  6. +5 −93 README.md
  7. +0 −97 ambassador.yaml
  8. +0 −47 app-ambassador.yaml
  9. +0 −98 app-conduit.yaml
  10. +0 −35 app.yaml
  11. +0 −1 echo.json
  12. +16 −0 go.mod
  13. +128 −0 go.sum
  14. +13 −0 hack/install-tools.sh
  15. +0 −22 ingress.yaml
  16. +32 −31 main.go
  17. +2 −0 yages-schema.proto
  18. +159 −139 yages/yages-schema.pb.go
  19. +141 −0 yages/yages-schema_grpc.pb.go
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -13,3 +13,5 @@
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
.DS_Store

dist/
45 changes: 45 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
project_name: yages
before:
hooks:
- go mod tidy
- go fmt -mod=readonly ./...
- go vet -mod=readonly ./...
- golangci-lint run -v
builds:
- flags:
- -mod=readonly
- -v
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
ldflags:
- -s
- -w
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
dockers:
- goos: linux
goarch: amd64
build_flag_templates:
- "--pull"
image_templates:
- "ghcr.io/projectcontour/{{ .ProjectName }}:latest"
- "ghcr.io/projectcontour/{{ .ProjectName }}:{{ .Tag }}"
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

19 changes: 7 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
FROM alpine:3.7
ARG yversion
LABEL version=$yversion \
description="YAGES gRPC server" \
maintainer="michael.hausenblas@gmail.com"
COPY ./srv-yages /app/srv-yages
WORKDIR /app
RUN chown -R 1001:1 /app
USER 1001
RUN chmod +x srv-yages
EXPOSE 9000
CMD ["/app/srv-yages"]
FROM alpine:latest as build
ADD https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.11/grpc_health_probe-linux-amd64 /grpc-health-probe
RUN chmod +x /grpc-health-probe
FROM scratch as final
COPY yages /
COPY --from=build /grpc-health-probe /grpc-health-probe
ENTRYPOINT ["/yages"]
33 changes: 15 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
yages_version := 0.1.0
.PHONY: install-tools
install-tools:
./hack/install-tools.sh

.PHONY: build clean container push delete destroy
.PHONY: generate-pb-go
generate-pb-go:
protoc --proto_path=${PWD} --go-grpc_out=. --go_out=. yages-schema.proto

build :
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.release=$(yages_version)" -o ./srv-yages ./main.go
.PHONY: build
build:
goreleaser build --snapshot --rm-dist

clean :
@rm srv-yages
.PHONY: release
release:
goreleaser release --rm-dist

container :
@docker build --build-arg yversion=$(yages_version) -t quay.io/mhausenblas/yages:$(yages_version) .

push :
@docker push quay.io/mhausenblas/yages:$(yages_version)

deploy :
@kubectl create ns grpc-demo
@kubectl apply -f app.yaml

destroy :
@kubectl delete ns grpc-demo
.PHONY: clean
clean:
rm -rf ${PWD}/dist
98 changes: 5 additions & 93 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,8 @@
# Yet another gRPC echo server
## Yet another gRPC echo server

YAGES (yet another gRPC echo server) is an educational gRPC server implementation. The goal is to learn gRPC and communicate best practices around its deployment and usage in the context of Kubernetes.

- [As an Kubernetes app](#as-an-kubernetes-app)
- [From inside the cluster](#from-inside-the-cluster)
- [From outside the cluster](#from-outside-the-cluster)
- [As a local app](#as-a-local-app)
- [Install](#install)
- [Use](#use)
- [Develop](#develop)

## As an Kubernetes app

You can install YAGES as an app in your Kubernetes cluster (tested with Kubernetes v1.9, v1.10, and v1.11) like so:

```bash
$ kubectl apply -f http://mhausenblas.info/yages/app.yaml
```

Then, in order to invoke the service you've got essentially two options: from inside the cluster or from the outside the cluster, by exposing the service.

### From inside the cluster

To access the gRPC server from inside the cluster, you can for example use the [gump](https://quay.io/repository/mhausenblas/gump) container image that has [grpcurl](https://github.com/fullstorydev/grpcurl) installed:


```bash
$ kubectl run -it --rm grpcurl --restart=Never --image=quay.io/mhausenblas/gump:0.1 -- sh
If you don't see a command prompt, try pressing enter.
/go $ grpcurl --plaintext yages:9000 yages.Echo.Ping
{
"text": "pong"
}
```
### From outside the cluster
TBD: Using Ingress as shown in [ingress.yaml](ingress.yaml) or an OpenShift Route object with TLS passthrough set.
## As a local app
### Install
Requires Go 1.9 or above, do:
```bash
$ go get -u github.com/mhausenblas/yages
```
### Use
You can run `go run main.go` in `$GOPATH/src/github.com/mhausenblas/yages` or if you've added `$GOPATH/bin` to your path, directly call the binary:

```bash
$ yages
2018/03/25 16:23:42 YAGES in version dev serving on 0.0.0.0:9000 is ready for gRPC clients …
```

Open up a second terminal session and using [grpcurl](https://github.com/fullstorydev/grpcurl) execute the following:

```bash
# invoke the ping method:
$ grpcurl --plaintext localhost:9000 yages.Echo.Ping
{
"text": "pong"
}
# invoke the reverse method with parameter:
$ grpcurl --plaintext -d '{ "text" : "some fun here" }' localhost:9000 yages.Echo.Reverse
{
"text": "ereh nuf emos"
}
# invoke the reverse method with parameter from JSON file:
$ cat echo.json | grpcurl --plaintext -d @ localhost:9000 yages.Echo.Reverse
{
"text": "ohce"
}
```

Note that you can execute `grpcurl --plaintext localhost:9000 list` and `grpcurl --plaintext localhost:9000 describe` to get further details on the available services and their respective methods.

### Develop

First you want to generate the stubs based on the protobuf schema. Note that this requires the Go gRPC runtime and plug-in installed on your machine, including `protoc` in v3 set up, see [grpc.io](https://grpc.io/blog/installation) for the steps.

Do the following:

```bash
$ protoc \
--proto_path=$GOPATH/src/github.com/mhausenblas/yages \
--go_out=plugins=grpc:yages \
yages-schema.proto
```

Executing above command results in the auto-generated file `yages/yages-schema.pb.go`. **Do not** manually edit this file, or put in other words: if you add a new message or service to the schema defined in `yages-schema.proto` just run above `protoc` command again and you'll get an updated version of `yages-schema.pb.go` in the `yages/` directory as a result.
### Changes from https://github.com/mhausenblas/yages:
- Adds `grpc_health_v1.HealthServer` implementation (see [documentation here](https://github.com/grpc/grpc/blob/master/doc/health-checking.md))
- Container image bundles [grpc-health-probe](https://github.com/grpc-ecosystem/grpc-health-probe) to ensure healthchecking in k8s is improved
- Releases with [goreleaser](https://goreleaser.com/)
97 changes: 0 additions & 97 deletions ambassador.yaml

This file was deleted.

47 changes: 0 additions & 47 deletions app-ambassador.yaml

This file was deleted.

Loading