https://drive.google.com/file/d/1DNe7iyLlQPbU4PW9600TDdlNdL00FLo6/view?usp=sharing
apiVersion: v1
kind: Pod
metadata:
name: nnwebserver
namespace: learning
spec:
containers:
- name: nnwebserver
image: nginx
resources:
requests:
cpu: "500m"
memory: "128Mi"
limits:
cpu: "1000m"
memory: "256Mi"
ports:
- containerPort: 80
name: http
protocol: TCP
tolerations:
- key: "color"
operator: "Equal"
value: "pink"
effect: "NoSchedule"
π Key Concept:
- Taints are applied to nodes β repel Pods
- Tolerations are defined in Pods β allow them to tolerate taints
π‘ Your Pod says:
"I can run on nodes tainted with
color=pink:NoSchedule."
| Taint Format | Meaning |
|---|---|
key=value:effect |
Standard taint |
| Effects | |
NoSchedule |
β New Pods wonβt be scheduled here (unless they tolerate) |
PreferNoSchedule |
π‘ Scheduler will try to avoid (soft rule) |
NoExecute |
β οΈ Evict existing Pods that donβt tolerate (after grace period) |
β In your case:
- Node has:
color=pink:NoSchedule- Pod has toleration for
color=pink:NoScheduleβ β Pod can be scheduled on that node
π Comment says:
"Our pod can also go to other nodes that are NEUTRAL to taint... nodeone will accept ONLY pods with pink toleration."
β Partially correct, but incomplete:
π― Correct Behavior:
- Untainted node: Accepts any Pod (tolerant or not)
- Tainted node: Accepts only Pods that tolerate the taint
π‘ To force a Pod onto a tainted node, combine with nodeAffinity:
spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: [k3s-gpu-node] tolerations: - key: "type" operator: "Equal" value: "gpu" effect: "NoSchedule"