Bài đăng phổ biến

Tuesday, December 27, 2022

[ k8s ] frequently used commands in kubenetes

- cmd to show nodes taint
kubectl get nodes -o json | jq '.items[].spec.taints'
- remove or untaint a node
kubectl taint nodes node1 key1=value1:NoSchedule-
- cordon all node 
kubectl get nodes | awk '{if (NR!=1) {print $1}}' | xargs -I {} kubectl cordon {}
- Kubectl autocomplete : 

source <(kubectl completion bash) # set up autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
alias k=kubectl
complete -o default -F __start_kubectl k

- Get all pods in a node : 

kubectl get pods --all-namespaces -o wide --field-selector spec.nodeName=<nodename> 



1 comment:

  1. delete multiple pod : kubectl get pods --all-namespaces | grep "yourpod-" | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod


Thanks for your join,we will be reply to you asap.