Pages

Bài đăng phổ biến

Showing posts with label [ k8s ] frequently used commands in kubenetes. Show all posts
Showing posts with label [ k8s ] frequently used commands in kubenetes. Show all posts

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>