Prompt
How do I set up a canary deployment in Kubernetes?
Latest observation
Oct 19, 2026
OpenAI APIWeb search: off
A canary deployment in Kubernetes means rolling out a new version to a small subset of traffic first, then gradually increasing it if it looks healthy.
Common ways to do it
- Manual canary with two Deployments + Service selector
- Traffic-splitting with a service mesh or ingress
- Use a progressive delivery tool like Argo Rollouts or Flagger
1) Simple canary with two Deployments
You run:
app-stablefor the current versionapp-canaryfor the new version
Then you route a small portion of traffic to canary by:
- using a separate Service
- or adjusting labels/selectors manually
- or using an ingress/controller that supports weighted routing
Example
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-stable
spec:
replicas: 9
selector:
matchLabels:
app: myapp
version: stable
template:
metadata:
labels:
app: myapp
version: stable
spec:
containers:
- name: myapp
image: myrepo/myapp:1.0.0
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-canary
spec:
replicas: 1
selector:
matchLabels:
app: myapp
version: canary
template:
metadata:
labels:
app: myapp
version: canary
spec:
containers:
- name: myapp
image: myrepo/myapp:1.1.0
A Service can target both, but Kubernetes Services don’t do weighted routing by default, so you usually need another component for that.
2) Canary with Argo Rollouts
This is the easiest “real” canary setup in Kubernetes.
Benefits
- Automated traffic shifting
- Analysis/metrics-based promotion
- Easy rollback
- Integrates with NGINX, ALB, Istio, etc.
Example Rollout
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: myapp
spec:
replicas: 10
strategy:
canary:
steps:
- setWeight: 10
- pause: {duration: 2m}
- setWeight: 50
- pause: {duration: 5m}
- setWeight: 100
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myrepo/myapp:1.1.0
You’ll also need a Service and an ingress/controller or mesh integration depending on how traffic is routed.
3) Canary with service mesh / ingress
If you use:
- Istio
- Linkerd
- NGINX Ingress
- Traefik
- AWS ALB
you can often configure weighted traffic splitting.
Example with Istio VirtualService
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: myapp
spec:
hosts:
- myapp.example.com
http:
- route:
- destination:
host: myapp
subset: stable
weight: 90
- destination:
host: myapp
subset: canary
weight: 10
This lets you send 10% of traffic to canary, then increase later.
Recommended setup
If you want a robust production canary deployment:
- Use Argo Rollouts
- Add metrics-based analysis (Prometheus, Datadog, New Relic, etc.)
- Start with 5–10% traffic
- Increase in steps
- Auto-rollback on errors/latency regression
Best practices
- Keep stable and canary versions isolated
- Use readiness/liveness probes
- Monitor:
- error rate
- latency
- CPU/memory
- business KPIs
- Use automated rollback thresholds
- Prefer gradual traffic shifts over replica-only splitting
- Test in staging first
If you want, I can give you:
- a full Argo Rollouts example,
- an Istio canary example, or
- a plain Kubernetes + NGINX Ingress setup.