Canary Deployment Using Kubernetes Gateway API Traffic Splitting
Scenario
You are running a production e-commerce platform called Shopverse. The team has built a new version (v2) of the store service with updated pricing and a new product. Before rolling it out to all users, you want to test it safely in production using a canary deployment.
Two versions of the store service are already running in the shopverse namespace:
store-stable— the current production version (v1), running on port3000store-canary— the new canary version (v2), running on port3000
Your goal is to expose the /store endpoint externally and split traffic between the two versions — 90% to stable and 10% to canary — using the Kubernetes Gateway API.
Task
Create the required Kubernetes Gateway API resources in the shopverse namespace:
- A Gateway named
shopverse-gatewaythat listens on HTTP port80, usesgatewayClassName: nginx, and is accessible externally via a LoadBalancer - An HTTPRoute named
shopverse-canaryattached to the Gateway that:- Uses hostname
shopverse.io - Matches
/storeusing path typeExact - Routes to both backends with weighted traffic splitting:
store-stable— weight90store-canary— weight10
- Uses hostname
Once the Gateway gets an external IP, verify that both versions respond correctly using shopverse.io (/etc/hosts is already pre-configured on cplane-01).
Gateway and HTTPRoute canary deployment view with 90% stable and 10% canary traffic splitting.
curl http://shopverse.io/store | jq
⏳ Wait 2 minutes for MetalLB and NGINX Gateway API setup.
🚫 Do not change existing Services or Deployments.
🎯 90/10 split may need 15–20 requests to hit canary.
After creating the Gateway and HTTPRoute, run kubectl radar on cplane-01, open it on port 9280, and use “Expose HTTP port”, then select the airspace namespace and Topology view (optional).
Hint
The Gateway API supports weighted traffic splitting using the weight field on backendRefs. Both backends are listed under the same rule — the weights determine the percentage of traffic each receives. Use path type Exact to match only /store and not any sub-paths.