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:
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
- Add the directory from kubectl to the PATH variable in windows, so you start kubectl from every directory.
- 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
Post a Comment