By Boli
A set of DNS services is deployed in the Kubernetes clusters and exposed because of the kube-dns service name. Run the following command to check the kube-dns service details:
kubectl get SVC kube-dns -n kube-system
The output results:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns ClusterIP 172.24.0.10 <none> 53/UDP,53/TCP,9153/TCP 27d
The service backend contains two Pods named coredns. The resolution principle of CoreDNS will be explained later. Run the following command to check the Pod details:
kubectl get deployment coredns -n kube- system
The output results:
NAME READY UP-TO-DATE AVAILABLE AGE
coredns 2/2 2 2 27d
The kubelet on Kubernetes cluster nodes contains, --cluster-dns=${dns-service-ip}
and --cluster-domain=${default-local-domain}
. These two DNS-related parameters are used to set the IP address and primary domain suffix of the cluster DNS server.
Check the DNS configuration file, /etc/resolv.conf
, of the Pod in dnsPolicy:ClusterFirst
mode under the default cluster namespace. The dnsPolicy will be introduced later:
nameserver 172.24.0.10
search default.svc.cluster.local SVC.cluster.local cluster.local
options ndots :5
Parameter descriptions:
default.svc.cluster.local
, svc.cluster.local
, and cluster.local
. A maximum of eight queries, four each for IPV4 and IPV6, is performed to obtain the correct resolution result.According to the above file configuration, try to resolve it in the Pod:
kubernetes.default.svc.cluster.local
. One IPV4 domain name resolution request is sent to 172.24.0.10 for resolution.kube-dns.kue-system.default.svc.cluster.local.
and kube-dns.kue-system.svc.cluster.local
. Two IPV4 domain name resolution requests are sent to 172.24.0.10 for the correct resolution result.aliyun.com.default.svc.cluster.local.
, aliyun.com.svc.cluster.local.
, aliyun.com.cluster.local.
, and aliyun.com. Four IPV4 domain name resolution requests are sent to 172.24.0.10 for the correct resolution result.In the Kubernetes cluster, it’s supported to configure different DNS policies for each Pod through the dnsPolicy field. Four policies are currently available:
/etc/resolv.conf file
is the kube-DNS address of the cluster DNS service. This is the default DNS policy for cluster workloads./etc/resolv.conf
file is directly used of nodes in the cluster.CoreDNS is a standard service discovery component of Kubernetes.
In the kube-system namespace, the cluster has a configmap named coredns. The file configuration information of its Conrefile filed is listed below. CoreDNS provides services based on the Corefile plug-ins.
Corefile: |
.:53 {
errors
health {
lameduck 5s
}
ready
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus :9153
forward . /etc/resolv.conf
cache 30
loop
reload
loadbalance
}
Plug-in descriptions:
http://localhost:8080/health
to view the report.http://localhost:8181/ready
to view the readability. When all plug-ins are in the running state, the ready status is 200.http://localhost:9153/metrics
to view the monitoring data in prometheus format.(/etc/resolv.conf)
. The default configuration is using the /etc/resolv.conf
file on the host.Setting a Whitelist to Specified Pod Segments in Terway for ACK
169 posts | 30 followers
FollowAlibaba Developer - October 13, 2020
Alibaba Container Service - March 12, 2021
Alibaba Container Service - August 22, 2018
Alibaba Cloud Native Community - July 13, 2022
Xi Ning Wang(王夕宁) - December 16, 2020
Alibaba Clouder - September 21, 2018
169 posts | 30 followers
FollowAlibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.
Learn MoreHigh Performance Computing (HPC) and AI technology helps scientific research institutions to perform viral gene sequencing, conduct new drug research and development, and shorten the research and development cycle.
Learn MoreDeploy custom Alibaba Cloud solutions for business-critical scenarios with Quick Start templates.
Learn MoreElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreMore Posts by Alibaba Container Service