Srreddy:
Hi how to manually move pods from one worker node to another node
Mohamed Ayman:
Fisrt, you have to make sure that the node you have to move your pod tonhas no taint that can prevent you pod to be scheduled on.
To add a label to an existing node you can do that by running
$ kubectl label node <nodename> <labelname>=<labelvalue>
Then you can update the deployment by running
$ kubectl get deployments
$ kubectl get deployment <deploymentname> -o yaml > deployment.yaml
$ kubectl edit deployment deployment.yaml
To add the node affinity section as followed example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: <deploymentname>
spec:
replicas: 3
selector:
matchLabels:
run: nginx
template:
metadata:
labels:
run: nginx
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: <nodelabel>
operator: In
values:
- <labelvalue>
Then you can save the file and apply if using
$ kubectl apply -f <filename.yaml>
Mumshad Mannambeth:
First of all you cannot “move” a pod from one node to another. You can only delete it from one node and have it re-created on another. To delete use the kubectl delete command. To ensure a pod lands on a specific node using node affinity/taints and tolerations. Hope that helps.
Srreddy:
Thank you
when you say
- key: <nodelabel>
This is the first time you are mentioning it. When we set the label we use;
$ kubectl label node <nodename> <labelname>=<labelvalue>
No nodelabel! So which one is it?
Thanks
Swapna