Search code examples
kubernetesdnscloudflarenameserverscoredns

How to use Cloudflare 1.1.1.1 with Kubernetes DNS


I'd like to use Cloudflare's 1.1.1.1 and 1.0.0.1 nameservers in Kubernetes, alongside DNS over TLS. It looks like I can do it using core-dns. I need to setup the following somehow:

  • IPv4: 1.1.1.1 and 1.0.0.1
  • IPv6: 2606:4700:4700::1111 and 2606:4700:4700::1001
  • TLS Server Name: tls.cloudflare-dns.com

What should my ConfigMap look like? I've started it below:

apiVersion: v1
kind: ConfigMap
data:
  upstreamNameservers: |
    ["1.1.1.1", "1.0.0.1"]

Solution

  • You can configure your core-dns kubectl -n kube-system edit configmap coredns and add to end of corefile:

    . {
        forward . tls://1.1.1.1 tls://1.0.0.1 {
           tls_servername cloudflare-dns.com
           health_check 5s
        }
        cache 30
    }
    

    and than save new configuration and restart core-dns pods.

    kubectl get pod -n kube-system | grep core-dns | cut -d " " -f1 - | xargs -n1 -P 10 kubectl delete pod -n kube-system