0
0
Kubernetesdevops~20 mins

Why labels organize resources in Kubernetes - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Label Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use labels in Kubernetes?

Which of the following best explains why labels are used to organize resources in Kubernetes?

ALabels encrypt resource data to secure communication between pods.
BLabels automatically create new resources based on existing ones.
CLabels allow grouping and selecting resources dynamically without changing the resource definitions.
DLabels replace the need for namespaces in Kubernetes.
Attempts:
2 left
💡 Hint

Think about how you find and manage groups of resources easily.

💻 Command Output
intermediate
2:00remaining
Output of label selection command

What is the output of the following command if two pods have the label app=frontend?

kubectl get pods -l app=frontend --no-headers -o custom-columns=NAME:.metadata.name
A
pod-frontend-1
pod-frontend-2
BNo resources found.
C
NAME
pod-frontend-1
pod-frontend-2
DError: unknown flag: --no-headers
Attempts:
2 left
💡 Hint

The command lists pods with a specific label and outputs only their names without headers.

Configuration
advanced
2:00remaining
Correct label selector syntax in Deployment spec

Which option shows the correct way to specify a label selector in a Kubernetes Deployment YAML to select pods with label tier: backend?

A
selector:
  labels:
    tier: backend
B
selector:
  matchLabels:
    tier: backend
C
selector:
  matchExpressions:
    - key: tier
      operator: In
      values: [backend]
D
selector:
  matchLabels:
    tier = backend
Attempts:
2 left
💡 Hint

Look for the standard field name used for exact label matching.

Troubleshoot
advanced
2:00remaining
Why does a Service not select pods?

A Service is defined with selector app: web, but it does not route traffic to any pods. What is the most likely reason?

APods do not have the label <code>app: web</code> assigned.
BThe Service type is set to ClusterIP instead of NodePort.
CThe Service port and pod container port do not match.
DThe pods are running in a different namespace than the Service.
Attempts:
2 left
💡 Hint

Check if the selector matches the pod labels exactly.

🔀 Workflow
expert
3:00remaining
Label-based rolling update strategy

You want to perform a rolling update on a Deployment but only update pods with label version: v1. Which workflow step is correct to achieve this?

APatch the Deployment selector to <code>version: v1</code> and update pod template labels to <code>version: v2</code>.
BManually delete pods with label <code>version: v1</code>; new pods will be created with <code>version: v2</code> label.
CCreate a new Deployment with label <code>version: v2</code> and delete the old Deployment with <code>version: v1</code>.
DUpdate the Deployment's pod template labels to <code>version: v2</code> and apply; Kubernetes will update pods matching <code>version: v1</code> to <code>v2</code> gradually.
Attempts:
2 left
💡 Hint

Think about how Deployment manages pods and labels during updates.