当前位置:网站首页>Explanation of pod DNS configuration & cases of DNS resolution failure
Explanation of pod DNS configuration & cases of DNS resolution failure
2022-06-24 17:20:00 【keke.】
This article will be based on Dockerd Run time to describe the deployment .
Docker Inside the container resolv.conf
( Here is a docker container As an example to describe )
Run a... On the node nginx container.
$ docker run -d nginx:latest da30536de35915abe1214a25e1c6278f95e5c8af157517ddefc5eaa1d3b36d93
Execute in container findmnt.
$ docker exec da30536de35915abe1214a25e1c6278f95e5c8af157517ddefc5eaa1d3b36d93 findmnt ... |-/etc/resolv.conf /dev/vda1[/var/lib/docker/containers/da30536de35915abe1214a25e1c6278f95e5c8af157517ddefc5eaa1d3b36d93/resolv.conf] ext4 rw,noatime |-/etc/hostname /dev/vda1[/var/lib/docker/containers/da30536de35915abe1214a25e1c6278f95e5c8af157517ddefc5eaa1d3b36d93/hostname] ext4 rw,noatime `-/etc/hosts /dev/vda1[/var/lib/docker/containers/da30536de35915abe1214a25e1c6278f95e5c8af157517ddefc5eaa1d3b36d93/hosts] ext4 rw,noatime ...
You can see , Inside the container /etc/resolv.conf Is attached to the host file (/var/lib/docker/containers/da30536de35915abe1214a25e1c6278f95e5c8af157517ddefc5eaa1d3b36d93/resolv.conf).
( Take a closer look at the contents of the document , On the same node /etc/resolv.conf The content is consistent )
stay Docker Container Creation time ,Docker Will be based on /etc/resolv.conf File to generate what the container needs resolv.conf, Generated resolv.conf Be put in container In the configuration directory of (/var/lib/docker/contaienrs/...).
in addition , You can also view a by using the following command Docker Container resolv.conf The real source of .
$ docker inspect da30536de35915abe1214a25e1c6278f95e5c8af157517ddefc5eaa1d3b36d93 -f {{.ResolvConfPath}}Pod Internal resolv.conf
pod Support the following 4 Kind of dnsPolicy:
- "Default": Pod Inherit the domain name resolution configuration from the running node .
- "ClusterFirst": Default configuration , All requests will take priority in the cluster domain ( such as cluster.local) Inquire about , If not, it will be forwarded to the upstream DNS.
- "ClusterFirstWithHostNet": In the hostNetwork Way to run Pod, It should be set explicitly DNS Strategy "ClusterFirstWithHostNet"; Otherwise, the domain name resolution configuration will be inherited from the running node .
- "None": Allow users to give Pod To configure DNS.
When pod After scheduling to the node ,kubelet Will come to pod The configuration is specific resolv.conf Content :
1 kubelet Will first create and run pod Of sandbox, And then get sandbox Of ResolvConfPath(/var/lib/docker/containers/xxxxxxx/resolv.conf), Next , hold dns policy The specific content of this article is written as sandbox Of ResolvConfPath( Write directly over ).
2 kubelet Continue to create the same pod In the other container, And use the same ResolvConfPath( The same pod Of all containers ResolvConfPath The real source on the host is the same ).
therefore , You can see ,pod Internal resolv.conf yes pod It was determined at the time of creation .
DNS Impassable cases
Problem description :
After the customer has created the cluster , Manually changed the on the node /etc/resolv.conf file , take nameserver Configure self built domain name resolution , Lead to in pod Inside (dnsPolicy yes ClusterFirst) The internal domain name cannot be resolved normally .
The root cause of the problem is :
Business pod(dnsPolicy yes ClusterFirst) Will DNS The request is sent to... In the cluster Coredns, Because it is an internal domain name ,Coredns Will forward the request to /etc/resolv.conf(coredns pod Inside resolv.conf), instead of Coredns pod On the node where the instance is located resolv.conf, The customer cannot resolve the internal domain name .
Repair plan :
The reconstruction Coredns pod example .
边栏推荐
- Introduction to koa (II) building the koa program
- One article combs multi task learning (mmoe/ple/dupn/essm, etc.)
- Research on clock synchronization performance monitoring system based on 1588v2 Technology
- How to compile and debug go runtime source code
- Solution to the problem that qlineedit setting qdoublevalidator setting range is invalid
- [tke] whether to configure SNAT when the container accesses services outside the node
- Go path customized project path package dependency
- zblog系统如何根据用户ID获取用户相关信息的教程
- Prometheus deployment
- FPGA systematic learning notes serialization_ Day10 [sequential logic, competitive adventure, synchronous reset, asynchronous reset]
猜你喜欢

MySQL learning -- table structure of SQL test questions

Why do you develop middleware when you are young? "You can choose your own way"
![[leetcode108] convert an ordered array into a binary search tree (medium order traversal)](/img/e1/0fac59a531040d74fd7531e2840eb5.jpg)
[leetcode108] convert an ordered array into a binary search tree (medium order traversal)

Daily algorithm & interview questions, 28 days of special training in large factories - the 15th day (string)
随机推荐
区块哈希游戏竞猜系统开发(成熟代码)
让UPS“印象派用户”重新认识可靠性
In those years, I insisted on learning the motivation of programming
[2021 taac & Ti-One] frequently asked questions related to the notebook function
Today, Tencent safety and SAIC Group officially announced!
When the game meets NFT, is it "chicken ribs" or "chicken legs"?
Classic examples of C language 100
Introduction to visual studio shortcut keys and advanced gameplay
IBM: supporting AI and enterprise digital reshaping in the cloud era with modern architecture
Prometheus deployment
Audio knowledge (I)
Can you remember the code of a programming boss? Can you hit it out without Baidu?
Tencent released "warehouse express" and issued "ID card" for each commodity!
Release! Tencent IOA and Tencent sky screen were selected into the first batch of certified products of domestic digital trusted services
The RTSP video image intelligent analysis platform easynvr cascades to the superior platform through the national standard for playback optimization
Following the previous SYSTEMd pit
Go kit microservice integrates Promtheus to solve monitoring alarm problems
How to learn go language happily? Let's go!
[2021 taac & Ti-One] frequently asked questions related to Ti-One products
NFT元宇宙源码搭建解析与介绍