Last active
June 9, 2020 06:57
-
-
Save myclau/d63b44bb6f19b023a87c74f58c32367a to your computer and use it in GitHub Desktop.
Revisions
-
myclau revised this gist
Jun 9, 2020 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ kubectl get no set NODENAME=xxxxxxxxxxxxxxx kubectl cordon $NODENAME -
myclau created this gist
Jun 9, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #find node names kubectl get no set NODENAME=xxxxxxxxxxxxxxx #nodename example: shkdevk8s05.devhk.shkp.com kubectl cordon $NODENAME #check pod on node kubectl get pods --all-namespaces --field-selector spec.nodeName=$NODENAME -o wide #find mysql pod kubectl get pods --all-namespaces --field-selector spec.nodeName=$NODENAME -o wide | grep mysql #manual remove pod kubectl -n <namespacename> delete pod <podname> #remove stuck pods kubectl -n <namespacename> delete pod <podname> --grace-period 0 --force #drain node kubectl drain $NODENAME --ignore-daemonsets if it appear something like ``` There are pending nodes to be drained: $NODENAME error: pods with local storage (use --delete-local-data to override): podname1-75ddd47ff5-hptq2, podname2-7d8cf5b448-j8bx4 ``` kubectl get pods --all-namespaces --field-selector spec.nodeName=$NODENAME -o wide | grep -E "podname1-75ddd47ff5-hptq2|podname2-7d8cf5b448-j8bx4" | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod #check pod on node kubectl get pods --all-namespaces --field-selector spec.nodeName=$NODENAME -o wide