Cheatsheet 10 - Nodes und Pods
Befehl |
Aktion |
kubectl label node <node_name> <key>=<value> |
Label erstellen |
kubectl taint node <node_name> <key>=<value>:<effect> |
Taint erstellen |
kubectl taint node <node_name> <key>:<effect>- |
Taint entfernen |
Node-Selector Beispiel:
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: nginx
image: nginx
nodeSelector:
my-key: my-value
Node-Affinity Beispiel:
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: nginx
image: nginx
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/e2e-az-name
operator: In
values:
- us-west-1a
- us-west-1b
Pod-(Anti-)Affinity Beispiel:
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: nginx
image: nginx
affinity:
podAffinity: # Oder podAntiAffinity
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- db
topologyKey: "kubernetes.io/hostname"
Toleration Beispiel:
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: nginx
image: nginx
tolerations:
- key: "node-type"
operator: "Equal"
value: "gpu"
effect: "NoSchedule"
Request und Limits Beispiel
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: nginx
image: nginx
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"