DNS name resolution not happening in kubernetes

2/17/2020

We set-up the kubernetes cluster with 3 nodes. One as master and two are slaves. And installed zookeeper and active mq in the master node. When we see the logs after deploying our application it showing http://foo.bar.com:2181(active(http://foo.bar.com:2181(active) mq DNS name) can't access or reach. If we change that activemq domain name to IP address in a properties file, it works fine.

I think name resolution is not happening in kubernetes, can you help how can i get this work automatically? because i cant change the property file always when there is new deployment.

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: {}
-- kumar
kubernetes
kubernetes-ingress
kubernetes-networkpolicy
kubernetes-pod

0 Answers