Blue/green with a Kubernetes Ingress: switch at the edge
Give each version its own Service and make the release a change to which Service an Ingress rule points at, with a test host for green. Where it works, where it stops, and what ingress-nginx's retirement changes.
ON THIS PAGE
With an Ingress, the blue/green switch moves to the edge of the cluster: each version keeps its own Service, and the release is a change to which Service an Ingress rule points at. A second hostname lets you test green through the same front door your users use. It is a clean model with one limit: a standard Ingress rule sends a host to exactly one Service, so anything gradual needs your controller's own features.
Based on the article from Gazeek, our sister site for hands-on CKA and CKAD labs: Blue/green deployments with an Ingress. The full Ingress YAML, the patch and the Traefik configuration are there.
The shape of it#
- Two Services:
shop-blueselectsversion: blue,shop-greenselectsversion: green. They never change. - One Ingress, two hosts:
shop.example.comgoes toshop-blue;green.shop.example.comgoes toshop-greenfor testing. - The release: patch the public rule's backend from
shop-bluetoshop-green. The rollback is the same patch the other way.
Why prefer this to switching a Service selector? Because the Services stay stable. Dashboards, tests and anything else that points at shop-blue keep meaning the same thing, and the only object that changes on release day is the Ingress.
The switch#
The release is one field: the backend Service of the live host's rule. A JSON patch changes it without touching the rest of the Ingress, and the same patch with shop-blue rolls it back:
kubectl patch ingress shop --type=json \
-p '[{"op":"replace","path":"/spec/rules/0/http/paths/0/backend/service/name","value":"shop-green"}]'When you want a gradual shift#
Ingress has no weights. Controllers bolt them on in their own way: Traefik, the default in k3s, has a TraefikService that splits traffic between Services by weight, which you route to with its own IngressRoute. Step the weights from 100/0 through 90/10 to 0/100 and a canary ends as a blue/green switch. It works, but only on Traefik; the Gateway API gives you the same weights in a standard form.
With Traefik, the split is its own object, and an IngressRoute sends the host to it:
spec:
weighted:
services:
- name: shop-blue
port: 80
weight: 90
- name: shop-green
port: 80
weight: 10The ingress-nginx question#
A great many tutorials do weighted releases with ingress-nginx's canary annotations. The Kubernetes project retired ingress-nginx in March 2026: it still runs, but there are no more releases or security fixes. If that is your controller, read ingress-nginx is retired: what now? before building anything new on it.
The series#
- Blue/green with a Service selector
- Blue/green with an Ingress: this article
- Blue/green with the Gateway API
- Blue/green with Istio
The diagram#
Drawn in archhy. Open it in archhy and press Make a copy to adapt it.
Go deeper#
Gazeek's full article has the Services, the Ingress with its test host, the exact JSON patch, the Traefik weights and the mistakes that catch people out. Its CKA and CKAD courses have Ingress labs on real clusters.
