Challenge - 5 Problems
Label Routing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Service routing with label selectors
Given the following Kubernetes service and pod labels, what pods will the service route traffic to?
Kubernetes
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: web
tier: frontend
ports:
- protocol: TCP
port: 80
targetPort: 8080
Pods:
- pod1 labels: {app: web, tier: frontend}
- pod2 labels: {app: web, tier: backend}
- pod3 labels: {app: api, tier: frontend}Attempts:
2 left
💡 Hint
The service selector matches pods with both labels 'app: web' and 'tier: frontend'.
✗ Incorrect
The service selector requires both labels to match. Only pod1 has both 'app: web' and 'tier: frontend'. Pod2 misses 'tier: frontend' and pod3 misses 'app: web'.
🧠 Conceptual
intermediate1:30remaining
Label importance in service routing
Why are labels important for Kubernetes service routing?
Attempts:
2 left
💡 Hint
Think about how a service knows which pods to send traffic to.
✗ Incorrect
Labels act as selectors that tell the service which pods to route traffic to based on matching labels.
❓ Configuration
advanced2:00remaining
Correct label selector syntax
Which of the following service selector configurations correctly selects pods with label 'env=prod' and 'version=v2'?
Kubernetes
apiVersion: v1 kind: Service metadata: name: example-service spec: selector:
Attempts:
2 left
💡 Hint
Look for the correct YAML key-value mapping under selector.
✗ Incorrect
The selector field expects a map of key-value pairs. Option C correctly uses YAML mapping syntax. Option C is invalid syntax. Option C is a list, which is incorrect. Option C uses commas inside a map which is invalid YAML.
❓ Troubleshoot
advanced2:30remaining
Service routes no pods despite matching labels
A service selector is set to 'app: backend'. Pods have label 'app: backend'. However, the service routes no traffic. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check pod status and readiness.
✗ Incorrect
Even if labels match, if pods are not running or not ready, the service will not route traffic to them.
🔀 Workflow
expert3:00remaining
Label-based canary deployment routing
You want to route 10% of traffic to pods labeled 'version: canary' and 90% to 'version: stable' using Kubernetes services. Which approach achieves this?
Attempts:
2 left
💡 Hint
Kubernetes services do not support weighted routing by themselves.
✗ Incorrect
Kubernetes services select pods by labels but do not support traffic splitting by weight. Creating separate services and using an Ingress or external load balancer to split traffic achieves weighted routing.