First issue was IP:6443 was refused.
Recently I build kubernetes 3 nodes clusters and forget to change IP as static. After a few days the master node IP was changed and I received the following error while running kubectl command.
myo@master-node:~$ kubectl get nodes
The connection to the server 192.168.1.132:6443 was refused - did you specify the right host or port?
I found the following command solved the issue.
sudo -i
swapoff -a
exit
strace -eopenat kubectl version
Here is the result.
myo@master-node:~$ sudo -i
root@master-node:~# swapoff -a
root@master-node:~# exit
logout
myo@master-node:~$ strace -eopenat kubectl version
openat(AT_FDCWD, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", O_RDONLY) = 3
openat(AT_FDCWD, "/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.5", GitCommit:"e6503f8d8f769ace2f338794c914a96fc335df0f", GitTreeState:"clean", BuildDate:"2020-06-26T03:47:41Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.5", GitCommit:"e6503f8d8f769ace2f338794c914a96fc335df0f", GitTreeState:"clean", BuildDate:"2020-06-26T03:39:24Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
+++ exited with 0 +++
myo@master-node:~$ kubectl cluster-info
Kubernetes master is running at https://192.168.1.132:6443
KubeDNS is running at https://192.168.1.132:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
myo@master-node:~$
For second issue was with localhost:8080 was refused.
If you received the following error, "The connection to the server localhost:8080 was refused - did you specify the right host or port?"
Try the following command.
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Comments
Post a Comment