I have a k3s cluster with several nodes, let's say 3 nodes. On each node, I have several pods to deploy. It's a "static deployment", meaning that I want to deploy each pod on a specific node. I don't want to let k3s do it automatically.
For example:
Node_1:
pod_a
pod_b
pod_c
Node_2:
pod_d
pod_e
pod_f
Node_3:
pod_h
pod_i
pod_g
To achieve this, I'm using labels. I tag each node with specific labels and then I specify the label in the yaml
deployment file:
For example, something like that:
apiVersion: v1
kind: Node
metadata:
name: node3
labels:
db: 'true'
And the yaml
deployment files, for example for the db:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: db
namespace: default
spec:
spec:
nodeSelector:
db: 'true'
So, normally the pod db
should be deployed on Node3
. But sometimes, it's not the case. When I do a redeployment, the pod redeploy on another Node and I don't understand why, and how to move it back to the correct node.
This is quite annoying because for some critical pods, I have data mounted on the host and if the pod is not deployed correctly my application can fail.
How to make sure my pod always deploys correctly? And why sometimes it fails to deploy correctly? Thank you