Hint: Label selectors ignore annotations, only match labels [OK]
Common Mistakes:
Thinking annotations affect label selectors
Assuming command fails due to annotations
Confusing labels and annotations roles
4. You want to add extra metadata to a deployment without affecting its selection. Which is the correct fix if you mistakenly added this under metadata.labels instead of metadata.annotations?
metadata:
labels:
description: "Handles user login"
medium
A. Move the key-value pair under metadata.annotations instead of labels
B. Keep it under labels but rename key to 'desc'
C. Remove the key-value pair entirely
D. Add the key-value pair under spec.containers
Solution
Step 1: Identify misuse of labels
Labels affect selection and grouping; adding descriptive info there can cause unintended behavior.
Step 2: Correct placement for metadata
Annotations are meant for extra metadata that does not affect selection, so move the key-value pair there.
Final Answer:
Move the key-value pair under metadata.annotations instead of labels -> Option A
Quick Check:
Metadata info belongs in annotations, not labels [OK]
Hint: Put extra info in annotations, not labels [OK]
Common Mistakes:
Using labels for descriptive metadata
Renaming keys instead of moving
Removing useful metadata
5. You have a service that selects pods with label tier=backend. You want to add a note about the pod's version without affecting service selection. Which YAML snippet correctly applies this?
hard
A. metadata:
labels:
tier: backend
version: "v2.1"
B. metadata:
labels:
tier: backend
annotations:
version: "v2.1"
C. metadata:
annotations:
tier: backend
version: "v2.1"
D. spec:
labels:
tier: backend
annotations:
version: "v2.1"
Solution
Step 1: Identify label for selection
The service selects pods with label tier=backend, so this label must be present under metadata.labels.
Step 2: Add version note without affecting selection
Version info is metadata and should go under metadata.annotations to avoid changing label selectors.
Final Answer:
metadata:
labels:
tier: backend
annotations:
version: "v2.1" -> Option B
Quick Check:
Labels for selection, annotations for extra info [OK]
Hint: Keep selectors in labels; notes in annotations [OK]
Common Mistakes:
Putting version as label and changing selectors
Putting tier in annotations losing selection
Placing labels or annotations under spec
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.