curl unable to access kubernetes services - error: no route to host

5/25/2020

For some reason I'm unable to curl my service or pod exposing the service. Below setup used to work - not anymore.

$ kubectl create deployment nginx --image=nginx
$ kubectl expose deployment nginx --port=80

$ kubectl get svc,pods -o wide
NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE    SELECTOR
service/nginx        ClusterIP   10.109.212.238   <none>        80/TCP    12m    app=nginx

NAME                            READY   STATUS    RESTARTS   AGE   IP          NODE               NOMINATED NODE   READINESS GATES
pod/nginx-866795cfb8-ff5zv      1/1     Running   0          13m   10.47.0.2   nebula-web01       <none>           <none>

Getting application content from Service IP or Pod IP results with this error.

$ curl 10.109.212.238
curl: (7) Failed connect to 10.109.212.238:80; No route to host

$ curl 10.47.0.2 
curl: (7) Failed connect to 10.47.0.2:80; No route to host
-- Lukasz Dynowski
kubernetes

1 Answer

5/25/2020

Funny enough I discovered that the error appeared only on nebula-web01 node. If I deployed the same application on different node e.g. nebula-web02 and curl Service IP or Pod IP then the application returned its content. This made me think that there has to be something wrong with nebula-web01 setup.

What fixed my problem was to restarting docker and kubelet daemon on nebula-web01 node.

$ systemctl restart docker
$ systemctl restart kubelet

Notes

Additonaly, you might disable firewall and flush iptables according to this instructions.

-- Lukasz Dynowski
Source: StackOverflow