Enable auto-completion for Kubectl in a Linux bash shell
In this short post, we will demonstrate how to install kubectl, setup up auto-completion, and set an alias for kubectl in your bash shell.
When using kubectl commands to interact with your Kubernetes cluster (K8S), auto-completion can be very useful to avoid having to reference a cheat sheet constantly!
Setting an alias for kubectl on the command line, (commonly as k
), also helps save a lot of time when managing your cluster, and is also recommended for the CKA administrator exam as it is very time limited.
Install Kubectl on Linux
- Open your bash shell. Type
kubectl
. If you see the message ‘kubectl: command not found’, follow these steps to installkubectl
. If it is installed, skip to step 7.
2. Download the latest kubectl
release with the command:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
3. Download the checksum file:
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
4. Validate the kubectl binary against the checksum file:
echo "$(cat kubectl.sha256) kubectl" | sha256sum…