Skip to main content
In this hands‑on demo you’ll learn how to perform a zero‑downtime canary (progressive) rollout using the Gateway API. We use the NGINX Gateway implementation for the demo, but the Gateway API resources and concepts apply across implementations (for example HAProxy).
A presentation slide titled "Zero-Downtime Canary Deployment" with a large turquoise curved shape on the right that says "Demo." The slide also shows a small copyright notice for KodeKloud in the corner.
Overview
  • Deploy two versions of the same application: coffee (v1) and coffeev2 (v2).
  • Create an HTTPRoute attached to the Gateway that splits traffic between the two Services using weight to simulate canary rollouts.
  • Drive requests to the route and observe how the Gateway distributes traffic as you change weights.
Why use Gateway API for canaries?
  • Gateway API provides first‑class routing primitives (HTTPRoute, TCPRoute, etc.) that support weighted backend splitting.
  • Weighted routing enables gradual rollouts without changing client endpoints — zero downtime and safer deployments.
Initial cluster state (before starting)
  • Only v1 (coffee) is running and no HTTPRoute exists yet. The gateway is already deployed.
Example checks (initial):
Quick reference: Kubernetes resources used Step 1 — Deploy the v2 application Create a Deployment and Service for coffeev2 (v2 of the same app). This manifest uses the same image as v1, exposes port 8080 in the pod and Service port 80. coffeev2-app.yaml:
Apply the manifest and confirm pods/services:
Step 2 — Create an HTTPRoute that splits traffic Create an HTTPRoute named splitroute that attaches to the existing gateway (sectionName http) and splits requests for host cafe.example.com on the /coffee path between two backend Services using weight. Initial canary route (75/25):
Apply the route:
Testing traffic splitting
  • Use curl with --resolve to send requests to the gateway address while setting the Host header to cafe.example.com. In these examples we use localhost:8080. If your Gateway is exposed as a NodePort (e.g., 31437) or you prefer to port-forward, update the port accordingly.
  • The app response includes Server name (pod name) and Server address so you can identify which backend served each request.
Tip: ensure the gateway is reachable on the chosen port and that DNS Host header is set via --resolve.
If your Gateway is exposed on a NodePort (for example 31437) or through a load balancer, replace 8080 in the examples with the Gateway’s listening port, or use kubectl port-forward to map the gateway to localhost:8080.
Representative requests with initial weights (mostly v1):
Weighted traffic splitting is probabilistic: a 75/25 weight is an approximate distribution. With a small sample of requests you may see variance; the distribution converges with higher request volume.
Step 3 — Adjust weights to simulate a progressive rollout Update the HTTPRoute weights to gradually shift traffic toward coffeev2. Each change is a single manifest edit and kubectl apply. Example: change weights to 90/10
Apply the change:
Example: change to 50/50 (even split)
Apply and test (repeat curl requests). You should see a more even distribution. Representative 50/50 sequence:
Step 4 — Promote v2 to 100% (complete cutover) When coffeev2 is validated and healthy, update the route so all traffic goes to v2 and v1 receives none. Final route for 0/100:
Apply and verify:
Best practices for safe canary rollouts
  • Start small: begin with a low percentage (for example 1% → 5% → 25%) and increase as confidence grows.
  • Monitor errors, latency, logs, and business metrics continuously during each step.
  • Automate and track changes via GitOps (ArgoCD, FluxCD) for auditable rollouts and easy rollbacks.
  • Remember weights are probabilistic. For precision testing use a sufficiently large request volume or a traffic generator.
  • Consider session affinity or consistent hashing if your app requires sticky sessions during canaries.
Links and references That’s it — you now have a practical zero‑downtime canary demo using Gateway API and the NGINX Gateway.

Watch Video

Practice Lab