Search code examples
kuberneteskubectl

Does kubectl drain remove pod first or create pod first


Kubernetes version 1.12.3. Does kubectl drain remove pod first or create pod first.


Solution

  • You can use kubectl drain to safely evict all of your pods from a node before you perform maintenance on the node (e.g. kernel upgrade, hardware maintenance, etc.)

    When kubectl drain return successfuly it means it has removed all the pods successfully from that node and it is safe to bring that node down(physically shut off, or start maintainence)

    Now if you turn on the machine and want to schedule pods again on that node you need to run:

    kubectl uncordon <node name>
    

    So, kubectl drain removes pods from the node and don't schedule any pods on that until you uncordon that node