Search code examples
kubernetescoredns

how to see upstream server of coredns in kubernetes 1.10+?


I have the following configmap

kubectl get configmap coredns --namespace kube-system -o yaml
apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           upstream
           fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        proxy . /etc/resolv.conf
        cache 30
        reload
    }
kind: ConfigMap
metadata:
  creationTimestamp: 2018-06-29T03:48:35Z
  name: coredns
  namespace: kube-system
  resourceVersion: "222"
  selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
  uid: 4c8c3b17-7b4f-11e8-aaa1-0cc47a453e30

But I don't see where it's getting it's upstream dns server from. I originally deployed this k8s cluster with kube-dns, but updated to coredns when 1.11 came out. My upstream server was set as 192.168.1.18, but I need to change that now. I've checked in each host's /etc/resolv.conf, 192.168.1.18 isn't listed there, and from this configmap, I don't see it either...yet if I stop DNS on 192.168.1.18, pods stop resolving externally. Where is this IP address stored?


Solution

  • So it seems that local dns was set to coredns

    /etc/resolv.conf
    nameserver 127.0.0.53
    

    if i look at the service for dns listening on 53, I get this

    kubectl describe svc kube-dns --namespace kube-system
    Name:              kube-dns
    Namespace:         kube-system
    Labels:            k8s-app=kube-dns
                       kubernetes.io/cluster-service=true
                       kubernetes.io/name=KubeDNS
    Annotations:       prometheus.io/scrape=true
    Selector:          k8s-app=kube-dns
    Type:              ClusterIP
    IP:                10.96.0.10
    Port:              dns  53/UDP
    TargetPort:        53/UDP
    Endpoints:         10.32.0.12:53,10.32.0.14:53
    

    which correlates to the coredns pods..which when entered...contains the ip address

    kubectl exec -it --namespace kube-system coredns-78fcdf6894-l4tph -- sh
    / # cd /etc
    /etc # ls
    TZ                    fstab                 logrotate.d           os-release            services
    alpine-release        group                 modprobe.d            passwd                shadow
    apk                   hostname              modules               periodic              shells
    ca-certificates       hosts                 modules-load.d        profile               ssl
    ca-certificates.conf  init.d                motd                  profile.d             sysctl.conf
    conf.d                inittab               mtab                  protocols             sysctl.d
    coredns               issue                 network               resolv.conf           udhcpd.conf
    crontabs              localtime             opt                   securetty
    /etc # cat resolv.conf
    nameserver 192.168.1.18
    search home
    

    ugh. what a PITA