gRPC Server - Go

    This sample can be used to try out gRPC, HTTP/2, and custom port configuration in a knative service.

    The container image is built with two binaries: the server and the client. This is done for ease of testing and is not a recommended practice for production containers.

    1. Download a copy of the code:

    Replace with your Docker Hub username then run the commands:

    1. # Build the container on your local machine.
    2. docker build --tag "{username}/grpc-ping-go" .
    3. # Push the container to docker registry.
    4. docker push "{username}/grpc-ping-go"
    1. Update the service.yaml file in the project to reference the published image from step 1.

      Replace {username} in with your Docker Hub user name:

    1. Use kubectl to deploy the service.
    1. kubectl apply --filename service.yaml

    Response:

    1. kubectl get ksvc --output yaml
    2. # This will show the Route, created by the service:
    3. # This will show the Configuration, created by the service:
    4. kubectl get configurations --output yaml
    5. kubectl get revisions --output yaml

    Testing the gRPC service requires using a gRPC client built from the same protobuf definition used by the server.

    The Dockerfile builds the client binary. To run the client you will use the same container image deployed for the server with an override to the entrypoint command to use the client binary instead of the server binary.

    Replace {username} with your Docker Hub user name and run the command:

    The arguments after the container tag are used instead of the entrypoint command defined in the Dockerfile CMD statement.