Kubernetes Selector Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 23: Line 23:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
kubectl get -A pods --selector=app=my-app -o jsonpath='{.items[0].metadata.namespace}'
kubectl get -A pods --selector=app=my-app -o jsonpath='{.items[0].metadata.namespace}'
</syntaxhighlight lang='bash'>
</syntaxhighlight>

Revision as of 20:41, 2 July 2020

External

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.

kubectl get -A pods --selector=app=my-app -o jsonpath='{.items[0].metadata.namespace}'