Kubernetes - How to edit CoreDNS corefile configmap?
It looks like your Corefile got somehow corrupted during editing through "kubectl edit ..." command. Probably it's fault of your default text editor, but it's definitely valid.
I would recommend you to replace your current config map with the following command:
kubectl get -n kube-system cm/coredns --export -o yaml | kubectl replace -n kube-system -f coredns_cm.yaml
#coredns_cm.yamlapiVersion: v1data: Corefile: | cluster.local:53 { log 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 loop reload loadbalance }kind: ConfigMapmetadata: creationTimestamp: null name: coredns
$ kubectl -n kube-system edit configmaps coredns -o yaml
Then use vi
to edit and save the coredns
configmap. Once it is saved the change will be applied.
kubectl get -n kube-system configmaps coredns -o yaml > core_dns.yamlkubectl replace -n kube-system -f core_dns.yaml