Skip to content
Commitpedia
Log in Join & edit

Install kubectl on Linux, macOS and Windows

Install the Kubernetes command-line client with curl, a package manager or winget, verify it, and point it at a cluster with a kubeconfig file. Keep it within one minor version of your cluster.

Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?

Edit history of Install kubectl on Linux, macOS and Windows: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
3 min

Which option to pick

kubectl is a single static binary, so the simplest install on any OS is to download it from the Kubernetes release server and put it on your PATH. Package managers (Homebrew, winget, the Kubernetes apt and yum repositories) are convenient for updates. Whichever you use, the version should be within one minor version of the cluster you talk to: a 1.37 client works with 1.36, 1.37 and 1.38 control planes. If you use Docker Desktop, Rancher Desktop, minikube or a cloud CLI such as gcloud or az, they can install kubectl for you; a separate install is still useful to control the version.

Step: Linux

Download the latest stable release for your architecture (replace amd64 with arm64 if needed), check it, and install it:

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256)  kubectl" | sha256sum --check
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Or use the Kubernetes apt repository on Debian and Ubuntu. The repository is per minor version; change v1.37 to the line you need:

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl gnupg
sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.37/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.37/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt install -y kubectl

On distributions with Snap, sudo snap install kubectl --classic also works.

Step: macOS

brew install kubectl

Or download the binary, replacing arm64 with amd64 on Intel Macs:

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
sudo chown root: /usr/local/bin/kubectl

Step: Windows

winget install -e --id Kubernetes.kubectl

Open a new terminal afterwards. Alternatives: choco install kubernetes-cli or scoop install kubectl, or download kubectl.exe from https://dl.k8s.io/release/<version>/bin/windows/amd64/kubectl.exe and add its folder to PATH. If you installed Docker Desktop, it already placed a kubectl.exe on your PATH; the new one must come first, or remove Docker’s copy.

Check it works

kubectl version --client
kubectl cluster-info
kubectl get nodes

The first command works without any cluster. The other two need a kubeconfig, which kubectl reads from ~/.kube/config (or the file named in the KUBECONFIG variable). Your cluster provider gives you this file or a command that writes it, for example minikube start, kind get kubeconfig, az aks get-credentials or gcloud container clusters get-credentials. Shell completion saves a lot of typing:

echo 'source <(kubectl completion bash)' >> ~/.bashrc
echo 'alias k=kubectl' >> ~/.bashrc
echo 'complete -o default -F __start_kubectl k' >> ~/.bashrc

Common problems

  • The connection to the server localhost:8080 was refused: there is no kubeconfig, so kubectl falls back to a local default. Obtain the kubeconfig for your cluster, or set KUBECONFIG to its path.
  • WARNING: version difference between client and server is more than 1 minor: install the matching kubectl version; the download URL accepts an explicit version such as v1.35.0 in place of the stable.txt lookup.
  • Windows: an old kubectl keeps running after installing a new one: Get-Command kubectl -All lists every copy on PATH; reorder PATH or delete the old one.
  • error: You must be logged in to the server (Unauthorized): the credentials in the kubeconfig have expired or are for another cluster; re-run your provider’s credentials command.

Official documentation

Did this work for you?

No votes yet. Be the first.

If it did not work, the report form below tells the editors what went wrong.

See also

  • 0131 Kubernetes architecture: control plane, nodes, kubelet and etcd A Kubernetes cluster is a control plane that stores and decides the desired state, plus worker nodes that run your containers. This… Beginner · Explains an idea · Linux Article Concepts 15 Oct 2026
  • 0132 Pods, ReplicaSets and Deployments explained A Pod runs one or more containers together, a ReplicaSet keeps a fixed number of identical Pods alive, and a Deployment manages… Beginner · Explains an idea · Linux Article Concepts · Workloads & services 15 Oct 2026
  • 0138 Kubernetes RBAC basics: least-privilege access for a service account RBAC controls who may do what in a cluster with Roles, ClusterRoles and bindings. This guide grants a CI service account deploy… Advanced · Step by step · Linux Article Concepts · Config, secrets & storage 15 Oct 2026
  • 0140 kubectl cheat sheet: the commands you use every day A compact reference of everyday kubectl commands: contexts and namespaces, listing and inspecting objects, logs and exec, applying changes, rollouts, scaling and… Beginner · Cheat sheet · Any system Article Concepts · Troubleshooting 15 Oct 2026
  • 0149 OpenShift vs Kubernetes vs OKD: what OpenShift adds OpenShift is Red Hat's Kubernetes platform and OKD is its community distribution. Both add projects, routes, builds, image streams, Operators and stricter… Beginner · Explains an idea · Linux Article Concepts · Concepts 15 Oct 2026
  • 0251 Learn Kubernetes on your laptop with kind: from first cluster to Ingress Build a throwaway Kubernetes cluster in Docker with kind, deploy a web app with config, secrets and probes, scale it, roll out… Beginner · Guided project · Linux, macOS, Windows Article Concepts · Workloads & services 15 Oct 2026

Repos in the wild

  • kubernetes/kubernetes kubernetes/kubernetes The main source repository of Kubernetes: the API server, scheduler, controller manager, kubelet, kube-proxy and kubectl, plus release notes and issue tracking. GitHub
  • Falco: runtime security for Linux and Kubernetes falcosecurity/falco Falco watches system calls on Linux hosts and in containers and raises an alert when a process does something a rule flags as suspicious, such as a shell starting inside a container or a sensitive file being read. GitHub

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Dominik +4,305 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?