Let's play with GatewayAPI!
- Provision GKE Kubernetes cluster
- Connect to GKE Kubernetes cluster
gcloud container clusters get-credentials gateway-api-playground --region europe-west1 --project conf42-2024
First exercise is about use Ingress API to expose in a basic way the "blue" application with some limitations.
-
Basic aim using Ingress API
+-----------------+ +---------------------+ +------+ | External Source | => | Load Balancer | => | blue | +-----------------+ +---------------------+ +------+ 100%
-
Install v1-blue version exposed with Ingress API
helm upgrade -i -f dummy-helm-values-v1.yaml dummy-release-v1-blue dummy-helm -n development --create-namespace
-
Wait the GKE Cloud Loadbalancer provisioning on web console and copy the URL
-
Edit /etc/hosts file and reach it
[publicIP] my-dummy-colored-app-exposed-by-ingress.net
Reach it --> http://my-dummy-colored-app-exposed-by-ingress.net
-
Limitations
Ex.
Q: How can I add some http url rewrites or header manipulations?
A: You can't!We already talked in previou slides on how we survived (provider specific ingress controllers).
Let's now see how Gateway API solved a lot of Ingress API limitations (ex. more advanced native http rules, more scalable and role oriented) in a more real scenario.
-
Install v2-green version without any Ingresses
helm upgrade -i -f dummy-helm-values-v2.yaml dummy-release-v2-green dummy-helm -n development --create-namespace
-
Label development namespace
kubectl label ns development shared-public-gateway-access=true
-
Create infrastructure namespace
k create ns infrastructure
-
🧢 Cluster operator hat -- install Gateway resource Note that GaytewayClass is already provided by the cloud provider (in this case by GKE)
k apply -f gateway-api-stuff/cluster-operator-hat/gateway.yaml
-
Wait the Gateway to be accepted (it takes few seconds)
Go to "Kubernetes Engine" -> "Gateways, Services & Ingress" -> "Gateways"
-
Let's see the new Load Balancer
Go to "Cloud Load Balancing"
Note that no rules created yet -
🧢 Developer operator hat -- install HTTPRoute resource
k apply -f gateway-api-stuff/development-hat/route-easy.yaml
-
Wait the rules to be synced
Go to "Cloud Load Balancing"
Some rules should come up -
Retrieve the new cloud load balancer URL, edit /etc/hosts file and reach it
[publicIP] my-dummy-colored-app-exposed-by-gateway-api.net
Reach it --> http://my-dummy-colored-app-exposed-by-gateway-api.net
-
🧢 Developer operator hat -- Play with some more complex routes!
10.a add header to the request
+-----------------+ +------------------------+ +------+ | External Source | => | Api Gateway / Balancer | => | blue | +-----------------+ +------------------------+ +------+ 100% custom-header:<value>
k apply -f gateway-api-stuff/development-hat/route-header-rewrite.yaml
10.b path rewrite
+-----------------+ +------------------------+ +------+ | External Source | => | Api Gateway / Balancer | => | blue | +-----------------+ +------------------------+ +------+ 100% custom-header:<value> / --> /custom-path
k apply -f gateway-api-stuff/development-hat/route-header-path-rewrite.yaml
10.c canary deploy
+-----------------+ +------------------------+ +------+ | External Source | => | Api Gateway / Balancer | (no) => | blue | +-----------------+ +------------------------+ +------+ `traffic:test` header there? +-------+ (yes) => | green | +-------+
k apply -f gateway-api-stuff/development-hat/route-canary.yaml
10.d blue green deploy
+-----------------+ +------------------------+ +------+ | External Source | => | Api Gateway / Balancer | 50% => | blue | +-----------------+ +------------------------+ +------+ +-------+ 50% => | green | +-------+
k apply -f gateway-api-stuff/development-hat/route-blue-green.yaml