Using labels for service routing
📖 Scenario: You are managing a Kubernetes cluster that runs multiple versions of a web application. You want to route traffic to the correct version using labels and services.
🎯 Goal: Create two deployments with different labels and a service that routes traffic to one of them using label selectors.
📋 What You'll Learn
Create a deployment named
web-v1 with label version: v1Create a deployment named
web-v2 with label version: v2Create a service named
web-service that routes traffic to pods with label version: v1Use correct Kubernetes YAML syntax for deployments and service
Verify the service routes to the correct pods by checking labels
💡 Why This Matters
🌍 Real World
In real Kubernetes clusters, labels and selectors help route traffic to the right pods, enabling blue-green deployments and canary releases.
💼 Career
Understanding labels and service routing is essential for Kubernetes administrators and DevOps engineers to manage application versions and traffic flow.
Progress0 / 4 steps