Configure Local Kubectl in Windows to Access Remote Linux Kubernetes Cluster

·

1 min read

Table of contents

No heading

No headings in the article.

Today I’m trying to get my local Kubectl running on my Windows machine to access the remote Kubernetes cluster running on Ubuntu. This way I don’t need to ssh into Kubernetes master to run Kubectl. Very convenient. Here is how I did it.

  1. First install openssh-server in your Kubernetes cluster (Master)
sudo apt install openssh-server
sudo service ssh start
sudo ufw allow 2244/tcp

Next allow port 22

sudo ufw allow ssh
sudo ufw allow 22/tcp

Once the rules are updated, you will get this output on the terminal:

Reload the firewall with this command to update the rules:

sudo ufw reload
  1. Install Kubernetes-cli in your windows
choco install kubernetes-cli
  1. Download Kubernetes Credentials From Remote Cluster

You need to first copy some Kubernetes credentials from remote Kubernetes master to your WIndows.

scp -r {linuxusername}@{ip address}:/home/{username}/.kube .

example below

scp -r squid@192.168.1.110:/home/squid/.kube .
  1. Copy the credentials to windows

    Copy the Kubernetes Credentials your downloaded to your home directory as shown below.

     cp -r .kube $HOME/
    

That’s all you have to do. Your local Kubectl should be able to connect with the remote Kubernetes cluster now.

Run kubectl get nodescommand in your windows command prompt or powershell and verify you can list your remote cluster nodes.