k8s/StudyNotes/NodeSelectors & Node Affinity
- Example is different size nodes, with labels Large, Medium, Small
Get labels on node
kubectl get nodes node01 --show-labels
(Older)nodeSelector, no logic. Ind pod-def.yaml, add to spec: nodeSelector:
apiVersion: kind: Pod metadata: name: myapp-pod spec: containers: - name: data-processor image: dataproc nodeSelector: size: Large
label node with
kubectl label node 2. (Newer)Node Affinity and anti affinity. * Node Affinity more flexabe but complex, e.g. pick large node {{{ spec: containers: ... affinity: nodeAffinity: requiredDuringSchedulingIgnoreDuringExecution: nodeSeletorTerms: - matchExpressions: - key: size operator: In values: - Large
- 2x types of Node affinity
- requiredDuringSchedulingIgnoredDuringExecution
- preferredDuringSchedulingIgnoredDuringExecution
- future planned
- requiredDuringSchedulingRequiredDuringExecution
- preferredDuringSchedulingRequiredDuringExecution
- Node Affinity, can have different operator's:
- operator: In
- operator: Exists