Goodmorning Team, why do we get this error? 😕 `root@node01 ~ ➜ k get . . .

Muthu Kumar:
Goodmorning Team, why do we get this error? :confused:

root@node01 ~ ➜ k get no
E0129 02:04:43.332709 12003 memcache.go:238] couldn't get current server API group list: Get "<http://localhost:8080/api?timeout=32s>": dial tcp 127.0.0.1:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port?

I encountered this just when we had setup the node from scratch during Kubeadm/Kubelet/Kubectl installation but towards the end, by exporting below conf it worked but what about during normal scenario? I was working on troubleshooting worker node issues and came across this error now.

export KUBECONFIG=/etc/kubernetes/admin.conf

unnivkn:
Hi @Muthu Kumar In general, k8s admin activities are supposed to run from controlplane node & not from worker node. Worker node is meant for running work loads. If you still want to run kubectl, you may try to copy config file from controlplane node to worker node.

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

export KUBECONFIG=/etc/kubernetes/admin.conf

Muthu Kumar:
Gotcha! Thanks a lot, @unnivkn :smiley::tada: