CKAD · 20 November 2026 · 5 min read

Blue/green deployments with an Ingress

Switch a release at the edge of the cluster: two Services, one Ingress, a test host for green, and one patch to switch. Plus gradual weights with Traefik, and what the retirement of ingress-nginx means.

With an Ingress, a blue/green release happens at the edge of the cluster: blue and green each get their own Service, the Ingress sends the public host to blue, and a second host reaches green so you can test it. When green is ready, you change one field, the Ingress rule's backend Service, from shop-blue to shop-green, and every new request goes to green. Change it back to roll back. For a gradual shift instead of a single switch, you need your controller's own weighting, such as Traefik's, or the Gateway API (part 3 of this series).

TL;DR

  • Two Deployments, two Services: shop-blue selects version: blue, shop-green selects version: green.
  • One Ingress: shop.example.com goes to shop-blue; a test host, green.shop.example.com, goes to shop-green.
  • Switch: patch the public rule's backend to shop-green. Roll back: patch it to shop-blue.
  • Gradual shifts need controller features (Traefik's weighted TraefikService) or the Gateway API's weight.
  • ingress-nginx was retired in March 2026: no more fixes. For new clusters, use the Gateway API.
  • Exam: Ingress rules are in Services and Networking on both the CKA and the CKAD; blue/green is in the CKAD's Application Deployment.

The whole pattern in one picture

Blue/green with an Ingress: users reach Ingress shop (class traefik), whose rule for shop.example.com sends them to Service shop-blue and its three blue Pods; a tester reaches Service shop-green through the test host green.shop.example.com; switching the rule's backend to shop-green releases green.

Want to change it for your own setup? Open this diagram in archhy, our sister product for architecture diagrams, and press Make a copy in archhy: it opens as your own copy, ready to edit.

Service or Ingress: where the switch happens

In part 1, one Service selected blue or green by its version label, and you switched by patching the selector. That works anywhere, inside or outside the cluster. Switching at the Ingress instead keeps each version's Service stable, which helps when other things point at those Services (dashboards, tests, a second Ingress), and lets you test green on its own hostname through the same front door your users use.

Step 1: blue and green, each with a Service

The Deployments are the same as in part 1: shop-blue runs nginx:1.26 with labels app: shop and version: blue, and shop-green runs nginx:1.27 with version: green. Give each its own Service:

YAML
apiVersion: v1kind: Servicemetadata:  name: shop-bluespec:  selector:    app: shop    version: blue  ports:  - port: 80    targetPort: 80---apiVersion: v1kind: Servicemetadata:  name: shop-greenspec:  selector:    app: shop    version: green  ports:  - port: 80    targetPort: 80

Step 2: the Ingress, with a test host for green

One Ingress, two hosts. Users reach shop.example.com, which goes to blue. You reach green.shop.example.com, which goes to green:

YAML
apiVersion: networking.k8s.io/v1kind: Ingressmetadata:  name: shopspec:  ingressClassName: traefik  rules:  - host: shop.example.com    http:      paths:      - path: /        pathType: Prefix        backend:          service:            name: shop-blue            port:              number: 80  - host: green.shop.example.com    http:      paths:      - path: /        pathType: Prefix        backend:          service:            name: shop-green            port:              number: 80

Use the Ingress class your cluster has (kubectl get ingressclass); k3s ships Traefik. Test both hosts through the controller without touching DNS by sending the Host header; nginx's Server header shows which version answered (1.26 is blue, 1.27 is green):

Shell
kubectl apply -f services.yaml -f ingress.yamlcurl -sI -H 'Host: shop.example.com' http://<ingress-address>/ | grep -i '^server'curl -sI -H 'Host: green.shop.example.com' http://<ingress-address>/ | grep -i '^server'

Step 3: switch, and switch back

When green has passed its tests, point the public rule at shop-green. The rule is the first in the list, so its backend is at /spec/rules/0/http/paths/0/backend/service/name:

Shell
kubectl patch ingress shop --type=json \  -p '[{"op":"replace","path":"/spec/rules/0/http/paths/0/backend/service/name","value":"shop-green"}]'kubectl describe ingress shop

To roll back, run the same command with shop-blue. In the exam, kubectl edit ingress shop is just as quick and harder to get wrong than a JSON path. Keep blue running until green has proved itself, then scale it to zero.

A gradual shift with Traefik

A standard Ingress has no weights: a rule sends a host to exactly one Service. Traefik, the controller in k3s, adds its own resources for that. A TraefikService splits traffic between Services by weight, and an IngressRoute (Traefik's version of an Ingress) sends the host to it:

YAML
apiVersion: traefik.io/v1alpha1kind: TraefikServicemetadata:  name: shop-weightedspec:  weighted:    services:    - name: shop-blue      port: 80      weight: 90    - name: shop-green      port: 80      weight: 10---apiVersion: traefik.io/v1alpha1kind: IngressRoutemetadata:  name: shopspec:  entryPoints:  - web  routes:  - match: Host(`shop.example.com`)    kind: Rule    services:    - name: shop-weighted      kind: TraefikService

Move the weights from 100/0 through 90/10 to 0/100 and you have a canary that ends as a blue/green switch. Use the IngressRoute instead of the Ingress rule for that host, not as well as it. These are Traefik's resources, so they only work on Traefik; the Gateway API (part 3) gives you the same weights in a standard form.

What about ingress-nginx?

Many tutorials do weighted releases with ingress-nginx’s canary annotations (nginx.ingress.kubernetes.io/canary and canary-weight on a second Ingress). They still work where ingress-nginx still runs, but nothing new should depend on them.

Using ingress-nginx? It was retired in March 2026 and gets no more fixes. Read ingress-nginx is retired: your options: the Gateway API, another controller that reads its annotations, or your cloud's option, with the tool that converts your Ingress resources.

Things that catch people out

  • The wrong Ingress class. An Ingress with no ingressClassName, or one your controller does not own, is silently ignored. Check kubectl get ingressclass.
  • Same namespace. An Ingress can only send traffic to Services in its own namespace.
  • Testing without the Host header. curl http://<address>/ matches no host rule. Send -H 'Host: …'.
  • Keep-alive connections stay on the old Pods after the switch until they reconnect.
  • TLS: each host needs its certificate in spec.tls; the test host too, if you test over HTTPS.

The blue/green series

  1. Blue/green with a Service selector: the pattern, and the version the exam asks for.
  2. Blue/green with an Ingress (this article): switch the backend at the edge; weights with Traefik.
  3. Blue/green with the Gateway API: standard weights in an HTTPRoute, and a header to test green.
  4. Blue/green with Istio: subsets, weights, mirroring live traffic to green.

Keep going

Write Ingress rules on a real cluster in the CKAD's Services and Ingress module and the CKA's Ingress and network policy module, where the first lab is an Ingress with Traefik.

More from the blog