What does the --selector option do in a kubectl get command?

Prepare for the Kubernetes Cloud Native Associate (KCNA) Certification test with engaging questions and detailed explanations. Perfect your knowledge and boost your confidence to pass the exam successfully!

Multiple Choice

What does the --selector option do in a kubectl get command?

Explanation:
Label selectors filter the resources you list by their labels. When you use the --selector option with kubectl get, Kubernetes only returns resources whose label expressions match what you provide. For example, kubectl get pods -l app=frontend will show only pods labeled with app=frontend, and you can combine multiple requirements like -l app=frontend,env=prod. The -l shorthand works the same as --selector. This filtering is about labels, not about YAML output or field-based filtering (which uses --field-selector).

Label selectors filter the resources you list by their labels. When you use the --selector option with kubectl get, Kubernetes only returns resources whose label expressions match what you provide. For example, kubectl get pods -l app=frontend will show only pods labeled with app=frontend, and you can combine multiple requirements like -l app=frontend,env=prod. The -l shorthand works the same as --selector. This filtering is about labels, not about YAML output or field-based filtering (which uses --field-selector).

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy