简体   繁体   English

DNS无法使用Kubernetes PetSet

[英]DNS not working with Kubernetes PetSet

Ok, following the examples and documentation on the Kubernetes website along with extensive research on Google, I still cannot get DNS resolution between the containers within my Pod. 好的,按照Kubernetes网站上的示例和文档以及对Google的广泛研究,我仍然无法在我的Pod中的容器之间获得DNS解析。

I have a Service and a PetSet with 2 containers defined. 我有一个服务和一个定义了2个容器的PetSet。 When I deploy the PetSet and Service, they start and run successfully, but if I attempt to ping the host of one of my containers from the other by hostname or by the full domain name I get destination unreachable. 当我部署PetSet和Service时,它们会成功启动并运行,但是如果我尝试通过主机名或完整域名从另一个容器中ping我的一个容器的主机,那么我将无法访问目标。 I can ping by IP address though. 我可以通过IP地址ping。

Here is my Kubernetes configuration file: 这是我的Kubernetes配置文件:

apiVersion: v1
kind: Service
metadata:
  name: ml-service
  labels:
    app: marklogic
  annotations:
    service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
  #restartPolicy: OnFailure
  clusterIP: None
  selector:
    app: marklogic
  ports:
    - protocol: TCP
      port: 7997
      #nodePort: 31997
      name: ml7997
    - protocol: TCP
      port: 8000
      #nodePort: 32000
      name: ml8000
    # ... More ports defined
  #type: NodePort

---
apiVersion: apps/v1alpha1
kind: PetSet
metadata:
  name: marklogic
spec:
  serviceName: "ml-service"
  replicas: 2
  template:
    metadata:
      labels:
        app: marklogic
      annotations:
        pod.alpha.kubernetes.io/initialized: "true"
    spec:
      terminationGracePeriodSeconds: 30
      containers:
        - name: 'marklogic'
          image: "{local docker registry ip}:5000/dcgs-sof/ml8-docker-final:v1"
          imagePullPolicy: Always
          command: ["/opt/entry-point.sh", "-l", "/opt/mlconfig.sh"]
          ports:
            - containerPort: 7997
              name: ml7997
            - containerPort: 8000
              name: ml8000
            - containerPort: 8001
              name: ml8001
            - containerPort: 8002
              name: ml8002
            - containerPort: 8040
              name: ml8040
            - containerPort: 8041
              name: ml8041
            - containerPort: 8042
              name: ml8042
            - containerPort: 8050
              name: ml8050
            - containerPort: 8051
              name: ml8051
            - containerPort: 8060
              name: ml8060
          env:
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
          lifecycle:
            preStop:
              exec:
                command: ["/etc/init.d/MarkLogic stop"]
          volumeMounts:
            - name: ml-data
              mountPath: /data
  volumeClaimTemplates:
    - metadata:
        name: ml-data
        annotations:
          volume.alpha.kubernetes.io/storage-class: anything
      spec:
        accessModes: [ "ReadWriteOnce" ]
        resources:
          requests:
            storage: 1Gi

I commented out the type: NodePort definition as I thought that might be the culprit, but still no success. 我注释掉了type: NodePort定义,因为我认为这可能是罪魁祸首,但仍然没有成功。

Additionally, if I run docker@minikube:/$ docker exec b4d21c4bc065 /bin/bash -c 'nslookup marklogic-1.marklogic.default.svc.cluster.local' it cannot resolve the name. 另外,如果我运行docker@minikube:/$ docker exec b4d21c4bc065 /bin/bash -c 'nslookup marklogic-1.marklogic.default.svc.cluster.local'它无法解析名称。

What am I missing??? 我错过了什么?

You are resolving the wrong domain name. 您正在解析错误的域名。 See http://kubernetes.io/docs/user-guide/petset/#network-identity http://kubernetes.io/docs/user-guide/petset/#network-identity

You should try to resolve: 你应该尝试解决:

marklogic-0.ml-service.default.svc.cluster.local marklogic-0.ml-service.default.svc.cluster.local

If everything is within the default namespace, the DNS name is: 如果所有内容都在默认命名空间内,则DNS名称为:

<pod_name>.<svc_name>.default.svc.cluster.local

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM