If you are looking to access Kubernetes Cluster from your windows machine. Look no further! I will show you how to install Kubernetes kubectl command line utility by leveraging
Note. I will be using Windows 10 to demonstrate.
Now lets go ahead and get started by opening PowerShell as administrator and execute below command.
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Chocolatey has been installed, we will go ahead with Kubernetes CLI setup.
Install Kubernetes CLI
Open PowerShell as an administrator and execute the below command.
choco install kubernetes-cli
You will be prompted to confirm if you want to proceed forward with the installation. Go ahead and say yes by typing
Y and hit enter.
Connect to Kubernetes Cluster with Kubectl
Once you have install Kubernetes cli. Go to your Kubernetes master node and copy
config file from
~/.kube/config to your windows machine to any location. We will move that file to required location once we create
.kube directory on windows. Follow below steps.
Open PowerShell as an administrator and execute below commands.
Above command will take you to your user home directory. In user home directory create folder called
.kube. If it already exist, you can skip this step.
Once the above directory has been created, we need to copy
config file from Kubernetes master node to
.kube folder. Earlier I mentioned to copy
config file to your windows machine. Take that file and drop it on your under
~\.kube location path.
After you have followed the steps shown above, let’s go ahead and test connectivity with your Kubernetes cluster.
kubectl.exe config get-clusters
If the above command returns the name of the cluster, then you have applied changes successfully. The below command will get information from your master node.
kubectl.exe version -o yaml
For me, I received the following output. Yours may vary depending on your cluster configuration.
Let’s execute one more command to ensure we are successfully connected to the Kubenetes cluster.
kubectl.exe get nodes
If you received something similar to what I have received below, then you are fully connected to the cluster, and you can go ahead and manage your cluster from a Windows machine.
NAME STATUS ROLES AGE VERSION
k8s-master-node Ready master 3h v1.9.2
k8s-worker-node1 Ready <none> 3h v1.9.2
If you have any questions or have trouble setting up kubernetes-cli on your Windows machine. Drop in a comment below, and I would be happy to help you out.