0
0
Kubernetesdevops~5 mins

Using labels for service routing in Kubernetes - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a label in Kubernetes?
A label is a key-value pair attached to Kubernetes objects like pods. It helps identify and organize resources for selection and routing.
Click to reveal answer
beginner
How do labels help with service routing in Kubernetes?
Labels allow services to select and route traffic only to pods with matching labels, enabling targeted communication between components.
Click to reveal answer
beginner
What is a selector in a Kubernetes Service?
A selector is a query that matches pods with specific labels. The service routes traffic to all pods matching this selector.
Click to reveal answer
beginner
Example: How to label a pod with app=frontend?
In the pod YAML, under metadata, add: <br> labels:<br> app: frontend
Click to reveal answer
beginner
How does a Kubernetes Service use labels to route traffic?
The service uses a selector to find pods with matching labels and sends network requests only to those pods.
Click to reveal answer
What does a Kubernetes Service selector do?
ACreates new pods automatically
BDeletes pods without labels
CMatches pods with specific labels to route traffic
DChanges pod labels dynamically
Which of these is a valid label format?
Aapp/frontend
Bapp frontend
Capp=frontend
Dapp:frontend
If a service selector is 'app=backend', which pods receive traffic?
AAll pods in the cluster
BPods labeled with app=backend
CPods without labels
DPods labeled with app=frontend
Can a pod have multiple labels?
AYes, pods can have many labels
BNo, only one label is allowed
COnly if the pod is running
DOnly for system pods
What happens if no pods match a service selector?
AThe service has no endpoints and traffic fails
BThe service routes traffic to all pods
CThe service creates new pods automatically
DThe service ignores the selector
Explain how labels and selectors work together to route traffic in Kubernetes services.
Think about how a service finds the right pods to send requests.
You got /4 concepts.
    Describe how you would label a pod and create a service to route traffic to it.
    Consider the YAML structure for both pod and service.
    You got /3 concepts.