Kubernetes Selector Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:


=Example=
=Example=
 
<font size=-1>
  ...
  ...
  selector:
  selector:
Line 16: Line 16:
     color: blue
     color: blue
  ...
  ...
</font>


=Query by Selector=
=Query by Selector=
Line 23: Line 24:
<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>

Latest revision as of 00:40, 6 February 2022

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}'