Difference between revisions of "Kubernetes pod affinity and anti affinity"
m (Welcome moved page Pod affinity and anti affinity to Kubernetes pod affinity and anti affinity) |
|||
Line 1: | Line 1: | ||
https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity | https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity | ||
+ | |||
+ | == Official example == | ||
+ | <pre> | ||
+ | apiVersion: v1 | ||
+ | |||
+ | kind: Pod | ||
+ | |||
+ | metadata: | ||
+ | |||
+ | name: with-node-affinity | ||
+ | |||
+ | spec: | ||
+ | |||
+ | affinity: | ||
+ | |||
+ | nodeAffinity: | ||
+ | |||
+ | requiredDuringSchedulingIgnoredDuringExecution: | ||
+ | |||
+ | nodeSelectorTerms: | ||
+ | |||
+ | - matchExpressions: | ||
+ | |||
+ | - key: topology.kubernetes.io/zone | ||
+ | |||
+ | operator: In | ||
+ | |||
+ | values: | ||
+ | |||
+ | - antarctica-east1 | ||
+ | |||
+ | - antarctica-west1 | ||
+ | |||
+ | preferredDuringSchedulingIgnoredDuringExecution: | ||
+ | |||
+ | - weight: 1 | ||
+ | |||
+ | preference: | ||
+ | |||
+ | matchExpressions: | ||
+ | |||
+ | - key: another-node-label-key | ||
+ | |||
+ | operator: In | ||
+ | |||
+ | values: | ||
+ | |||
+ | - another-node-label-value | ||
+ | |||
+ | containers: | ||
+ | |||
+ | - name: with-node-affinity | ||
+ | |||
+ | image: registry.k8s.io/pause:2.0 | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | {{K8s}} |
Revision as of 16:57, 20 September 2022
https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity
Official example
apiVersion: v1 kind: Pod metadata: name: with-node-affinity spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: topology.kubernetes.io/zone operator: In values: - antarctica-east1 - antarctica-west1 preferredDuringSchedulingIgnoredDuringExecution: - weight: 1 preference: matchExpressions: - key: another-node-label-key operator: In values: - another-node-label-value containers: - name: with-node-affinity image: registry.k8s.io/pause:2.0
Kubernetes: distributions, tools, CKA, CKS, Kubernetes interfaces: CSI, CNI, installation, workloads, networking, kubeadm
, Kubernetes API
, Kubernetes API Server, kubectl, kubeadm, kubelet, kube-proxy
, Cloud services: EKS, GKE, TKE, DKS, Helm, Kubernetes RBAC, Kubernetes deployments, Minikube, Rancher, OpenShift, Charmed Kubernetes, Ingress, Kubernetes scheduler, Kubernetes Finalizers, logging, Kubernetes operator, Orka, kind:
, Kubernetes namespaces, Kubernetes dashboard, Kubernetes Metrics Server, Field Selectors, CoreDNS, CRI, Kubernetes Topology Manager, Kubernetes governance: (SIG, KEP), Kustomize, controllers, ReadinessProbe, LivenessProbe
, KOPS, K9s, Kui, k3s, ImagePullBackOff, PDB, EndPoints, Kots, metadata, Karpenter, Replicated.com, Kubernetes Authenticating, Kubernetes timeline, Changelog/Versions, service accounts, Kubernetes Pod Lifecycle, Kubernetes Conformance Certified, Kubernetes backup, Kubernetes Pod Security Admission, tEKS, Kubernetes events, Kubernetes ports, Kubernetes policies, Connect, addons, DoKC, Kubernetes control plane, Kubernetes Federation, Kubernetes info, Kubetest2, Sidecar (Kubernetes)
Advertising: