CoreDNS service Corefile location

6/22/2020

I would like to view the configuration file of CoreDNS service.

When i look in to the coredns deployment file it is shown as

  spec:
  containers:
  - args:
    - -conf
    - /etc/coredns/Corefile
    image: k8s.gcr.io/coredns:1.6.7
    imagePullPolicy: IfNotPresent
  • Is the /etc/coredns/Corefile inside the container
  • If yes,How to view it.. i am unable to get in to the coredns container
  • If i change the coredns config map file, will the /etc/coredns/Corefile also change

Coredns pods

Unable to get in to coredns pod

-- Sivakumarj
coredns
dns
kubernetes

1 Answer

6/22/2020

Basically Corefile is included in coredns which is a kind of ConfigMap in Kubernetes. 1. To view it you have to check ConfigMap resourse.

kubectl get ConfigMap coredns -n kube-system -o yaml

2.If you change coredns ConfigMap data Corefile then /etc/cordns/Corefile will be changed also.you can check this document.

apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns
  namespace: kube-system
data:
  Corefile: |
    .:53 {
        errors
        health {
            lameduck 5s
        }
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
            pods insecure
            fallthrough in-addr.arpa ip6.arpa
            ttl 30
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }
-- Taybur Rahaman
Source: StackOverflow