Here is how to install kubectl on Debian 12. Tested and verified.
Prerequisites
- Debian 12 installed and updated
- Root or sudo access
- Internet connection
Step 1: Update System
sudo apt update && sudo apt upgrade -yStep 2: Add Official Repository
kubectl should be installed from the official Kubernetes apt repository so you get the latest stable version and security updates, rather than whatever (older) version ships in Debianβs own repos.
# Install packages needed to use the Kubernetes apt repository
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl gnupg
# Create the keyrings directory (present by default on Debian 12+)
sudo mkdir -p -m 755 /etc/apt/keyrings
# Download the Kubernetes signing key
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.36/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg
# Add the Kubernetes apt repository (this overwrites any existing kubernetes.list)
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.36/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list
v1.36selects the Kubernetes 1.36 package repository, the current stable minor version at the time of writing. To track a different minor version, replacev1.36in both the key URL and thesources.list.dentry, then re-runapt update.
Step 3: Install kubectl
sudo apt update
sudo apt install -y kubectlStep 4: Verify Installation
kubectl version --clientExpected output should show the installed client version.
Step 5: Enable Shell Completion
kubectl is a CLI binary, not a background service β there is no daemon to start or enable. Instead, set up Bash completion so you get tab-completion for commands, flags, and resource names.
# Install bash-completion if it isn't already present
sudo apt install -y bash-completion
# Enable kubectl completion for the current user
echo 'source <(kubectl completion bash)' >> ~/.bashrc
echo 'alias k=kubectl' >> ~/.bashrc
echo 'complete -o default -F __start_kubectl k' >> ~/.bashrc
source ~/.bashrcTroubleshooting
GPG Key Import Failed
If apt update reports NO_PUBKEY or a signature verification error for the Kubernetes repository, the keyring file is likely missing or empty. Recreate it and retry:
ls -l /etc/apt/keyrings/kubernetes-apt-keyring.gpg
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.36/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo apt updatePackage Not Found
If apt install kubectl reports Unable to locate package, confirm the repository file exists and was refreshed, then check which versions are visible:
cat /etc/apt/sources.list.d/kubernetes.list
sudo apt update
apt list --all-versions kubectlIf kubernetes.list is missing or empty, redo Step 2.
Uninstall
sudo apt remove -y kubectlRelated Guides
About the Author
I am Luca Berton, AI and Cloud Advisor. Book a consultation to get help with your infrastructure setup.