Today when testing the pod's internal communication and external network, I found that I couldn't ping it.
Tested access to www.baidu.com and found that the ping still failed. Check if there is a problem with coredns.
[root@devops ~]# kubectl edit cm coredns -n kube-system
It is found that the cm configuration is normal and the coredns log is checked.
[root@devops ~]# kubectl logs -n kube-system coredns-66f779496c-2tjgf
It showed that the address communication could not be found instead of the connection timeout. At this time, I thought that the firewall might not be released. After checking, it turned out to be the case.
Since I am in a test environment, I was too lazy to just turn off the firewall. Tested again and the connection returned to normal! !
By the way, let’s mention the field dnsPolicy
Pod’s DNS policy
- Default: Inherit the DNS configuration of the node;
- ClusterFirst: use coredns as DNS configuration;
-
ClusterFirstWithHostNet:
- When Pod.spec.hostNetwork=true, the Pod’s DNS policy is forced to Default, which inherits the node’s DNS configuration;
- If the Pod wants to use coredns as DNS configuration, you need to configure pod.spec.dnsPolicy=ClusterFirstWithHostNet;
- None: No DNS configuration;
If dnsPolicy is not specified, the default is =ClusterFirst.