GKE Gateway controller 


The Gateway API is an API in the Kubernetes system and aims to standardize ingress into clusters. In this recipe, we walked through how to provide a multitenant gateway that routes users to two deployments, depending on the HTTP route. The Gateway API provides many more features for advanced routing and traffic management, such as canarying, header-based routing, and more.

Create a GKE cluster:

gcloud beta container --project $PROJECT_ID \
    clusters create "sample-cluster" \
    --zone "us-central1-c" --enable-ip-alias \
    --cluster-version "1.20.6-gke.1000" \
    --release-channel "rapid"

Create a gateway.yaml manifest with the following code:

kind: Gateway
apiVersion: networking.x-k8s.io/v1alpha1
metadata:
  name: external-http
spec:
  gatewayClassName: gke-l7-gxlb
  listeners:
  - protocol: HTTP
    port: 80
    routes:
      kind: HTTPRoute
      selector:
        matchLabels:
          gateway: external-http

Deploy the gateway.yaml manifest:

kind: HTTPRoute
apiVersion: networking.x-k8s.io/v1alpha1
metadata:
  name: hello-world-route-v1
  labels:
    gateway: external-http
spec:
  rules:
  - matches:
    - path:
        value: /hellov1
    forwardTo:
    - serviceName: hello-world-v1-service
      port: 8080