Skip to content

Commit

Permalink
Change note wording and code block white spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ciarams87 committed May 1, 2024
1 parent 7dadd39 commit c416ec4
Showing 1 changed file with 111 additions and 111 deletions.
222 changes: 111 additions & 111 deletions examples/grpc-routing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,46 @@ to route traffic to that application using GRPCRoute resources.
## 1. Deploy NGINX Gateway Fabric

1. Follow the [installation instructions](https://docs.nginx.com/nginx-gateway-fabric/installation/) to deploy NGINX Gateway Fabric.
NB: Ensure the Gateway APIs from the experimental channel are installed and that NGF is deployed with the Gateway experimental features enabled.
> **Important**: Ensure the Gateway APIs from the experimental channel are installed and that NGF is deployed with the Gateway experimental features enabled.
1. Save the public IP address of NGINX Gateway Fabric into a shell variable:

```text
GW_IP=XXX.YYY.ZZZ.III
```
```text
GW_IP=XXX.YYY.ZZZ.III
```
1. Save the port of NGINX Gateway Fabric:
```text
GW_PORT=<port number>
```
```text
GW_PORT=<port number>
```
## 2. Deploy the Helloworld Application
1. Create the two helloworld Deployments and Services:
```shell
kubectl apply -f helloworld.yaml
```
```shell
kubectl apply -f helloworld.yaml
```
1. Check that the Pods are running in the `default` Namespace:
```shell
kubectl -n default get pods
```
```shell
kubectl -n default get pods
```
```text
NAME READY STATUS RESTARTS AGE
grpc-infra-backend-v1-766c7d6788-rg92p 1/1 Running 0 12s
grpc-infra-backend-v2-546f7c8d48-mjkkx 1/1 Running 0 12s
```
```text
NAME READY STATUS RESTARTS AGE
grpc-infra-backend-v1-766c7d6788-rg92p 1/1 Running 0 12s
grpc-infra-backend-v2-546f7c8d48-mjkkx 1/1 Running 0 12s
```
Save these pod names into variables:
```text
POD_V1=<grpc-infra-backend-v1-xxxxxxxxxx-xxxxx>
POD_V2=<grpc-infra-backend-v2-xxxxxxxxxx-xxxxx>
```
```text
POD_V1=<grpc-infra-backend-v1-xxxxxxxxxx-xxxxx>
POD_V2=<grpc-infra-backend-v2-xxxxxxxxxx-xxxxx>
```
## 3. Configure Routing
Expand All @@ -57,147 +57,147 @@ There are 3 options to configure gRPC routing. To access the application and tes
1. Create the Gateway and GRPCRoute resources:
```shell
kubectl apply -f exact-method.yaml
```
```shell
kubectl apply -f exact-method.yaml
```
2. Test the Application:
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "exact"}' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "exact"}' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```text
{
"message": "Hello exact"
}
```
```text
{
"message": "Hello exact"
}
```
3. Clean up the Gateway and GRPCRoute resources:
```shell
kubectl delete -f exact-method.yaml
```
```shell
kubectl delete -f exact-method.yaml
```
### 3b. Configure hostname based routing
1. Create the Gateway and GRPCRoute resources:
```shell
kubectl apply -f hostname.yaml
```
```shell
kubectl apply -f hostname.yaml
```
2. Test the Application:
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "bar server"}' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "bar server"}' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```text
{
"message": "Hello bar server"
}
```
```text
{
"message": "Hello bar server"
}
```
To make sure this came from the correct server, we can check the application server logs:
```shell
kubectl logs ${POD_V1}
```
```shell
kubectl logs ${POD_V1}
```
```text
2024/04/29 09:26:54 server listening at [::]:50051
2024/04/29 09:28:54 Received: bar server
```
```text
2024/04/29 09:26:54 server listening at [::]:50051
2024/04/29 09:28:54 Received: bar server
```
Now we'll send a request to `foo.bar.com`
```shell
grpcurl -plaintext -proto grpc.proto -authority foo.bar.com -d '{"name": "foo bar server"}' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```shell
grpcurl -plaintext -proto grpc.proto -authority foo.bar.com -d '{"name": "foo bar server"}' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```text
{
"message": "Hello foo bar server"
}
```
```text
{
"message": "Hello foo bar server"
}
```
This time, we'll check the POD_V2 logs:
```shell
kubectl logs ${POD_V2}
```
```shell
kubectl logs ${POD_V2}
```
```text
2024/04/29 09:26:55 server listening at [::]:50051
2024/04/29 09:29:46 Received: foo bar server
```
```text
2024/04/29 09:26:55 server listening at [::]:50051
2024/04/29 09:29:46 Received: foo bar server
```
3. Clean up the Gateway and GRPCRoute resources:
```shell
kubectl delete -f hostname.yaml
```
```shell
kubectl delete -f hostname.yaml
```
### 3c. Configure headers based routing
1. Create the Gateway and GRPCRoute resources:
```shell
kubectl apply -f headers.yaml
```
```shell
kubectl apply -f headers.yaml
```
2. Test the Application:
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "version one"}' -H 'version: one' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "version one"}' -H 'version: one' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```text
{
"message": "Hello version one"
}
```
```text
{
"message": "Hello version one"
}
```
To make sure this came from the correct server, we can check the application server logs:
```shell
kubectl logs ${POD_V1}
```
```shell
kubectl logs ${POD_V1}
```
```text
<...>
2024/04/29 09:30:27 Received: version one
```
```text
<...>
2024/04/29 09:30:27 Received: version one
```
Now we'll send a request with the header `version: two`
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "version two"}' -H 'version: two' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "version two"}' -H 'version: two' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```text
{
"message": "Hello version two"
}
```
```text
{
"message": "Hello version two"
}
```
This time, we'll check the POD_V2 logs:
```shell
kubectl logs ${POD_V2}
```
```shell
kubectl logs ${POD_V2}
```
```text
<...>
2024/04/29 09:32:46 Received: version two
```
```text
<...>
2024/04/29 09:32:46 Received: version two
```
Finally, we'll send a request with the headers `version: two` and `color: orange`
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "version two orange"}' -H 'version: two' -H 'color: orange' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```shell
grpcurl -plaintext -proto grpc.proto -authority bar.com -d '{"name": "version two orange"}' -H 'version: two' -H 'color: orange' ${GW_IP}:${GW_PORT} helloworld.Greeter/SayHello
```
```text
{
Expand All @@ -219,6 +219,6 @@ There are 3 options to configure gRPC routing. To access the application and tes

3. Clean up the Gateway and GRPCRoute resources:

```shell
kubectl delete -f headers.yaml
```
```shell
kubectl delete -f headers.yaml
```

0 comments on commit c416ec4

Please sign in to comment.