mmumshad / kubernetes-the-hard-way

Bootstrap Kubernetes the hard way on Vagrant on Local Machine. No scripts.
Apache License 2.0
4.7k stars 4.54k forks source link

Error proxying kubernetes dashboard #313

Closed kadeksuryam closed 1 year ago

kadeksuryam commented 1 year ago

Hello,

I've successfully provisioned k8s by following this tutorial and have passed the smoke test. However after installing the k8s dashboard (https://github.com/kubernetes/dashboard) and using kubectl proxy. I cannot access the dashboard due to the following error:

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {},
  "status": "Failure",
  "message": "error trying to reach service: dial tcp 10.44.0.6:8443: i/o timeout",
  "reason": "ServiceUnavailable",
  "code": 503
}

Strangely, I am able to access the dashboard when I use the kubectl port-forward command: kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard 8080:443.

Do you have any idea why this is happening?

kadeksuryam commented 1 year ago

Alright, I've resolved this issue.

The issue with the configuration is that the master node cannot reach service/pod IPs. So, I had to add static routing on the master node like this:

# Configure networking so that the master node can reach services and pods.
sudo ip route add ${POD_CIDR} via 192.168.56.2${HOSTNAME: -1}
sudo ip route add ${SERVICE_CIDR}  via 192.168.56.2${HOSTNAME: -1}

Also, I replaced weave-net CNI with kube-router because, strangely, with weave-net, the IP that a pod will get after being scheduled by kube-controller is different (not in range) from its CIDR configuration.