How to add custom Domain Name System records in Tanzu Kubernetes Grid clusters
search cancel

How to add custom Domain Name System records in Tanzu Kubernetes Grid clusters

book

Article ID: 337404

calendar_today

Updated On:

Products

VMware

Issue/Introduction

This article covers how to test out which DNS record which has not been injected in the external name server and how to reach some custom host from inside a pod.

Symptoms:
You are not able to reach to the custom host from inside a pod in a cluster in Tanzu Kubernetes Grid (TKG).

Environment

VMware Tanzu Kubernetes Grid 1.x

Cause

You keep hitting custom hosts, from inside a pod in your cluster but the custom host is not reachable. As a result, if you need to reach some custom host from inside a pod, you are unable to.

Resolution

There is no resolution. However, there is a workaround available.

Workaround:
To work around this issue, follow these steps: 

1. You need to edit the ConfigMap of the coredns using the following command:

kubectl -n kube-system edit configmap/coredns


2. Add a section called hosts where you define the address you want to use for yourcustom.host in the example and point it to the IP address you need 1.2.3.4  in the example below.

For example, your ConfigMap should look like this:

data: 
  Corefile: |
      .:53 {
          errors
          health
          ready
          kubernetes cluster.local in-addr.arpa ip6.arpa {
            pods insecure
            fallthrough in-addr.arpa ip6.arpa
          }
          prometheus :9153
          forward . 8.8.8.8 8.8.4.4
          cache 30
          loop
          reload
          loadbalance
          hosts {
            1.2.3.4 yourcustom.host
            fallthrough
          }
       }

 

3. Restart the core-DNS pod and wait for the new one to come up: 

kubectl -n kube-system rollout restart deployment coredns

4. Go to the custom host from inside any pod on the cluster and verify DNS resolution with this command:

kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools

Additional Information

For more information on hosts, refer to the following CoreDNS documentation: Hosts