GKE RPC Health Check with multiple ports and different protocols under the same backend service

Solution

Instead of using an Ingress, which will launch a HTTP/HTTPs Load Balancer on GCP by default, I’ve changed the Service to work as a LoadBalancer with a custom HTTP2 health check config. By default this configuration will spin up a TCP Load Balancer on GCP. For instance:

apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
  name: rpc-config
spec:
  healthCheck:
    checkIntervalSec: 10
    timeoutSec: 3
    healthyThreshold: 2
    unhealthyThreshold: 2
    type: HTTP2
    port: 8020
---
apiVersion: v1
kind: Service
metadata:
  name: x-service
  annotations:
    cloud.google.com/app-protocols: '{"rpc-a":"HTTP2", "rpc-b":"HTTP2", "rpc-c":"HTTP2"}'
    beta.cloud.google.com/backend-config: '{"default": "rpc-config"}'
spec:
  selector:
    app: x-node
  ports:
    - name: rpc-a
      port: 5001
      protocol: TCP
      targetPort: 5001
    - name: rpc-b
      port: 8020
      protocol: TCP
      targetPort: 8020
    - name: rpc-c
      port: 8000
      protocol: TCP
      targetPort: 8000
  type: LoadBalancer

The next step is to enable the SSL for the TCP LB. I saw GCP has the SSL Proxy LB, that might solve it. Just need to figure out the proper configuration for that, I could not find it in their docs.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top