Do you really need to uncordon it? The task is only to mark the node unschedulable and reschedule all the running pods on it. It should be done by issuing:
# drain node <node_name> --ignore-daemonsets
drain will safely evict all of the pods from a node, if there are daemon set-managed pods, drain will not proceed without using --ignore-daemonsets flag
The key thing here is to reschedule all POD's, if cluster has only single node and the controlplane then POD's won't get scheduled to controlplane. In this case either taints will need to be removed from controlplane or need to add tolerations to POD so that they can be scheduled on controlplane.
You are absolutely right. In my case, there where 3 nodes (1 master and 2 worker) so just cordon and then drain (i know drain alone can do the job, but cordon first and then drain is more complete) the worker node
i think you are right because its asking to rescheduling all pods which are running on ek8s-node-0 so when we cordon it pods will automatically rescheduling on another node.
1️⃣ Cordon the Node (Mark it as unschedulable)
kubectl cordon ek8s-node-0
🔹 This prevents new pods from being scheduled on ek8s-node-0.
2️⃣ Drain the Node (Evict all running pods)
kubectl drain ek8s-node-0 --ignore-daemonsets --delete-emptydir-data --force
🔹 This command:
Evicts all non-DaemonSet pods.
Forces eviction of pods using emptyDir storage (--delete-emptydir-data).
--force is used to handle misconfigured pods.
3️⃣ Verify the Node Status
kubectl get nodes
🔹 ek8s-node-0 should now show SchedulingDisabled status.
Drain marks the node as unschedulable and also evict pods on the node. While, cordon, only marks the node as unschedulable. Hence, kubectl drain <node name> --ignore-daemonsets, would work in this case and also questions refers to only pods and not all objects.
This question can be tricky with pods that are NOT created as part of replicaSets. Then the pods will be terminated only and not rescheduled on other nodes. That needs to be checked before draining the node.
# Mark the node as unschedulable
kubectl cordon ek8s-node-0
# Delete all pods running on the node
kubectl delete pods --all --grace-period=0 --force --field-selector spec.nodeName=ek8s-node-0
No need to uncordon it. Draining the node will evict the nodes and mark it unschedulable.
# k drain <node_name> --ignore-daemonsets
# k get nodes
# k get pods -o wide (make sure existing pods are on other nodes)
don't need to run cordon if you're going to drain it. Drain will do it then evict all the pods in the node.
I'm confused the question didn't say we have to uncordon it eventually, why some comments are saying that we need to uncordon the node?
As i read this question i see that there are two actions required - make unavailable and reschedule. To make unavailable (or unschedulable) we need to cordon it and then drain, no?
would this be correct:
K get nodes
K drain ek8s-node-0 –ignore-demosets
Mark the node as unschedulable:
kubectl cordon ek8s-node-0
Delete the node:
kubectl delete node ek8s-node-0
kubectl get pods -o wide
The task does not asks to make it back available! I guess the exam checker will compare the LAST state of the node when ending the exam. If the node is uncordoned, how can the exam checker know that at some moment the node had been unscheduable.
I do not see the point of uncordon it.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Meliodas12
Highly Voted 1 year, 11 months agofemijohn123
1 year, 6 months agoimportme
11 months, 3 weeks agoVivekSolutionArchitect
1 year, 4 months agoPortman
1 year, 4 months agogtsvetko
Highly Voted 1 year, 11 months agoStunomatic
1 year, 3 months agoDevch0801
7 months, 1 week agoSawb7
Most Recent 5 days, 5 hours agonahid0002
3 months, 1 week agoHaiNgo
6 months, 3 weeks agocharlilec
9 months agoKk14
10 months, 1 week agoanhayg
10 months, 2 weeks agoNatraj007
11 months agoStargazer11
1 year, 1 month agobotsokui
1 year, 7 months agoreal111
1 year, 7 months agoreal111
1 year, 11 months agospocknimoy
1 year, 7 months agoHamiltonian
2 years, 3 months agoiiiaz
1 year, 6 months agonot4me
2 years, 3 months agogcpengineer
2 years, 4 months ago