-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Michael Pleshakov <[email protected]>
- Loading branch information
Showing
11 changed files
with
146 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,33 @@ | ||
# gRPC support | ||
|
||
To support a gRPC application using Virtual server resources with NGINX Ingress controllers, you need to add the **type: grpc** field to an upstream. | ||
To support a gRPC application using VirtualServer resources with NGINX Ingress Controller, you need to add the **type: grpc** field to an upstream. | ||
The protocol defaults to http if left unset. | ||
|
||
## Prerequisites | ||
|
||
1. Follow the [installation](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/) instructions to deploy the Ingress Controller with custom resources enabled. | ||
2. Save the public IP address of the Ingress Controller into a shell variable: | ||
``` | ||
$ IC_IP=XXX.YYY.ZZZ.III | ||
``` | ||
3. Save the HTTPS port of the Ingress Controller into a shell variable: | ||
``` | ||
$ IC_HTTPS_PORT=<port number> | ||
``` | ||
## Step 0 - Replace the ConfigMap | ||
* HTTP/2 must be enabled. See `http2` ConfigMap key in the [ConfigMap](https://docs.nginx.com/nginx-ingress-controller/configuration/global-configuration/configmap-resource/#listeners) | ||
|
||
* VirtualServer and VirtualServerRoute resources for gRPC applications must include TLS termination. | ||
|
||
## Example | ||
|
||
```yaml | ||
apiVersion: k8s.nginx.org/v1 | ||
kind: VirtualServer | ||
metadata: | ||
name: grpc-vs | ||
spec: | ||
host: grpc.example.com | ||
tls: | ||
secret: gprc-secret | ||
upstreams: | ||
- name: grpc1 | ||
service: grpc-svc | ||
port: 50051 | ||
type: grpc | ||
routes: | ||
- path: /helloworld.Greeter | ||
action: | ||
pass: grpc1 | ||
``` | ||
$ kubectl apply -f nginx-config.yaml | ||
``` | ||
## Step 1 - Deploy the Cafe Application | ||
Create the greeter and the grpc-svc deployment and service: | ||
``` | ||
$ kubectl create -f grpc-app.yaml | ||
``` | ||
## Step 2 - Configure Load Balancing and TLS Termination | ||
1. Create the secret with the TLS certificate and key: | ||
``` | ||
$ kubectl create -f vs-grpc-secret.yaml | ||
``` | ||
2. Create the VirtualServer resource: | ||
``` | ||
$ kubectl create -f vs-grpc.yaml | ||
``` | ||
## Step 3 - Test the Configuration | ||
1. Check that the configuration has been successfully applied by inspecting the events of the VirtualServer: | ||
``` | ||
$ kubectl describe virtualserver virtual-server | ||
. . . | ||
Events: | ||
Type Reason Age From Message | ||
---- ------ ---- ---- ------- | ||
Normal AddedOrUpdated 7s nginx-ingress-controller Configuration for default/virtual-server was added or updated | ||
``` | ||
2. Access the application using a version of the helloworld gRPC client; see the (documentation here)[https://grpc.io/docs/languages/go/quickstart/] - e.g.: | ||
$(go env GOPATH)/bin/greeter_client | ||
2021/11/01 14:22:25 Received: world | ||
2021/11/01 14:22:25 Greeting: Hello world | ||
*grpc-svc* is a service for the gRPC application. The service becomes available at the `/helloworld.Greeter` path. Note how we used the **type: grpc** field in the Upstream configuration. |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
7 changes: 0 additions & 7 deletions
7
examples-of-custom-resources/grpc-upstreams/nginx-config.yaml
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
examples-of-custom-resources/grpc-upstreams/vs-grpc-secret.yaml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.