Complete the code to add a label to a Kubernetes pod.
kubectl label pods my-pod environment=production [1]The --overwrite flag allows updating an existing label on the pod.
Complete the command to list pods with the label app=frontend.
kubectl get pods -l [1]The -l flag filters pods by label. Here, we want pods labeled app=frontend.
Fix the error in the command to delete pods with label tier=backend.
kubectl delete pods -l [1]The command deletes pods with label tier=backend. Using the correct label ensures the right pods are deleted.
Fill both blanks to create a label selector for pods with app=web and environment=prod.
kubectl get pods -l [1],[2]
Multiple labels can be combined with commas. Here, app=web and environment=prod select pods matching both labels.
Fill all three blanks to create a dictionary of labels in a pod YAML manifest.
metadata:
labels:
[1]: [2]
[3]: productionLabels in YAML are key-value pairs. Here, app: frontend and environment: production label the pod correctly.