0
0
Kubernetesdevops~5 mins

Annotations vs labels in Kubernetes - Quick Revision & Key Differences

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 used to identify and organize them for selection and grouping.
Click to reveal answer
beginner
What is an annotation in Kubernetes?
An annotation is a key-value pair attached to Kubernetes objects used to store non-identifying metadata, like build info or URLs.
Click to reveal answer
intermediate
How do labels differ from annotations in Kubernetes?
Labels are used for grouping and selecting objects, while annotations store extra metadata that does not affect selection.
Click to reveal answer
beginner
Can annotations be used to select Kubernetes objects?
No, annotations cannot be used to select objects; only labels support selection and filtering.
Click to reveal answer
intermediate
Give an example use case for labels and annotations.
Labels: Mark pods by environment (e.g., 'env=production') for deployment. Annotations: Store build version or contact info for debugging.
Click to reveal answer
Which Kubernetes feature is used to group and select objects?
ASecrets
BAnnotations
CLabels
DConfigMaps
What kind of data do annotations typically store?
ANon-identifying metadata like build info
BSelection criteria for pods
CUser credentials
DNetwork policies
Can you use annotations to filter Kubernetes objects in a query?
ANo, only labels support filtering
BYes, annotations support filtering
CYes, but only for pods
DNo, neither labels nor annotations support filtering
Which of these is a valid label example?
Abuild-info=version1.2
Bcontact=email@example.com
Cdescription=backend service
Denv=production
Annotations are best used for:
AManaging storage volumes
BStoring extra metadata not used for selection
CDefining network rules
DSelecting pods for deployment
Explain the difference between labels and annotations in Kubernetes.
Think about how you find or organize things versus how you add notes about them.
You got /3 concepts.
    Describe a scenario where you would use a label and another where you would use an annotation.
    Labels help pick groups; annotations add extra info.
    You got /2 concepts.