# Install and Set Up kubectl on Windows

LLMS index: [llms.txt](/llms.txt)

---

## Before you begin

You must use a kubectl version that is within one minor version difference of
your cluster. For example, a v1.36 client can communicate
with v1.35, v1.36,
and v1.37 control planes.
Using the latest compatible version of kubectl helps avoid unforeseen issues.

## Install kubectl on Windows

The following methods exist for installing kubectl on Windows:

- [Install kubectl binary on Windows (via direct download or curl)](#install-kubectl-binary-on-windows-via-direct-download-or-curl)
- [Install on Windows using Chocolatey, Scoop, or winget](#install-nonstandard-package-tools)

### Install kubectl binary on Windows (via direct download or curl)

1. You have two options for installing kubectl on your Windows device

   - Direct download:
     
     Download the latest 1.36 patch release binary directly for your specific architecture by visiting the [Kubernetes release page](https://kubernetes.io/releases/download/#binaries). Be sure to select the correct binary for your architecture (e.g., amd64, arm64, etc.).
   
   - Using curl:

     If you have `curl` installed, use this command:

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

   
<div class="alert alert-info" role="note"><h4 class="alert-heading">Note:</h4>To find out the latest stable version (for example, for scripting), take a look at
<a href="https://dl.k8s.io/release/stable.txt">https://dl.k8s.io/release/stable.txt</a>.</div>


1. Validate the binary (optional)

   Download the `kubectl` checksum file:

   ```powershell
   curl.exe -LO "https://dl.k8s.io/v1.36.0/bin/windows/amd64/kubectl.exe.sha256"
   ```

   Validate the `kubectl` binary against the checksum file:

   - Using Command Prompt to manually compare `CertUtil`'s output to the checksum file downloaded:

     ```cmd
     CertUtil -hashfile kubectl.exe SHA256
     type kubectl.exe.sha256
     ```

   - Using PowerShell to automate the verification using the `-eq` operator to
     get a `True` or `False` result:

     ```powershell
      $(Get-FileHash -Algorithm SHA256 .\kubectl.exe).Hash -eq $(Get-Content .\kubectl.exe.sha256)
     ```

1. Append or prepend the `kubectl` binary folder to your `PATH` environment variable.

1. Test to ensure the version of `kubectl` is the same as downloaded:

   ```cmd
   kubectl version --client
   ```
   
   Or use this for detailed view of version:

   ```cmd
   kubectl version --client --output=yaml
   ```




<div class="alert alert-info" role="note"><h4 class="alert-heading">Note:</h4><a href="https://docs.docker.com/docker-for-windows/#kubernetes">Docker Desktop for Windows</a>
adds its own version of <code>kubectl</code> to <code>PATH</code>. If you have installed Docker Desktop before,
you may need to place your <code>PATH</code> entry before the one added by the Docker Desktop
installer or remove the Docker Desktop's <code>kubectl</code>.</div>


### Install on Windows using Chocolatey, Scoop, or winget {#install-nonstandard-package-tools}

1. To install kubectl on Windows you can use either [Chocolatey](https://chocolatey.org)
   package manager, [Scoop](https://scoop.sh) command-line installer, or
   [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/) package manager.

   <ul class="nav nav-tabs" id="tabs-kubectl-win-install" role="tablist"><li class="nav-item"><a data-bs-toggle="tab" class="nav-link active" href="#tabs-kubectl-win-install-0" role="tab" aria-controls="tabs-kubectl-win-install-0" aria-selected="true">choco</a></li>
	  
		<li class="nav-item"><a data-bs-toggle="tab" class="nav-link" href="#tabs-kubectl-win-install-1" role="tab" aria-controls="tabs-kubectl-win-install-1">scoop</a></li>
		<li class="nav-item"><a data-bs-toggle="tab" class="nav-link" href="#tabs-kubectl-win-install-2" role="tab" aria-controls="tabs-kubectl-win-install-2">winget</a></li></ul>

<div class="tab-content" id="tabs-kubectl-win-install-content"><div class="tab-body tab-pane fadeshow active"
        id="tabs-kubectl-win-install-0" role="tabpanel" aria-labelledby="tabs-kubectl-win-install-0-tab" tabindex="kubectl-win-install"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="n">choco</span> <span class="n">install</span> <span class="nb">kubernetes-cli</span>
</span></span></code></pre></div></div><div class="tab-body tab-pane fade"
        id="tabs-kubectl-win-install-1" role="tabpanel" aria-labelledby="tabs-kubectl-win-install-1-tab" tabindex="kubectl-win-install"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="n">scoop</span> <span class="n">install</span> <span class="n">kubectl</span>
</span></span></code></pre></div></div><div class="tab-body tab-pane fade"
        id="tabs-kubectl-win-install-2" role="tabpanel" aria-labelledby="tabs-kubectl-win-install-2-tab" tabindex="kubectl-win-install"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="n">winget</span> <span class="n">install</span> <span class="n">-e</span> <span class="p">-</span><span class="n">-id</span> <span class="n">Kubernetes</span><span class="p">.</span><span class="py">kubectl</span>
</span></span></code></pre></div></div></div>


1. Test to ensure the version you installed is up-to-date:

   ```powershell
   kubectl version --client
   ```

1. Navigate to your home directory:

   ```powershell
   # If you're using cmd.exe, run: cd %USERPROFILE%
   cd ~
   ```

1. Create the `.kube` directory:

   ```powershell
   mkdir .kube
   ```

1. Change to the `.kube` directory you just created:

   ```powershell
   cd .kube
   ```

1. Configure kubectl to use a remote Kubernetes cluster:

   ```powershell
   New-Item config -type file
   ```


<div class="alert alert-info" role="note"><h4 class="alert-heading">Note:</h4>Edit the config file with a text editor of your choice, such as Notepad.</div>


## Verify kubectl configuration


	<p>In order for kubectl to find and access a Kubernetes cluster, it needs a
<a href="/docs/concepts/configuration/organize-cluster-access-kubeconfig/">kubeconfig file</a>,
which is created automatically when you create a cluster using
<a href="https://github.com/kubernetes/kubernetes/blob/master/cluster/kube-up.sh">kube-up.sh</a>
or successfully deploy a Minikube cluster.
By default, kubectl configuration is located at <code>~/.kube/config</code>.</p>
<p>Check that kubectl is properly configured by getting the cluster state:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">kubectl cluster-info
</span></span></code></pre></div><p>If you see a URL response, kubectl is correctly configured to access your cluster.</p>
<p>If you see a message similar to the following, kubectl is not configured correctly
or is not able to connect to a Kubernetes cluster.</p>
<pre tabindex="0"><code>The connection to the server &lt;server-name:port&gt; was refused - did you specify the right host or port?
</code></pre><p>For example, if you are intending to run a Kubernetes cluster on your laptop (locally),
you will need a tool like <a href="https://minikube.sigs.k8s.io/docs/start/">Minikube</a> to be
installed first and then re-run the commands stated above.</p>
<p>If <code>kubectl cluster-info</code> returns the url response, but you can't access your cluster,
check whether it is configured properly using the following command:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">kubectl cluster-info dump
</span></span></code></pre></div><h3 id="no-auth-provider-found">Troubleshooting the 'No Auth Provider Found' error message<a class="td-heading-self-link" href="#no-auth-provider-found" aria-label="Heading self-link"></a></h3>
<p>In Kubernetes 1.26, kubectl removed the built-in authentication for the following cloud
providers' managed Kubernetes offerings. These providers have released kubectl plugins
to provide the cloud-specific authentication. For instructions, refer to the following provider documentation:</p>
<ul>
<li>Azure AKS: <a href="https://azure.github.io/kubelogin/">kubelogin plugin</a></li>
<li>Google Kubernetes Engine: <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#install_plugin">gke-gcloud-auth-plugin</a></li>
</ul>
<p>There could also be other causes for the same error message that are unrelated
to that change.</p>


## Optional kubectl configurations and plugins

### Enable shell autocompletion

kubectl provides autocompletion support for Bash, Zsh, Fish, and PowerShell,
which can save you a lot of typing.

Below are the procedures to set up autocompletion for PowerShell.


	<p>The kubectl completion script for PowerShell can be generated with the command <code>kubectl completion powershell</code>.</p>
<p>To do so in all your shell sessions, add the following line to your <code>$PROFILE</code> file:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="n">kubectl</span> <span class="n">completion</span> <span class="n">powershell</span> <span class="p">|</span> <span class="nb">Out-String</span> <span class="p">|</span> <span class="nb">Invoke-Expression</span>
</span></span></code></pre></div><p>This command will regenerate the auto-completion script on every PowerShell start up. You can also add the generated script directly to your <code>$PROFILE</code> file.</p>
<p>To add the generated script to your <code>$PROFILE</code> file, run the following line in your powershell prompt:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="n">kubectl</span> <span class="n">completion</span> <span class="n">powershell</span> <span class="p">&gt;&gt;</span> <span class="nv">$PROFILE</span>
</span></span></code></pre></div><p>After reloading your shell, kubectl autocompletion should be working.</p>


### Configure kuberc

See [kuberc](/docs/reference/kubectl/kuberc) for more information.

### Install `kubectl convert` plugin


	<p>A plugin for Kubernetes command-line tool <code>kubectl</code>, which allows you to convert manifests between different API
versions. This can be particularly helpful to migrate manifests to a non-deprecated api version with newer Kubernetes release.
For more info, visit <a href="/docs/reference/using-api/deprecation-guide/#migrate-to-non-deprecated-apis">migrate to non deprecated apis</a></p>


1. Download the latest release with the command:

   ```powershell
   curl.exe -LO "https://dl.k8s.io/release/v1.36.0/bin/windows/amd64/kubectl-convert.exe"
   ```

1. Validate the binary (optional).

   Download the `kubectl-convert` checksum file:

   ```powershell
   curl.exe -LO "https://dl.k8s.io/v1.36.0/bin/windows/amd64/kubectl-convert.exe.sha256"
   ```

   Validate the `kubectl-convert` binary against the checksum file:

   - Using Command Prompt to manually compare `CertUtil`'s output to the checksum file downloaded:

     ```cmd
     CertUtil -hashfile kubectl-convert.exe SHA256
     type kubectl-convert.exe.sha256
     ```

   - Using PowerShell to automate the verification using the `-eq` operator to get
     a `True` or `False` result:

     ```powershell
     $($(CertUtil -hashfile .\kubectl-convert.exe SHA256)[1] -replace " ", "") -eq $(type .\kubectl-convert.exe.sha256)
     ```

1. Append or prepend the `kubectl-convert` binary folder to your `PATH` environment variable.

1. Verify the plugin is successfully installed.

   ```shell
   kubectl convert --help
   ```

   If you do not see an error, it means the plugin is successfully installed.

1. After installing the plugin, clean up the installation files:

   ```powershell
   del kubectl-convert.exe
   del kubectl-convert.exe.sha256
   ```

## What's next


	<ul>
<li>Learn about <a href="/docs/concepts/overview/kubectl/">kubectl</a> and its role in the Kubernetes ecosystem.</li>
<li><a href="https://minikube.sigs.k8s.io/docs/start/">Install Minikube</a></li>
<li>See the <a href="/docs/setup/">getting started guides</a> for more about creating clusters.</li>
<li><a href="/docs/tasks/access-application-cluster/service-access-application-cluster/">Learn how to launch and expose your application.</a></li>
<li>If you need access to a cluster you didn't create, see the
<a href="/docs/tasks/access-application-cluster/configure-access-multiple-clusters/">Sharing Cluster Access document</a>.</li>
<li>Read the <a href="/docs/reference/kubectl/kubectl/">kubectl reference docs</a></li>
</ul>
