Cheat Sheet - kubectl

Cheat Sheet - kubectl

Installation

Download the latest version:

curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version

Autocomplete

echo 'source <(kubectl completion bash)' >>~/.bashrc

Delete all evicted pods

kubectl get pods -n default | grep Evicted | awk '{print $1}' | xargs kubectl delete pod -n default

Delete all PVCs

kubectl delete pvc --all

Force delete a pod

kubectl delete pod $POD --grace-period=0 --force

Decoding a Secret

kubectl get secret somesecret -o yaml

and then decode the value of data:

echo 'secret' | base64 --decode