Question 21
Kubernetes FundamentalsWhat is the purpose of labels in Kubernetes?
Correct answer: C
Explanation
Labels are key-value metadata attached to Kubernetes objects so they can be identified and grouped. They support selection and organization by letting controllers and users target resources based on shared attributes, which is why they are used "to attach identifying metadata for selection and organization."
Why each option is right or wrong
A. To provide detailed descriptive information about a resource
B. To define network access rules between resources
C. To attach identifying metadata for selection and organization
Kubernetes labels are defined in the object metadata as key-value pairs used to identify and organize resources, and they are specifically consumed by label selectors for grouping and targeting objects. In practice, controllers, Services, and kubectl rely on these labels to select matching resources rather than on names or UIDs, so the function is to provide identifying metadata for selection and organization.
D. To specify resource requests and limits for containers
E. To store multi-line configuration data