Repository navigation
Description
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-nginxkubectl 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
weikinhuang commentedon Oct 5, 2016
Flushed all my firewalls with
iptables --flushandiptables -tnat --flushthen restart docker fixed itStephenLau007 commentedon Jan 5, 2018
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 firewalldsystemctl disable firewalldeskuai commentedon Feb 25, 2019
Same problem using cni waeve
disabled firewalld and iptables
any clues?
async-dna commentedon Apr 25, 2019
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. ¯_(ツ)_/¯
adiii717 commentedon Dec 5, 2019
in my case I just the minikube
jepsenwan commentedon Apr 7, 2021
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
novakov-alexey commentedon Dec 30, 2022
I restarted my rancher desktop as well as updated to latest version and this issue got resolved.