Fix GCP GKE Gateway Controller Errors
When working with GCP GKE, you may encounter a configuration error that prevents your deployment from working. This guide explains the most common mistake with gateway controller and shows the exact fix.
A Common Mistake
Using the legacy Ingress resource instead of the Gateway API, which provides more advanced traffic routing capabilities and is the future of Kubernetes ingress.
The incorrect command:
kubectl apply -f - <<EOF
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
spec:
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80
EOF
Error output:
ingress.networking.k8s.io/my-ingress created
The Ingress works but lacks advanced features: traffic splitting, header modification, and cross-namespace routing require additional controllers and annotations.
The Correct Approach
The right way to configure gateway controller in GCP GKE:
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: my-route
spec:
parentRefs:
- name: my-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: my-app-v1
port: 80
weight: 90
- name: my-app-v2
port: 80
weight: 10
EOF
Successful result:
httproute.gateway.networking.k8s.io/my-route created
The HTTPRoute provides weighted traffic splitting (90/10 canary), cross-namespace routing, header modification, and request filtering. Gateway API is the future of Kubernetes ingress.
How to Prevent This
Use Gateway API for new ingress configurations. GKE Gateway Controller supports HTTPRoute, TCPRoute, TLSRoute. Gateway API provides role-oriented design (infra vs app teams). Supports traffic splitting, cross-namespace routing, and more. GC is GA in GKE 1.24+.
FAQ
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Secure your cloud with DodaTech.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro