我在docker-machine上使用Kubernetes v1.2.2,我想从另一个在同一节点上运行的普通单容器pod连接到多容器pod。
每个pod都有一个提供clusterIP的服务。我可以通过相应服务的clusterIP从多容器窗格(postgres-bw-service)访问单容器窗格(postgres-service),但反之亦然。我检查了kube-proxy日志,发现没有为我的多容器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]
请注意日志条目Setting endpoints for "default/postgres-service:postgres-tcp" to [172.17.0.2:5432]
,但postgres-bw-service没有类似的条目。我认为这就是为什么我无法访问多容器盒的原因,但我不知道是什么造成这种情况。
更奇怪的是:我无法通过自己服务的clusterIP访问pod,这既不适用于多容器容器也不适用于单容器容器。
任何帮助表示赞赏
修改
kubectl get ep
给了我
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
答案 0 :(得分:1)
问题是我的广告连播的应用标签与我的服务定义中的应用选择器不匹配。