动物园管理员和kubernetes的无头服务

时间:2017-12-05 12:01:19

标签: kubernetes apache-zookeeper

在kubernetes中,我部署了一个名为zookeeper的状态集:

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: zookeeper
spec:
  serviceName: zookeeper-svc
  replicas: 1
  template:
    metadata:
      labels:
        app: zookeeper

和无头服务:

apiVersion: v1
kind: Service
metadata:
  name: zookeeper-svc
  labels:
    app: zookeeper    
spec:
  clusterIP: None
  ports:
  - port: 2888
    name: server
  - port: 3888
    name: leader-election

进入我的zookeeper-0 pod我可以看到它的IP:

zookeeper@zookeeper-0:/usr/bin$ cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.32.0.11      zookeeper-0.zookeeper-svc.default.svc.cluster.local     zookeeper-0

但寻找IP

kb exec dnsutils nslookup zookeeper-0
服务器:10.96.0.10 地址:10.96.0.10#53

**服务器找不到zookeeper-0:NXDOMAIN

我看不到它。

我哪里错了? 任何建议都表示赞赏。

1 个答案:

答案 0 :(得分:1)

您是否尝试过访问zookeeper-0.zookeeper-svc服务名称未添加到/etc/resolv.conf中的搜索域列表中,因此您需要在名称中添加名称空间名称前面的所有内容。