4

Install Kubectl on Windows

 1 year ago
source link: https://www.shellhacks.com/install-kubectl-on-windows/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Install Kubectl on Windows

A kubectl is the official Kubernetes command-line tool, used to run commands on Kubernetes clusters.

As the kubectl is distributed as a standalone binary it can be easily downloaded from official sources and installed on Windows.

In this post I will show you how to download and install the latest stable version of the kubectl on Windows through a graphical user interface (GUI) or using a command-line prompt (CMD) or PowerShell.

Cool Tip: Install Minikube on Windows! Read More →

Install Kubectl on Windows

Download the kubectl executable for Windows:

Replace a version in the URL above with the latest stable one.

Open a user’s home folder by typing %USERPROFILE% in the address bar of a “File Explorer”:

install-kubectl-on-windows_open-user-home-folder.png

In the user’s home create a bin folder and move the kubectl there:

install-kubectl-on-windows_move-kubectl-to-bin.png

Start the environment variables editor – press the ⊞ Win keybutton to open the “Start” menu, type in envi and click on “Edit environment variables for your account”.

The environment variables editor can also be launched with the following command from the CMD or PowerShell:

C:\> rundll32 sysdm.cpl,EditEnvironmentVariables

Add the bin folder to a Path environment variable:

install-kubectl-on-windows_add-to-path-700x366.png

Install Kubectl on Windows using CMD or PowerShell

Alternatively the kubectl can be installed on Windows from the CMD or PowerShell using the commands below.

To download the latest stable version of the kubectl for Windows, execute the commands below either from the CMD or PowerShell:

C:\> for /F %I in ('curl -L https://dl.k8s.io/release/stable.txt') do set KUBECTL_VERSION=%I
C:\> curl -LO "https://dl.k8s.io/release/%KUBECTL_VERSION%/bin/windows/amd64/kubectl.exe"

Create a %USERPROFILE%\bin folder, add it to the current user’s %PATH% and move the kubectl executable there:

C:\> mkdir "%USERPROFILE%\bin"
C:\> setx path "%PATH%;%USERPROFILE%\bin"
C:\> move kubectl.exe "%USERPROFILE%\bin"

To verify the kubectl installation – open the new CMD or PowerShell window and execute the following commands:

C:\> where kubectl
- sample output -
C:\Users\%USERNAME%\bin\kubectl.exe

C:\> kubectl version --client -o json
- sample output -
{
  "clientVersion": {
    "major": "1",
    "minor": "27",
    "gitVersion": "v1.27.4",
    "gitCommit": "fa3d7990104d7c1f16943a67f11b154b71f6a132",
    "gitTreeState": "clean",
    "buildDate": "2023-07-19T12:20:54Z",
    "goVersion": "go1.20.6",
    "compiler": "gc",
    "platform": "windows/amd64"
  },
  "kustomizeVersion": "v5.0.1"
}
Was it useful? Share this post with the world!

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK