How do I change the external DNS not kubernetes(CoreDNS)?

975 Views Asked by At

My pods can't find the URL https://nfe.sefaz.go.gov.br/nfe/services/NFeAutorizacao4.

I did a test and added the DNS 8.8.8.8 and 8.8.4.4 in the /etc/resolve.conf file of one of the pods, and the URL is found.

The file /etc/resolve.conf looks like this

search default.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.245.0.10
nameserver 8.8.8.8
nameserver 8.8.4.4
options ndots:5

My question is:

Is there a correct way to correct the cluster DNS and leave it in an automated way?

We use CoreDNS, Corefile:

.:53 {
    errors
    health
    ready
    kubernetes cluster.local in-addr.arpa ip6.arpa {
      pods insecure
      fallthrough in-addr.arpa ip6.arpa
    }
    prometheus :9153
    forward . /etc/resolv.conf
    cache 30
    loop
    reload
    loadbalance
    import custom/*.override
}
import custom/*.server
1

There are 1 best solutions below

0
Guilherme On

I solved that by creating the ConfigMap 'coredns-custom', which is the coredns default

It looks like this:

apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns-custom
  namespace: kube-system
data:
  custom.server: |
    specific-domain:53 {
      log
      forward . 8.8.8.8 8.8.4.4
    }

replace 'specific-domain' with some specific domain or '*'.