Which of the following best explains why labels are used to organize resources in Kubernetes?
Think about how you find and manage groups of resources easily.
Labels are key-value pairs attached to resources. They help identify and select resources dynamically, making management easier without modifying the resources themselves.
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
The command lists pods with a specific label and outputs only their names without headers.
The -l app=frontend filters pods with that label. The --no-headers removes the column header, and -o custom-columns=NAME:.metadata.name outputs only pod names.
Which option shows the correct way to specify a label selector in a Kubernetes Deployment YAML to select pods with label tier: backend?
Look for the standard field name used for exact label matching.
The matchLabels field is used for exact label matching with key-value pairs. The syntax must be correct YAML with colon and indentation.
A Service is defined with selector app: web, but it does not route traffic to any pods. What is the most likely reason?
Check if the selector matches the pod labels exactly.
Services route traffic to pods matching their selector labels. If pods lack the label, the Service finds no endpoints to route to.
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?
Think about how Deployment manages pods and labels during updates.
Updating the pod template labels in the Deployment triggers Kubernetes to perform a rolling update, replacing pods with old labels gradually with new ones.