<p>I am deployed coredns in kubernetes cluster, but the mysql pod(ip:10.244.8.43) in the slave node is not using coredns ip as name server, I login to mysql pods and find the nameserver:</p>

<pre><code>root@apollo-mysql-85fd475fc9-sjfhg:/# cat /etc/resolv.conf 
nameserver 10.96.0.10
search sre.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
</code></pre>

<p>but the coredns (v1.6.7) pod's ip is: <code>10.244.6.34</code>, where is the problem? what should I do to make coredns work to my cluster pods? and this is my pod define :</p>

<pre><code>kind: Deployment
apiVersion: apps/v1
metadata:
  name: apollo-mysql
  namespace: sre
  selfLink: /apis/apps/v1/namespaces/sre/deployments/apollo-mysql
  uid: b7a2f852-894d-4686-816c-21737535dbea
  resourceVersion: '498210'
  generation: 42
  creationTimestamp: '2020-05-30T11:27:09Z'
  annotations:
    deployment.kubernetes.io/revision: '4'
    kubectl.kubernetes.io/last-applied-configuration: &gt;
      {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"name":"apollo-mysql","namespace":"sre"},"spec":{"selector":{"matchLabels":{"app":"apollo-mysql"}},"strategy":{"type":"Recreate"},"template":{"metadata":{"labels":{"app":"apollo-mysql"}},"spec":{"containers":[{"env":[{"name":"MYSQL_ROOT_PASSWORD","value":"gl4LucnXwLeLwAd29QqJn4"}],"image":"mysql:5.7","name":"mysql","ports":[{"containerPort":3306,"name":"mysql"}],"volumeMounts":[{"mountPath":"/var/lib/mysql","name":"apollo-mysql-persistent-storage"}]}],"volumes":[{"name":"apollo-mysql-persistent-storage","persistentVolumeClaim":{"claimName":"apollo-mysql-pv-claim"}}]}}}}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: apollo-mysql
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: apollo-mysql
    spec:
      volumes:
        - name: apollo-mysql-persistent-storage
          persistentVolumeClaim:
            claimName: apollo-mysql-pv-claim
      containers:
        - name: mysql
          image: 'mysql:5.7'
          ports:
            - name: mysql
              containerPort: 3306
              protocol: TCP
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: gl4LucnXwLeLwAd29QqJn4
          resources: {}
          volumeMounts:
            - name: apollo-mysql-persistent-storage
              mountPath: /var/lib/mysql
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: Recreate
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600
status:
  observedGeneration: 42
  replicas: 1
  updatedReplicas: 1
  readyReplicas: 1
  availableReplicas: 1
  conditions:
    - type: Progressing
      status: 'True'
      lastUpdateTime: '2020-05-31T03:34:11Z'
      lastTransitionTime: '2020-05-30T11:38:19Z'
      reason: NewReplicaSetAvailable
      message: ReplicaSet "apollo-mysql-5f5c49c448" has successfully progressed.
    - type: Available
      status: 'True'
      lastUpdateTime: '2020-05-31T08:34:56Z'
      lastTransitionTime: '2020-05-31T08:34:56Z'
      reason: MinimumReplicasAvailable
      message: Deployment has minimum availability.
</code></pre>

Dolphin
<p><code>10.96.0.10</code> is commonly used as the IP for the <code>kube-dns</code> service which is provided by the <code>coredns</code> pods.</p>

<pre><code>$ kubectl describe svc kube-dns -n kube-system
Name:              kube-dns
...
Type:              ClusterIP
IP:                10.96.0.10
Port:              dns  53/UDP
TargetPort:        53/UDP
Endpoints:         192.168.150.144:53,192.168.24.204:53
...
</code></pre>

<p>So I think your coredns is being used. Check the IPs on the core-dns pods to be sure that the IPs line up:</p>

<pre><code>$ kubectl describe pod -n kube-system coredns-....-.... | grep IP
IP:                   192.168.150.144
</code></pre>

<p>Notice in my case the <code>192.168.150.144</code> is the pod IP of a coredns pod and it is listed in the service endpoints.</p>
