I have two namespace qa and dev. qa and dev pods can run in same node. When I delete the dev release/pods, k8's just reschedules some of the qa pods in different nodes. Similar things happen when I enable autoscaling that is when scaling down, k8's will reschedule other services pods in the same/different namespace. 1) How do I prevent k8's rescheduling 2) How do I handle this in case of autoscaling?
If you want to schedule your pod on specific node then you can use node selector.
# To set level on node run
$ kubectl label nodes <node-name> <label-key>=<label-value>
# On pod spec set
nodeSelector:
<label-key>=<label-value>
If you want to prevent re-schedule then use Pod disruption budget and set maxUnavailable: 0
, it will never remove your pods
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: pdb
spec:
maxUnavailable: 0
selector:
matchLabels:
app: demoapp