Kubernetes Selector Concepts: Difference between revisions
Jump to navigation
Jump to search
Line 16: | Line 16: | ||
color: blue | color: blue | ||
... | ... | ||
=Query by Selector= | |||
Get the namespace of the first pod from a series that has an "app=my-app" label. | |||
<syntaxhighlight lang='bash'> | |||
kubectl get -A pods --selector=app=my-app -o jsonpath='{.items[0].metadata.namespace}' | |||
</syntaxhighlight lang='bash'> |
Revision as of 20:41, 2 July 2020
External
- https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/#labelselector-v1-meta
- https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
- https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/
Internal
Example
... selector: matchLabels: color: blue ...
Query by Selector
Get the namespace of the first pod from a series that has an "app=my-app" label.
<syntaxhighlight lang='bash'> kubectl get -A pods --selector=app=my-app -o jsonpath='{.items[0].metadata.namespace}' </syntaxhighlight lang='bash'>