Interview Prep/Real-World Interview/Kubernetes cluster-level

Every `kubectl` command fails with "The connection to the server 10.0.1.10:6443 was refused - did you specify the right host or port?"

BeginnerTroubleshootingKubernetes cluster-level
Answer

Likely causes → Either kubectl points at the wrong endpoint (wrong context, stale kubeconfig after the cluster was recreated) or the API server really is down. On self-managed clusters the kube-apiserver static pod may be crash-looping because etcd is down, a certificate expired, or the control-plane disk is full.

Diagnose →

kubectl config current-context
kubectl config view --minify | grep server
nc -vz 10.0.1.10 6443
# on the control-plane node
sudo crictl ps -a | grep -E 'kube-apiserver|etcd'
sudo crictl logs $(sudo crictl ps -a --name kube-apiserver -q | head -1) 2>&1 | tail
df -h /var/lib/etcd

Fix → Switch to the right context (kubectl config use-context prod) or regenerate kubeconfig (aws eks update-kubeconfig --name prod). On kubeadm clusters fix whatever the apiserver logs complain about (etcd, certs, disk); kubelet restarts the static pod automatically.

Prevent → Use a managed control plane where possible, run 3 control-plane nodes, and monitor the API server endpoint with a blackbox probe.

All Real-World Interview questions Roadmap: Interview readiness

More on Kubernetes cluster-level