Recall & Review
beginner
What is a label selector in Kubernetes?
A label selector is a way to filter Kubernetes objects based on their labels. It helps you find and manage groups of resources by matching key-value pairs.
Click to reveal answer
beginner
Explain equality-based label selectors.
Equality-based selectors match resources where a label key equals or does not equal a specific value. For example,
environment=production selects resources with label environment set to production.Click to reveal answer
intermediate
What are set-based label selectors?
Set-based selectors allow filtering resources based on whether a label's value is in or not in a set of values. For example,
environment in (production, staging) selects resources labeled with environment as production or staging.Click to reveal answer
beginner
How do you express 'not equal' in equality-based selectors?
Use the
!= operator. For example, tier!=frontend selects resources where the tier label is anything except frontend.Click to reveal answer
intermediate
Give an example of a set-based selector that excludes certain values.
You can use
notin to exclude values. For example, environment notin (dev, test) selects resources whose environment label is neither dev nor test.Click to reveal answer
Which operator is used for equality-based label selectors to match exact values?
✗ Incorrect
The '=' operator is used in equality-based selectors to match labels with exact values.
What does the selector
app in (frontend, backend) do?✗ Incorrect
The 'in' operator selects resources whose app label matches any value in the set (frontend or backend).
How do you select resources where a label key exists regardless of its value?
✗ Incorrect
Simply specifying the label key without a value selects resources where that key exists.
Which selector excludes resources with label tier set to 'frontend'?
✗ Incorrect
'tier!=frontend' selects resources where tier label is anything except frontend.
What is the correct syntax to select resources with environment label not in dev or test?
✗ Incorrect
The 'notin' operator with parentheses and comma-separated values excludes those label values.
Describe the difference between equality-based and set-based label selectors in Kubernetes.
Think about matching one value versus matching a group of values.
You got /3 concepts.
How would you write a label selector to find all pods with label 'app' set to either 'web' or 'api' but not 'test'?
Use 'app in (web, api)' and 'app notin (test)'
You got /3 concepts.