-
Download the latest release of
kubectl
from the official Kubernetes release page: https://kubernetes.io/docs/tasks/tools/install-kubectl/ -
Unpack the archive and move the
kubectl
binary to a directory in your$PATH
.
alias k=kubectl
alias kgp='kubectl get pods'
alias kgs='kubectl get svc'
alias kgd='kubectl get deployments'
To enable autocompletion for kubectl
commands, follow the instructions for your shell:
-
Obtain the
kubeconfig
file from your cluster administrator or cloud provider. -
Create the folder
mkdir -p $HOME/.kube
and copy yourkubeconfig
file toconfig
.cp kubeconfig $HOME/.kube/config
$HOME/.kube/config
is the default location where kubernetes checks the config file Another approach is by setting an env -
Set the
KUBECONFIG
environment variable:
export KUBECONFIG=/path/to/kubeconfig
- Verify that you can connect to the cluster:
kubectl cluster-info
- Check the current context:
kubectl config current-context
- List all available contexts:
kubectl config get-contexts
- Get information about the nodes in the cluster:
kubectl get nodes -o wide