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

Prepare for the KCNA Certification Test. Study with flashcards, multiple-choice questions, and detailed explanations to enhance your understanding of Kubernetes Cloud Native concepts. Ace your exam!

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