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-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