kubectl
Install kubectl | Linux
Install kubectl - Latest release
Bash
echo "Downloading the latest release"
echo ""
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
echo "Installing latest release"
echo ""
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
echo "Move to ~/.local/bin"
echo ""
chmod +x kubectl
mkdir -p ~/.local/bin
mv ./kubectl ~/.local/bin/kubectl
# and then append (or prepend) ~/.local/bin to $PATH
echo "Version:"
kubectl version --client
Enable kubectl autocomplete (bash)
- updated:
Bash
kubectl completion bash > kubectl &&\
sudo mv kubectl /etc/bash_completion.d/ &&\
source ~/.bashrc
Enable kubectl autocomplete (zsh)
Nice Tricks
List all images being used
Bash
kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" |\
tr -s '[[:space:]]' '\n' |\
sort |\
uniq -c
Also nice one
Bash
kubectl get pods --all-namespaces -o jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' |\
sort
List Everything - Just names (except roles, secrets ..)
All pods (on all namespaces)