Challenge, Medium,  on  KubernetesNetworking

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 port 3000
  • store-canary — the new canary version (v2), running on port 3000

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-gateway that listens on HTTP port 80, uses gatewayClassName: nginx, and is accessible externally via a LoadBalancer
  • An HTTPRoute named shopverse-canary attached to the Gateway that:
    • Uses hostname shopverse.io
    • Matches /store using path type Exact
    • Routes to both backends with weighted traffic splitting:
      • store-stable — weight 90
      • store-canary — weight 10

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 traffic split for Shopverse

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.


Test Cases