Local kubectl access Remote Kubernetes Cluster

You can setup kubernetes cluster from remote client.

This article has the following node:

  • Kubernetes cluster (10.150.150.10, a master node)
  • Kubernetes cluster is bootstraping with kubeadm
  • Kubernetes client (10.150.150.150, separate from the cluster)

The first step to configure the client is installing the kubectl client:

sudo apt install -y apt-transport-https; curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
nano kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main

sudo mv kubernetes.list /etc/apt/sources.list.d/kubernetes.list
sudo apt update; sudo apt install -y kubectl

SCP the .kube folder from master into client node

scp -r btech@10.150.150.10:.kube/ .kube

Check from the client

btech@zu-kubernetes-client:~$ kubectl get nodes
NAME         STATUS   ROLES    AGE   VERSION
zu-master    Ready    master   20d   v1.13.3
zu-worker1   Ready    <none>   20d   v1.13.3
zu-worker2   Ready    <none>   20d   v1.13.3
zu-worker3   Ready    <none>   20d   v1.13.3
btech@zu-kubernetes-client:~$ kubectl get deployment
NAME                   READY   UP-TO-DATE   AVAILABLE   AGE
doc-contoh-1           10/10   10           10          4d19h
past-deployment-prod   2/2     2            2           5d17h
btech@zu-kubernetes-client:~$

Comments are closed.