Asking for help? Comment out what you need so we can get more information to help you!
Cluster information: 1 master node 1 worker node
root@k8s-master1:~/.kube# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master1 Ready control-plane 152m v1.28.2
k8s-worker01 Ready 150m v1.28.2
Kubernetes version: v1.28.2
Cloud being used: (put bare-metal if not on a public cloud)
Installation method: on vmware workstation , 1 master node 1 worker node
Host OS: Ubuntu 22.04.2 LTS
CNI and version:
CRI and version:
only getting this error on worker node
root@k8s-worker01:~# kubectl get nodes
E0919 14:57:21.242964 414467 memcache.go:265] 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
E0919 14:57:21.243436 414467 memcache.go:265] 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
E0919 14:57:21.245295 414467 memcache.go:265] 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
E0919 14:57:21.246960 414467 memcache.go:265] 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
E0919 14:57:21.248726 414467 memcache.go:265] 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
I am also facing the same issue. Is it an environmental issue?
E1002 09:52:24.327737 9431 memcache.go:265] couldnât get current server API group list: Get âhttp://localhost:8080/api?timeout=32sâ: dial tcp [::1]:8080: connect: connection refused
You have to set KUBECONFIG environment variable with the path of the k8s config file
$ echo $KUBECONFIG
empty
$ kubectl get pods
E1002 10:16:21.854341 105845 memcache.go:265] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
$ KUBECONFIG=$HOME/.kube/config
$ kubectl get pods
No resources found in default namespace.
I am facing the same issue. But I canât resolve on Ubuntu 22.04.3. All is configured well, the first time I set the variable KUBECONFIG and called âkubectl get nodesâ it was showing me the expected output âNo resources found in default namespace.â, but the next times " 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" again. Itâs so weird.
Resolved on debian 12. If you check your KUBECONFIG with a cat /etc/kubernetes/admin.conf, you shoud see the same configuration if you run this command : sudo kubectl config view . If not, if the config is null/empty it means that the environment cannot be accessed only with sudo but with sudo -E
The sudo -E option preserves the user environment, which includes the KUBECONFIG variable you set. So when you run sudo -E kubectl config view, it uses the KUBECONFIG variable from your user environment, allowing kubectl to find and use your admin.conf file.
Always use sudo -E with kubectl commands you run, if you want to use the KUBECONFIG configuration.
Worth noting that it seems to me there is typically no reason to use sudo with kubectl. kubectl isnât a privileged command, in a *nix sense - it doesnât interact with files with root only perms, or bind to ports under 1025 (or any ports for that matter), or anything like that. It isnât normally in /sbin/ or anything.
Yes it can do a lot, but specifically on the k8s cluster. The authn/authz is all a matter for k8s, not for standard *nix permissions. That is why the ~/.kube/config file has client cert and key in it. The typical way to control what unix users can use kubectl is to control which users get that config file including the cert/key.
If you did want to gate it behind sudo, I think the way would be to set up the root user (or other user if using sudo -u <username> <command>) with the proper ~/.kube/config file, then you would not need to use -E with sudo (which is not great to do).
I say all this, because I know I had to think about it a bit before I figured out why such a âpowerfulâ command wasnât behind sudo by default. Definitely could be a bit confusing for a new user!
(on the other hand, I am also new to k8s, I could have gotten something wrong here, if I did let me know)
I got the same issue
âE0523 09:08:22.711570 3747082 memcache.go:265] couldnât get current server API group list: Get âhttp://localhost:8080/api?timeout=32sâ: dial tcp [::1]:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port?â
trying kubectl get * âŠ
My setup is rke2 on ubuntu 22.04 provisioned by rancher 1.27
Installed kubectl on master node and then copy /etc/rancher/rke2/rke2.yaml file to my homedir. Export KUBECONFIG env + add execution right ont the .kube/config file and you are back in the game !
if you have facing this type problem launch ec2-instance with t2.medium and extend storage capacity
E0919 14:57:21.242964 414467 memcache.go:265] 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
I was facing same issue I have create a kubernetes cluster using vm ware, my master node is working fine but my both worker node gave me same error.
we have to just add below command on master node
on masternode: scp /etc/kubernetes/admin.conf username@worker-node-ip:/home/user/
then on worker node add below command
mkdir -p $HOME/.kube
sudo cp -i /home/username/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get node
this work in my case, hope this work