kubernetes version: 1.21.1 Host: Linux CO4AEAP000110FB 5.0.0-1032-azure #34-Ubuntu
I apply a daemonset with "OnDelete" as update strategy. This runs the pods in two nodes. I update the nodeAffinity to not to deploy in one of the nodes (exclude a node) and apply the updated daemonset (kubectl apply -f ...)
Expect: daemonet pods continue to run in both nodes, even though one is added to anti-affinity, as OnDelete supposed to act only upon pod deletion. Later when I manually delete the pod in the excluded-node, I expect k8s not to re-deploy
What happened: The k8s immediately terminates the pod on excluded node.
I even tried "kubectl cascade=orphan apply -f <file>"
Daemonset:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: sonic-test-container
labels:
app: k8s-test-container
spec:
selector:
matchLabels:
app: k8s-test-container
updateStrategy:
type: OnDelete
template:
metadata:
labels:
app: k8s-test-container
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "test_enabled"
operator: "In"
values:
- "true"
- key: "kubernetes.io/hostname"
operator: NotIn
values:
- str-s6000-acs-8
hostname: sonic
hostNetwork: true
containers:
- name: sonic-test-container
image: sonicanalytics.azurecr.io/sonic-dockers/any/docker-sonic_test_container:20210908.0129
tty: true
env:
securityContext:
privileged: true
volumeMounts:
- name: sonic-scripts
mountPath: /usr/share/sonic/scripts
readOnly: true
imagePullPolicy: IfNotPresent
volumes:
- name: sonic-scripts
hostPath:
path: /usr/share/sonic/scripts
Any tips will be very handy ?
Thank you!