Solution | Benefits |
This solution is simple and intuitive. You can add arbitrary resolution records. | |
You do not need to know the IP address of a resolution record in advance, but the IP address mapped by the resolution record must be deployed in the cluster. | |
You can manage a large number of resolution records. As all records are managed in the external DNS, you do not need to modify the CoreDNS configuration when adding or deleting records. |
configmap
of CoreDNS
, as shown below:kubectl edit configmap coredns -n kube-system
hosts
configuration by adding the relevant domain names, as shown below:hosts {192.168.1.6 harbor.example.com192.168.1.8 es.example.comfallthrough}
harbor.example.com
to 192.168.1.6 and es.example.com
to 192.168.1.8.apiVersion: v1data:Corefile: |2-.:53 {errorshealthkubernetes cluster.local. in-addr.arpa ip6.arpa {pods insecureupstreamfallthrough in-addr.arpa ip6.arpa}hosts {192.168.1.6 harbor.example.com192.168.1.8 es.example.comfallthrough}prometheus :9153forward . /etc/resolv.confcache 30reloadloadbalance}kind: ConfigMapmetadata:labels:addonmanager.kubernetes.io/mode: EnsureExistsname: corednsnamespace: kube-system
configmap
of CoreDNS
, as shown below:kubectl edit configmap coredns -n kube-system
rewrite name es.example.com es.logging.svc.cluster.local
es.example.com
domain name to the es
service deployed in the logging
namespace. Separate multiple domain names with carriage returns.apiVersion: v1data:Corefile: |2-.:53 {errorshealthkubernetes cluster.local. in-addr.arpa ip6.arpa {pods insecureupstreamfallthrough in-addr.arpa ip6.arpa}rewrite name es.example.com es.logging.svc.cluster.localprometheus :9153forward . /etc/resolv.confcache 30reloadloadbalance}kind: ConfigMapmetadata:labels:addonmanager.kubernetes.io/mode: EnsureExistsname: corednsnamespace: kube-system
forward
configuration. The default configuration of forward
is as follows, which means that the domain name that is not in the cluster is resolved by the nameserver
configured in the /etc/resolv.conf
file of the node where CoreDNS is located.forward . /etc/resolv.conf
forward
by replacing /etc/resolv.conf
explicitly with the IP address of the external DNS server, as shown below:forward . 10.10.10.10
apiVersion: v1data:Corefile: |2-.:53 {errorshealthkubernetes cluster.local. in-addr.arpa ip6.arpa {pods insecureupstreamfallthrough in-addr.arpa ip6.arpa}prometheus :9153forward . 10.10.10.10cache 30reloadloadbalance}kind: ConfigMapmetadata:labels:addonmanager.kubernetes.io/mode: EnsureExistsname: corednsnamespace: kube-system
/etc/resolv.conf
on the node as the upstream of the external DNS. If it is not set as the upstream of the external DNS, some services may not work properly because the services rely on internal DNS resolution of Tencent Cloud. This document takes BIND 9 as an example to modify the configuration file and write the upstream DNS address into forwarders
, as shown below:options {forwarders {183.60.83.19;183.60.82.98;};...
Was this page helpful?