I need some node affinity in some deployments (specifically to have DinD, docker in docker, run one per node in my cluster). I need to have multiple DinD but only one of the per node.
I add for example:
kubectl label nodes aks-nodepool1-16162636-vmss000000 dindId=dind00
and the same for every node in the cluster… everything works.
Problem is, if the cluster is restarted (for a version upgrade or any other reason) those labels are lost, hence the system won’t aout start, as the DinD pods won’t deploy as they don’t find the node they need to run.
I have also found that AKS assignes new node names when the cluster is restarted. Maybe that’s the reason that the label is lost.
Quesiton is: how I can have those node labels persistent or, at least, if the cluster is restarted, that the new nodes in the claster get automatically the corresponding label? (dindId=dind00, dindId=dind01, dindId=dind01…)
As an alternative, I am now executing 2 Deployments with replicas: 1 value… but if I can execute a single deployment with replicas: 2 (so it deploys 2 pods)… is there a way to ensure that each pod is ran in a different cluster node? That would work.