1

我们设置了 3 个节点的 Kubernetes 集群。一个是主人,两个是奴隶。并在master节点安装了zookeeper和active mq。当我们在部署应用程序后看到日志时,它显示http://foo.bar.com:2181(active mq DNS name) 无法访问或到达。如果我们在属性文件中将 activemq 域名更改为 IP 地址,它就可以正常工作。

我认为 kubernetes 中没有进行名称解析,您能帮我如何自动完成这项工作吗?因为我不能总是在有新部署时更改属性文件。

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.17.0 (0c01409)
  creationTimestamp: null
  labels:
    io.kompose.service:  config-service
  name:  config-service
spec:
  progressDeadlineSeconds: 2146593647
  replicas: 1
  revisionHistoryLimit: 2146593647
  selector:
    matchLabels:
      io.kompose.service: config-service
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service:  config-service
    spec:
      containers:
      - env:
        - name: CONFIG_DIR
          value: /tmp/work/
        - name: audit_file_path
          value: /tmp/work/logs/audit.log
        - name: spring_cloud_zookeeper_connectString
          value: 172.X.X.X:2181
        - name: cross_orgin_hosts
          value: http://172.X.X.X:3056;http://172.X.X.X:3056;http://172.X.X.X:3056
        image: nexus.repo.com:8098/config-service:1.1.0-2198
        imagePullPolicy: Always
        name:  config-service
        ports:
        - containerPort: 8088
          hostPort: 8088
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /tmp/work/
          name:  config-service-claim0
      dnsPolicy: ClusterFirst
      hostNetwork: true
      nodeSelector:
         disktype: node1
      imagePullSecrets:
      - name: regcred
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - hostPath:
          path: /tmp/CONFIG_DIR
          type: ""
        name:  config-service-claim0
status: {}

---

apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.19.0 (f63a961c)
  creationTimestamp: null
  labels:
    io.kompose.service: config-service
  name: config-service
spec:
  ports:
  - name: "8088"
    port: 8088
    targetPort: 8088
  selector:
    io.kompose.service: config-service
status:
  loadBalancer: {}

4

0 回答 0