Kubernetes Selector Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Kubernetes Concepts")
 
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
=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=
=Internal=


* [[Kubernetes_Concepts#Subjects|Kubernetes Concepts]]
* [[Kubernetes_Concepts#Subjects|Kubernetes Concepts]]
=Example=
<font size=-1>
...
selector:
  matchLabels:
    color: blue
...
</font>
=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>

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