I have configured Kubernetes using kubeadm in cent os stream 9. When I issue kubectl commands i am getting this error often
The connection to the server xx.xxx.xx.xx:6443 was refused - did you specify the right host or port?
I have used Flannel as CNI.
I have tried the swapoff -a
command. And done export KUBECONFIG=/etc/kubernetes/admin.conf
Restarting kubelet works sometimes but again gets the same error.
kube-api-server logs shows as follows,
2023-05-22T14:26:09.871029029+05:30 stderr F W0522 08:56:09.870881 1 storage_scheduling.go:106] unable to get PriorityClass system-node-critical: Get "https://[::1]:6443/apis/scheduling.k8s.io/v1/priorityclasses/system-node-critical": dial tcp [::1]:6443: connect: connection refused. Retrying...
2023-05-22T14:26:09.8710991+05:30 stderr F E0522 08:56:09.870905 1 storage_rbac.go:187] unable to initialize clusterroles: Get "https://[::1]:6443/apis/rbac.authorization.k8s.io/v1/clusterroles": dial tcp [::1]:6443: connect: connection refused
2023-05-22T14:26:09.871143932+05:30 stderr F W0522 08:56:09.871088 1 storage_scheduling.go:106] unable to get PriorityClass system-node-critical: Get "https://[::1]:6443/apis/scheduling.k8s.io/v1/priorityclasses/system-node-critical": dial tcp [::1]:6443: connect: connection refused. Retrying...
2023-05-22T14:26:09.871221589+05:30 stderr F F0522 08:56:09.871144 1 hooks.go:203] PostStartHook "scheduling/bootstrap-system-priority-classes" failed: unable to add default system priority classes: timed out waiting for the condition
Please provide a solution. I have tried out most of the solutions from Google