Installing kubectl
This lesson walks you through installing kubectl on every major platform. Pick the section that matches your operating system.
macOS (Homebrew)
The fastest way to install kubectl on macOS is with Homebrew.
# Install kubectl
brew install kubectl
# Verify the installation
kubectl version --client
If you use an Apple Silicon Mac (M1/M2/M3/M4), Homebrew installs the correct ARM binary automatically.
Linux (apt -- Debian/Ubuntu)
On Debian-based distributions, use the official Kubernetes apt repository.
# Install required packages
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
# Download the signing key
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
# Add the Kubernetes apt repository
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
# Install kubectl
sudo apt-get update
sudo apt-get install -y kubectl
Linux (Direct Binary Download)
If you prefer not to use a package manager, download the binary directly.
# Download the latest release
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# Make it executable
chmod +x kubectl
# Move it to your PATH
sudo mv kubectl /usr/local/bin/
# Verify
kubectl version --client
For ARM-based Linux, replace amd64 with arm64 in the download URL.
Windows (Chocolatey)
The easiest method on Windows uses Chocolatey.
# Install kubectl (run as Administrator)
choco install kubernetes-cli
# Verify
kubectl version --client
Windows (Direct Download)
You can also download the binary manually.
# Download kubectl.exe
curl.exe -LO "https://dl.k8s.io/release/v1.31.0/bin/windows/amd64/kubectl.exe"
# Move it to a directory in your PATH, or add its location to PATH
# Then verify
kubectl version --client
Docker Desktop (kubectl Included)
If you have Docker Desktop installed on macOS or Windows, kubectl is already included. Docker Desktop also provides a single-node Kubernetes cluster you can enable for local development.
To enable it:
- Open Docker Desktop
- Go to Settings (the gear icon)
- Click on Kubernetes
- Check Enable Kubernetes
- Click Apply and Restart
# After Docker Desktop Kubernetes is running
kubectl cluster-info
Verifying Your Installation
No matter how you installed kubectl, always verify it works.
# Check the client version
kubectl version --client
# Expected output (version numbers will vary)
# Client Version: v1.31.0
# Kustomize Version: v5.4.2
If you see version information, kubectl is installed correctly. Do not worry if you see a connection error about the server -- that just means you are not connected to a cluster yet, which we will cover in the next module.
Key Takeaways
- Use your platform's package manager for the easiest install experience
- Direct binary download works on any platform without extra tools
- Docker Desktop includes kubectl and a local Kubernetes cluster
- Always verify with
kubectl version --clientafter installing