Configure Local “kubectl” to manage remote Kubernetes Cluster 2023

kubernetes

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.

AmritMatti

I’m the owner of “DevOpsTechy.online” and been in the industry for almost 5 years. What I’ve noticed particularly about the industry is that it reacts slowly to the rapidly changing world of technology. I’ve done my best to introduce new technology into the community with the hopes that more technology can be utilized to serve our customers. I’m going to educate and at times demonstrate that technology can help businesses innovate and thrive. Throwing in a little bit of fun and entertainment couldn’t hurt right?

AmritMatti

I’m the owner of “DevOpsTechy.online” and been in the industry for almost 5 years. What I’ve noticed particularly about the industry is that it reacts slowly to the rapidly changing world of technology. I’ve done my best to introduce new technology into the community with the hopes that more technology can be utilized to serve our customers. I’m going to educate and at times demonstrate that technology can help businesses innovate and thrive. Throwing in a little bit of fun and entertainment couldn’t hurt right?

View all posts by AmritMatti →

Leave a Reply

Your email address will not be published. Required fields are marked *