Skip to content

Unable to access kubernetes services: no route to host #6139

Closed

Description

@weikinhuang

I am able to reach individual pods just fine regardless if they are on the same machine or not. I am just having issues with the kubernetes Service setup. I have tried ClusterIP, NodePort, and LoadBalancer.

Rancher Version:
v1.1.4 (docker rancher/server:latest)

Docker Version:
v1.12.1

OS and where are the hosts located? (cloud, bare metal, etc):
centos 7 vm x2 local

Setup Details: (single node rancher vs. HA rancher, internal DB vs. external DB)
docker setup following getting started http://docs.rancher.com/rancher/v1.2/en/quick-start-guide/

Environment Type: (Cattle/Kubernetes/Swarm/Mesos)
Kubernetes

Steps to Reproduce:
following the guide in http://kubernetes.io/docs/user-guide/connecting-applications/

# ng.yaml

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: my-nginx
spec:
  replicas: 2
  template:
    metadata:
      labels:
        run: my-nginx
    spec:
      containers:
      - name: my-nginx
        image: nginx
        ports:
        - containerPort: 80

---

apiVersion: v1
kind: Service
metadata:
  name: my-nginx
  labels:
    run: my-nginx
spec:
  ports:
  - port: 80
    protocol: TCP
  selector:
    run: my-nginx

kubectl apply -f ng.yaml

Then separately run:

kubectl run -i -t test --image=centos:latest --restart=Never

Results:

$ kubectl get pods -l run=my-nginx -o wide
NAME                        READY     STATUS    RESTARTS   AGE       IP              NODE
my-nginx-2160135165-loy4p   1/1       Running   0          15m       10.42.154.145   rancher04
my-nginx-2160135165-qkhxg   1/1       Running   0          15m       10.42.77.3      rancher06
$ kubectl get svc my-nginx
NAME       CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
my-nginx   10.43.20.3   <none>        80/TCP    53s
$ kubectl describe svc my-nginx
Name:           my-nginx
Namespace:          nx
Labels:         run=my-nginx
Selector:           run=my-nginx
Type:           ClusterIP
IP:             10.43.20.3
Port:           <unset> 80/TCP
Endpoints:          10.42.154.145:80,10.42.77.3:80
Session Affinity:       None
$ kubectl get ep my-nginx
NAME       ENDPOINTS                        AGE
my-nginx   10.42.154.145:80,10.42.77.3:80   1m

In the test container

$ yum install nc nslookup bind-utils
$ nslookup my-nginx
Server:     169.254.169.250
Address:        169.254.169.250#53

Name:   my-nginx.nx.svc.cluster.local
Address: 10.43.20.3

The issue, cURLing the cluster ip results in no route to host:

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

$ curl my-nginx.nx.svc.cluster.local
curl: (7) Failed connect to my-nginx.nx.svc.cluster.local:80; No route to host

What works, curling directly to the pods:

$ curl 10.42.154.145
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em; ...

Expected:

Expect to be able to curl the cluster ip defined in the kubernetes service

Activity

  1. weikinhuang commented on Oct 5, 2016

    @weikinhuang
    Author

    Flushed all my firewalls with iptables --flush and iptables -tnat --flush then restart docker fixed it

  2. StephenLau007 commented on Jan 5, 2018

    @StephenLau007

    I also meet this problem,after I kudeadm join token,that slave node can't work pod,because I forgot disable firewalld.I use there are command each node,so that pod can work successful.
    systemctl stop firewalld
    systemctl disable firewalld

  3. eskuai commented on Feb 25, 2019

    @eskuai

    Same problem using cni waeve
    disabled firewalld and iptables
    any clues?

  4. async-dna commented on Apr 25, 2019

    @async-dna

    saw a similar symptom, and determined it was only the master node that couldn't connect to the "borken" service. restarting the master node fixed it. ¯_(ツ)_/¯

  5. adiii717 commented on Dec 5, 2019

    @adiii717

    in my case I just the minikube

    minikube start
    
  6. jepsenwan commented on Apr 7, 2021

    @jepsenwan

    Gathered all resolutions that might help in case one of them is not working:

    #kubelet & runtime
    systemctl stop kubelet
    systemctl stop docker / crio
    iptables --flush
    iptables -tnat --flush
    systemctl start kubelet
    systemctl start docker / crio

    #coredns deployment
    kubectl rollout restart deployment coredns --namespace

    #proxy
    kubectl delete pod -n kube-system kube-proxy-xxx-xxx

    #firewalld
    systemctl stop firewalld
    systemctl disable firewalld

  7. novakov-alexey commented on Dec 30, 2022

    @novakov-alexey

    I restarted my rancher desktop as well as updated to latest version and this issue got resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions