Difference between revisions of "Kubernetes selectors"
Jump to navigation
Jump to search
↑ https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/
(26 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
* https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ | * https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ | ||
+ | * https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/ | ||
− | + | * <code>[[kind: Deployment]], [[kind: Service]]</code> (Services without selectors) | |
+ | |||
+ | |||
+ | == Examples == | ||
+ | * <code>[[kubectl get pods]] [[--selector]]=app=YOUR_APP</code> | ||
+ | |||
+ | * <code>[[kubectl get pods]] [[--selector]]=app=YOUR_APP -o=[[jsonpath]]='{.items[0].metadata.name}'</code> | ||
+ | |||
+ | * <code>[[kubectl get pods]] [[--field-selector]] [[status.]]phase=Running</code> <ref>https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/</ref> | ||
[[selector:]] | [[selector:]] | ||
+ | |||
+ | [[app=]]elasticsearch-master | ||
+ | [[chart=]]elasticsearch | ||
+ | [[release]]=elasticsearch-prod | ||
+ | |||
+ | |||
+ | spec: | ||
+ | [[podSelector]]: | ||
+ | [[matchLabels:]] | ||
+ | app: elasticsearch-master | ||
+ | |||
+ | |||
+ | {{PDB example}} | ||
+ | |||
+ | |||
+ | kind: [[AWSNodeTemplate]] | ||
+ | spec: | ||
+ | [[subnetSelector]]: | ||
+ | [[karpenter.sh/discovery]]: ${CLUSTER_NAME} | ||
+ | securityGroupSelector: | ||
+ | karpenter.sh/discovery: ${CLUSTER_NAME} | ||
+ | |||
+ | == Related == | ||
+ | * <code>[[kubectl set selector]]</code> | ||
+ | * [[Kubernetes services]] | ||
+ | * [[Kubernetes field selectors]] | ||
+ | * [[CKA v1.21: Understand how to use Labels, Selector and Annotations]] | ||
+ | * <code>0/2 nodes are available: 1 Too many pods, 1 nodes(s) [[didn't match Pod's node affinity/selector]]</code> | ||
+ | * [[spec.selector]] | ||
== See also == | == See also == | ||
+ | * {{Kubernetes selectors}} | ||
* {{Kubernetes labels}} | * {{Kubernetes labels}} | ||
[[Category:K8s]] | [[Category:K8s]] |
Latest revision as of 08:43, 3 October 2024
- https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
- https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/
kind: Deployment, kind: Service
(Services without selectors)
Examples[edit]
kubectl get pods --selector=app=YOUR_APP
kubectl get pods --selector=app=YOUR_APP -o=jsonpath='{.items[0].metadata.name}'
selector:
app=elasticsearch-master chart=elasticsearch release=elasticsearch-prod
spec: podSelector: matchLabels: app: elasticsearch-master
apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: zk-pdb spec: minAvailable: 2 selector: matchLabels: app: zookeeper
kind: AWSNodeTemplate spec: subnetSelector: karpenter.sh/discovery: ${CLUSTER_NAME} securityGroupSelector: karpenter.sh/discovery: ${CLUSTER_NAME}
Related[edit]
kubectl set selector
- Kubernetes services
- Kubernetes field selectors
- CKA v1.21: Understand how to use Labels, Selector and Annotations
0/2 nodes are available: 1 Too many pods, 1 nodes(s) didn't match Pod's node affinity/selector
- spec.selector
See also[edit]
- Kubernetes selectors,
PodSelector:, labelSelector:, spec.selector
- Kubernetes labels, selectors, recommended labels
,
kubectl label, kubectl annotate
, Common,kubernetes.io, app.kubernetes.io, MatchLabels:
,labels:
Advertising: