first of all I would like to say that I am a beginner in the kubernetes-topic and I have the problem that I couldn't reach a pod (via a service) when I give the service a fixed IP so I would like to summary the things I think I had understand and maybe someone here can correct me or aknowledge my way to resolve my problem.
I deploy my cluster with the ansible-script kubespray on baremetal (2 Nodes with CentOS 7) and I configure the script and resulting cluster as follow:
and after the deployment was successfully I can deploy pods, services, secrets etc. to the cluster so it seems for me it works fine, but when I now to define an external IP i.e. like this:
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- port: 80
selector:
name: nginx
externalIPs:
- "192.168.1.42"
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
name: nginx
spec:
containers:
- name: gluster-pod1
image: gcr.io/google_containers/nginx-slim:0.8
ports:
- name: web
containerPort: 80
I can reach the pod by his internal IP, by the IP of the endpoint and by the IP of the master but not by the IP I define for this service, when I try this I get by curl the error: "no route to host" the strange this for me is when I set the IP for the service as the same IP as the kubernetes master i.e.
...
spec:
ports:
- port: 80
selector:
name: nginx
externalIPs:
- "192.168.1.1"
I can reach the pod.
Now after I read a lot of documentation and howto's the problem is resolveable when I configure my own load balancer for the management of external IPs because if I didn't define an fixed IP the service waiting with the status "pending" for an external IP.
But unfortunately after all the reading of the documentation I am not sure if the architecture really works this way I mean pod <-> service <-> load-balancer (<-> DHCP)
so I can reach the pod via the service.
As I started I would like to close this post I am not sure this is the right direction to resolve my problem. That's why I would very grateful if someone can confirm me or correct me :-) best regards Dan