0
0
Kubernetesdevops~30 mins

Canary deployments in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Canary Deployments with Kubernetes
📖 Scenario: You are working as a DevOps engineer for a web application team. Your team wants to release a new version of the app safely by gradually sending a small portion of user traffic to the new version first. This approach is called a canary deployment. It helps catch issues early without affecting all users.
🎯 Goal: Build a simple Kubernetes setup that deploys two versions of an app: the stable version and the canary version. Then configure a service to split traffic between them, sending 10% of traffic to the canary version and 90% to the stable version.
📋 What You'll Learn
Create a Deployment for the stable app version with 3 replicas
Create a Deployment for the canary app version with 1 replica
Create a Service that routes 90% traffic to stable and 10% to canary using labels
Print the final Service YAML to verify the traffic split
💡 Why This Matters
🌍 Real World
Canary deployments are used in production to reduce risk when releasing new software versions by gradually shifting user traffic.
💼 Career
DevOps engineers and site reliability engineers use canary deployments to improve software release safety and reliability.
Progress0 / 4 steps
1
Create the stable Deployment
Create a Kubernetes Deployment named app-stable with 3 replicas. Use the container image nginx:1.19. Add the label version: stable to the pod template metadata.
Kubernetes
Need a hint?

Use replicas: 3 and add version: stable label under template.metadata.labels.

2
Create the canary Deployment
Add a new Deployment named app-canary with 1 replica. Use the container image nginx:1.20. Add the label version: canary to the pod template metadata.
Kubernetes
Need a hint?

Use replicas: 1 and label the pods with version: canary.

3
Create the Service with traffic split
Create a Kubernetes Service named app-service of type ClusterIP. It should select pods with label app: myapp. Use two selectors with weights to split traffic: 90% to pods with label version: stable and 10% to pods with label version: canary. Use spec.selector and spec.traffic fields accordingly.
Kubernetes
Need a hint?

Use spec.traffic with weight and podSelector.matchLabels to split traffic.

4
Print the final Service YAML
Print the full YAML of the app-service to verify the traffic split configuration.
Kubernetes
Need a hint?

Use a print statement to output the Service YAML exactly as configured.