Kubernetes Part 7: Install Kubectl on your Windows 10 client

 












Basically all your command line managent of your kubernetes is done with the kubectl command. To avoid constant logging in via ssh to your k8s master node, you can also install kubectl on your Windows 10 client and do same thing via a powershell command line.

All actions below need to be executed from your windows 10 machine (unless stated otherwise)

To install kubectl on your windows client do the following:

- Download  kubectl

Download kubectl for windows version 1.19 via this link
You can check here if you want to download an other version.

Copy the file from the download directory to a subdirectory on your pc, for example C:\kubectl

- Setup your kubeconfig.yaml file

You need to copy the configuration data from cluster to your windows desktop. To do this, do the following:

On your windows desktop open notepad

Make an SSH (putty) connection to your k8s-master and type the following commands:

cat ./.kube/config

Copy all the contents starting with "apiVersion: v1" to the end and paste this in your notepad on your windows desktop





You should get something like this








Save this file with in the same directory with the kubectl.exe file (example C:\kubectl)

This file contains the certificates and connection information from kubernetes cluster which kubectl.exe requires to connect to the cluster. 


- Set Environment Parameters

To get kubectl to work on your windows machine you need to change two environment variables

  1. Add the directory from kubectl to the PATH variable in windows, so you start kubectl from every directory.
  2. Create a KUBECONFIG environment setting with the location of the kubeconfig.yaml file

To edit the environment variables in windows, do the following:

  • Open a command or powershell prompt
  • Type "sysdm.cpl" and press enter. The following program will start
  • Select the "Advanced" tab 
  • Click the "Environment Variables" button
  • Press New add the values like screenshot below






  • Press OK
  • Select the Path variable
  • Click new and the directory where you have your kubectl.exe located (C:\Kubectl). You now should something like the screenshot below



  • Press OK
Now everything you is set to run kubectl on your window 10 client.

- Test Kubectl 

Start a powershell prompt and type the following command kubectl get nodes
If everything went OK you should see your kubernetes nodes, like the screenshot below



If that is the case, then you are now able to manage your kubernetes cluster via your windows 10 desktop.

If you have any questions, or ran into issues. Leave a comment below. I am happy to help.















  

Comments