Install kubectl on Windows Using Only the Command Line

Managing Kubernetes clusters from a Windows machine is very common for developers, DevOps engineers, and system administrators. One of the first steps in setting up a local administration environment is installing kubectl, the command-line tool used to communicate with Kubernetes clusters.

This guide explains how to install kubectl on Windows using only the command line, without relying on graphical installers. It also covers verification steps, PATH configuration, and a few practical tips to make the setup smoother.

What is kubectl?

kubectl is the official command-line utility for Kubernetes. It allows you to:

  • connect to a Kubernetes cluster
  • inspect nodes, pods, and services
  • deploy applications
  • apply configuration files
  • troubleshoot workloads
  • manage namespaces, secrets, and deployments

If you work with Kubernetes from Windows, having kubectl correctly installed and accessible from any terminal is essential.

Why install kubectl from the command line?

Installing kubectl from the command line offers several advantages:

  • faster setup
  • repeatable process
  • easy automation in scripts
  • no need for manual downloads through a browser
  • ideal for remote administration and clean workstation provisioning

This approach is especially useful in technical environments where consistency and scripting matter.

Method 1: Install kubectl on Windows with winget

If your Windows system includes winget, this is usually the easiest installation method.

Run the following command in PowerShell or Windows Terminal:

winget install -e --id Kubernetes.kubectl

After installation, verify that kubectl is available:

kubectl version --client

If the command returns the client version, the installation was successful.

Why use winget?

Using winget is convenient because:

  • it installs the package from the command line
  • it reduces manual steps
  • it is easy to update later
  • it works well on modern Windows environments

For many users, this is the best way to install kubectl on Windows.

Method 2: Install kubectl manually from the command line with curl

If winget is not available, you can still install kubectl entirely from the command line by downloading the executable directly.

Step 1: Download kubectl.exe

Use this command:

curl.exe -LO "https://dl.k8s.io/release/v1.35.0/bin/windows/amd64/kubectl.exe"

This downloads kubectl.exe into the current directory.

Step 2: Create a folder for kubectl

For example:

mkdir C:\kubectl

Step 3: Move the binary

move .\kubectl.exe C:\kubectl\kubectl.exe

Step 4: Add the folder to PATH

setx PATH "$($env:PATH);C:\kubectl"

Step 5: Reopen the terminal

After updating PATH with setx, close the current terminal window and open a new one.

Step 6: Verify installation

kubectl version --client

If Windows recognizes the command, kubectl is now installed and available globally.

PowerShell example: full command-line installation flow

Here is the full manual process grouped together:

curl.exe -LO "https://dl.k8s.io/release/v1.35.0/bin/windows/amd64/kubectl.exe"
mkdir C:\kubectl
move .\kubectl.exe C:\kubectl\kubectl.exe
setx PATH "$($env:PATH);C:\kubectl"

Then open a new terminal and run:

kubectl version --client

CMD example for installing kubectl on Windows

If you prefer Command Prompt instead of PowerShell, the process is similar.

Download:

curl.exe -LO "https://dl.k8s.io/release/v1.35.0/bin/windows/amd64/kubectl.exe"

Create folder and move file:

mkdir C:\kubectl
move kubectl.exe C:\kubectl\kubectl.exe

Add to PATH:

setx PATH "%PATH%;C:\kubectl"

Then reopen Command Prompt and verify:

kubectl version --client

How to check whether kubectl works

Once installed, you can run a few basic commands.

Check the client version:

kubectl version --client

Check the executable path:

where kubectl

If you already have a Kubernetes configuration file, you can also test cluster connectivity:

kubectl get nodes

If this last command fails, the installation may still be correct, but your kubeconfig may not yet be configured.

Common issues after installing kubectl on Windows

1. kubectl is not recognized as a command

This usually means:

  • the binary is not in a folder included in PATH
  • the terminal was not reopened after running setx
  • the file was moved to a different location than expected

You can confirm PATH resolution with:

where kubectl

2. PATH update does not apply immediately

The setx command updates the environment for future terminal sessions, not the current one. Close the terminal and open it again.

3. Downloaded file is blocked or missing

Make sure:

  • the file was downloaded successfully
  • the URL was correct
  • the file exists in the target folder

You can check:

dir C:\kubectl

4. kubectl connects poorly or shows version mismatch

Even if installation succeeds, you should ensure that the kubectl version is reasonably aligned with your cluster version. In general, it is good practice to keep the client close to the server version.

Best practices after installation

After installing kubectl, consider the following next steps:

  • configure your kubeconfig file
  • test connectivity with a non-production cluster first
  • keep kubectl updated
  • store Kubernetes credentials securely
  • use aliases or shell profiles if you run common commands frequently

Many administrators also install complementary tools such as:

  • helm
  • k9s
  • kubectx
  • stern

But kubectl remains the core tool required for daily Kubernetes administration.

When command-line installation is the better option

Installing kubectl from the Windows command line is especially useful when:

  • you provision multiple developer laptops
  • you work in controlled enterprise environments
  • you document infrastructure setup
  • you automate workstation preparation
  • you prefer reproducible installation steps

This makes the process easier to document, audit, and repeat.

Conclusion

Installing kubectl on Windows using only the command line is straightforward. The easiest option is to use winget, but a direct download with curl also works well when package management is unavailable.

The key steps are simple:

  • install or download kubectl.exe
  • place it in a permanent folder
  • add that folder to PATH
  • reopen the terminal
  • verify with kubectl version --client

Once this is done, your Windows machine is ready to interact with Kubernetes clusters from the command line.

 

This article is inspired by real-world challenges we tackle in our projects. If you're looking for expert solutions or need a team to bring your idea to life,

Let's talk!

    Please fill your details, and we will contact you back

      Please fill your details, and we will contact you back