Using PPA is not the best solution, but it is easy and fast. Official documentation here
Update packages
sudo apt-get updateDownload the public signing key for the Kubernetes package repositories. The same signing key is used for all repositories so you can disregard the version in the URL
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.35/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpgAllow unprivileged APT programs to read this keyring
sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpgAdd the appropriate Kubernetes apt repository. If you want to use Kubernetes version different than v1.35, replace v1.35 with the desired minor version in the command below.This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.35/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.listHelps tools such as command-not-found to work correctly
sudo chmod 644 /etc/apt/sources.list.d/kubernetes.listInstall
sudo apt-get update
sudo apt-get install -y kubectlEnable bash completion, cause I want autocomplete with TAB when searching pods, deployments, nodes, etc.
sudo apt install -y bash-completion
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/nullConnect to your cluster
mkdir ~/.kube
## copy your config in ~/.kubeUse different configs with adding this in ~/.bashrc
export KUBECONFIG="${KUBECONFIG}:${HOME}/.kube/civo-civo-ftw-kubeconfig"
alias use-civo='export KUBECONFIG=~/.kube/civo-civo-ftw-kubeconfig'
alias use-proxmox='export KUBECONFIG=~/.kube/proxmox-config'Reload shell or log out and log in again
source ~/.bashrc