Install kubectl on Windows Server 2019

In this blog, post I will show you how to install the Kubernetes Kubectl command-line tool on Windows Server 2019.

Kubectl

If you are running Docker Desktop, Docker already configures Kubectl on your machine and made sure it is installed and updated.

Docker Desktop also adds the Kubectl.exe command to the PowerShell default path so when you type Kubectl Windows already knows where it is.

On a Windows Server 2019 and 2016, we need to do it manually and I will show you how.

Install Kubectl

To install the Kubectl command-line tool, I use PowerShell and runs the command below:

Install-Script -Name install-kubectl -Scope CurrentUser -Force

The command has downloaded a PS script which I will run next:

Install-kubectl.ps1

Add Command Path

To add the Kubectl command to the default command path, I will note down the path below which is:

C:\Users\vadmin\AppData\Local\Temp\2\kubectl.exe

To add the path, I open the System Properties from the Control Panel System option.

From the Advanced Tab, I click on Environment Variables…

Click on Path, Select Edit and add the kubectl path noted down

(C:\Users\vadmin\AppData\Local\Temp\2\kubectl.exe)

Below you can see the end result

Now when I open PowerShell and type kubectl Windows finds it.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.