Created
July 30, 2024 18:09
-
-
Save gbrayut/b0b3d75b6b5b84782884ad119f64881d to your computer and use it in GitHub Desktop.
GKE grpc gateway testing
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
# Modified from https://gist.github.com/gauravkghildiyal/a3ed6aaf7010835b5e3d253c2472aef2 | |
# Changes: Use TCP health check, one service instead of two, and set grpc as default instead of only explicit routes. | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
labels: | |
app: grpc-app | |
name: grpc | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: grpc-app | |
template: | |
metadata: | |
labels: | |
app: grpc-app | |
spec: | |
containers: | |
- name: echo | |
image: kalmhq/echoserver:latest | |
ports: | |
- name: http-port | |
containerPort: 8001 | |
- name: http2-tls-port | |
containerPort: 8003 | |
- name: grpc-tls-port | |
containerPort: 8005 | |
--- | |
kind: Gateway | |
apiVersion: gateway.networking.k8s.io/v1beta1 | |
metadata: | |
name: grpc-gateway | |
spec: | |
gatewayClassName: gke-l7-global-external-managed | |
listeners: | |
- name: https | |
protocol: HTTPS | |
port: 443 | |
tls: | |
mode: Terminate | |
certificateRefs: | |
- name: example-dot-com-certificate | |
--- | |
kind: HTTPRoute | |
apiVersion: gateway.networking.k8s.io/v1beta1 | |
metadata: | |
name: grpc-httproute | |
spec: | |
parentRefs: | |
- kind: Gateway | |
name: grpc-gateway | |
rules: | |
# Optional test endpoint for http2 backend | |
- matches: | |
- path: | |
type: PathPrefix | |
value: /test | |
backendRefs: | |
- name: grpc-svc | |
port: 8080 | |
# Use gRPC TLS service as default backend | |
- matches: | |
- path: | |
type: PathPrefix | |
value: / | |
backendRefs: | |
- name: grpc-svc | |
port: 80 | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: grpc-svc | |
spec: | |
type: ClusterIP | |
selector: | |
app: grpc-app | |
ports: | |
- name: grpc-tls | |
port: 80 | |
protocol: TCP | |
appProtocol: HTTP2 | |
targetPort: 8005 | |
- name: http2-tls | |
port: 8080 | |
protocol: TCP | |
appProtocol: HTTP2 | |
targetPort: 8003 | |
--- | |
apiVersion: networking.gke.io/v1 | |
kind: HealthCheckPolicy | |
metadata: | |
name: grpc-gateway-healthcheck | |
spec: | |
default: | |
checkIntervalSec: 15 | |
timeoutSec: 15 | |
healthyThreshold: 1 | |
unhealthyThreshold: 2 | |
logConfig: | |
enabled: true | |
config: | |
# Recommend TCP or GRPC health check. See https://cloud.google.com/load-balancing/docs/health-check-concepts | |
type: TCP | |
tcpHealthCheck: | |
port: 8005 | |
targetRef: | |
group: "" | |
kind: Service | |
name: grpc-svc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test commands and screenshots: