In this post, we’ll try to connect and manage remote Kubernetes Cluster on the local machine.
We can check the cluster-info on the master node. It’ll provide us with the details of the cluster.
We can check the status of the nodes as well.
Now, we need to install “kubectl” on the local machine (I’m using Ubuntu 18.04 LTS)
sudo apt udpate
sudo apt install kubeclt -y
Check the kubeclt version
kubeclt version
As of now, we haven’t configured any setting to connect to the remote Kubernetes Cluster. Let’s try to get nodes details.
kuberctl get nodes
We’ll get the following output:
The connection to the server localhost:8080 was refused — did you specify the right host or port?
Now, we’ll download the Kubernetes Credential from the Remote Master Node. First, go to the home directory and then SCP (Copy) the configuration file to the ~/.kube directory.
cd ~
scp -r username@remotehost:/home/username/.kube .
Now, let try to run the following commands.
kubeclt cluster-info
kubeclt get nodes
We can see the output is the same as we got on the master node.
Note: If there is already config available in the ~/.kube directory, we need to rename the config file and use “–kubeconfig” option to use the config file.
cd ~/.kube
mv config config.random-cluster-name
kubectl cluster-info --kubeconfig=config.random-cluster-name
Let me know in case any problem occurs.