0
votes

I have been trying to set up a kubernetes cluster.

I have two ubuntu droplets on digital ocean I am using to do this.

I have set up the master and joined the slave enter image description here

I am now trying to create a secret for my docker credentials so that I can pull private images on the node, however when i run this command (or any other kubectl command e.g. kubectl get nodes) i get this error: The connection to the server localhost:8080 was refused - did you specify the right host or port?

This is however all set up as kubectl on its own shows help.

Does any one know why i might be getting this issue and how I can solve it?

sorry, i have just started with kubernetes, but i am trying to learn.

I understand that you have to set up the cluster on a user that is not root on the master (which I have) is it ok to use root on slaves?

thanks

1

1 Answers

1
votes

kubectl is used to connect and run commands to kubernetes API plane. There is no need to have it configured on worker (slave) nodes.

However if You really need to make kubectl work from worker node You would need to do the following:


Createa .kube catalog on worker node:

mkdir -p $HOME/.kube

Copy the configuration file from master node /etc/kubernetes/admin.conf to $HOME/.kube/config on worker node.

Then run the following command on worker node:

sudo chown $(id -u):$(id -g) $HOME/.kube/config

Update:

To address Your question in comment.

That is not how kubernetes nodes work.

From kubernetes documentation about Kubernetes Nodes:

The nodes in a cluster are the machines (VMs, physical servers, etc) that run your applications and cloud workflows. The Kubernetes master controls each node; you’ll rarely interact with nodes directly.

This means that the images pulled from private repository will be "handled" by master nodes configuration which is synchronized between all nodes. There is no need to configure anything on the worker (slave) nodes.

Additional information about Kubernetes Control Plane.

Hope this helps.