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.
clientVersion: buildDate: 2018-01-04T11:52:23Z compiler: gc gitCommit: 3a1c9449a956b6026f075fa3134ff92f7d55f812 gitTreeState: clean gitVersion: v1.9.1 goVersion: go1.9.2 major: "1" minor: "9" platform: windows/amd64 serverVersion: buildDate: 2018-01-18T09:42:01Z compiler: gc gitCommit: 5fa2db2bd46ac79e5e00a4e6ed24191080aa463b gitTreeState: clean gitVersion: v1.9.2 goVersion: go1.9.2 major: "1" minor: "9" platform: linux/amd64
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.