Moritz Becker
Moritz Becker

Reputation: 107

Cannot access Kubernetes multi-container pod via clusterIP

I am using Kubernetes v1.2.2 on docker-machine and I want to connect to a multi-container pod from another ordinary single-container pod running on the same node.

Each pod has a service providing a clusterIP. I can access the single-container pod (postgres-service) from the multi-container pod (postgres-bw-service) via the clusterIP of the corresponding service but not vice-versa. I checked the kube-proxy logs and noticed that no service endpoints are set for the service of my multi-container pod:

I0408 16:20:06.693273       1 iptables.go:177] Could not connect to D-Bus system bus: dial unix /var/run/dbus/system_bus_socket: no such file or directory
E0408 16:20:06.703401       1 server.go:340] Can't get Node "default", assuming iptables proxy: Get http://127.0.0.1:8080/api/v1/nodes/default: dial tcp 127.0.0.1:8080: connection refused
I0408 16:20:06.711666       1 server.go:200] Using iptables Proxier.
I0408 16:20:06.712420       1 server.go:213] Tearing down userspace rules.
I0408 16:20:06.822631       1 conntrack.go:36] Setting nf_conntrack_max to 262144
I0408 16:20:06.822833       1 conntrack.go:41] Setting conntrack hashsize to 65536
I0408 16:20:06.823646       1 conntrack.go:46] Setting nf_conntrack_tcp_timeout_established to 86400
E0408 16:20:06.826470       1 event.go:202] Unable to write event: 'Post http://127.0.0.1:8080/api/v1/namespaces/default/events: dial tcp 127.0.0.1:8080: connection refused' (may retry after sleeping)
E0408 16:20:08.627546       1 event.go:202] Unable to write event: 'Post http://127.0.0.1:8080/api/v1/namespaces/default/events: dial tcp 127.0.0.1:8080: connection refused' (may retry after sleeping)
E0408 16:20:18.629129       1 event.go:202] Unable to write event: 'Post http://127.0.0.1:8080/api/v1/namespaces/default/events: dial tcp 127.0.0.1:8080: connection refused' (may retry after sleeping)
I0408 16:20:20.925349       1 proxier.go:484] Setting endpoints for "default/kubernetes:https" to [10.0.2.15:6443]
I0408 16:20:20.925592       1 proxier.go:484] Setting endpoints for "default/postgres-service:postgres-tcp" to [172.17.0.3:5432]
I0408 16:20:20.925841       1 proxier.go:565] Not syncing iptables until Services and Endpoints have been received from master
I0408 16:20:20.931213       1 proxier.go:421] Adding new service "default/kubernetes:https" at 10.0.0.1:443/TCP
I0408 16:20:20.931901       1 proxier.go:421] Adding new service "default/postgres-bw-service:postgres" at 10.0.0.139:5432/TCP
I0408 16:20:20.932084       1 proxier.go:421] Adding new service "default/postgres-bw-service:kafka" at 10.0.0.139:9092/TCP
I0408 16:20:20.932203       1 proxier.go:421] Adding new service "default/postgres-bw-service:zookeeper" at 10.0.0.139:2181/TCP
I0408 16:20:20.932331       1 proxier.go:421] Adding new service "default/postgres-service:postgres-tcp" at 10.0.0.241:5432/TCP
I0408 16:20:22.860305       1 proxier.go:494] Removing endpoints for "default/postgres-service:postgres-tcp"
I0408 16:20:26.582664       1 proxier.go:484] Setting endpoints for "default/postgres-service:postgres-tcp" to [172.17.0.2:5432]

Note the log entry Setting endpoints for "default/postgres-service:postgres-tcp" to [172.17.0.2:5432] but there is no similar entry for the postgres-bw-service. I assume that this is the reason why I cannot access the multi-container pod but I do not no what is causing this.

One more strange thing: I cannot access a pod via the clusterIP of its own service, this works neither for the multi-container pod nor for the single-container pod.

Any help appreciated

EDIT

kubectl get ep gives me

kubectl get ep postgres-service
NAME               ENDPOINTS         AGE
postgres-service   172.17.0.2:5432   17h

kubectl get ep postgres-bw-service
NAME               ENDPOINTS         AGE
postgres-bw-service   <none>      17h

Upvotes: 0

Views: 944

Answers (1)

Moritz Becker
Moritz Becker

Reputation: 107

The issue was that the app labels of my pod did not match the app selector in my service definition.

Upvotes: 1

Related Questions