Drain a node

Gracefully evict all pods before maintenance

kubectl drain <node> --ignore-daemonsets --delete-emptydir-data

tool
kubectl73 commands
tags
nodes

More kubectl commands

  • kubectl edit deployment/<name> -n <ns>

    Open resource in $EDITOR; changes applied on save

  • kubectl auth can-i list pods --as=system:serviceaccount:<ns>:<sa> -n <ns>

    Check what a ServiceAccount is allowed to do

  • kubectl get pods -n <ns> -o custom-columns='NAME:.metadata.name,NODE:.spec.nodeName,STATUS:.status.phase'

    Print only the fields you care about without jq

  • kubectl patch deployment <name> -n <ns> -p '{"spec":{"replicas":2}}'

    Inline JSON patch without editing the whole manifest

  • kubectl annotate pod <pod> -n <ns> key=value --overwrite

    Set or update an annotation; --overwrite replaces existing value

all 73 kubectl commands