Background:

Self-built Kubernetes1.16 cluster, service applications early mostly PHP applications. Docker encapsulates the Nginx + PHP-FPM base image and packages the code as Image Jenkins for CI/CD construction. PHP application in the domain name resolution failed….. error what? I started to wonder about the Kubernets version, and I also wondered about the network components. But no reason was found. Today when I was just the baidu search information came across: https://www.it1352.com/589254.html, see it solve the curl of obtaining the curl specifies CURL_IPRESOLVE_V4 spend time is too long time. I just thought about it… Yes. My cluster does not have IPv6 disabled! Highlighted:

If IPv6 is turned on, curl will resolve IPv6 first by default, and wait for a timeout for IPv6 DNS resolution to fail before going back to IPv4

About the solution:

If you think about it for yourself, there are two solutions:

  1. The Work node disables IPv6.
  2. The PHP code specifies CURL_IPRESOLVE_V4.

    Start with:

    1. Disabling IPv6 on the Work node

    Reference: https://blog.csdn.net/wh211212/article/details/80996364 I’m directly sysctl Settings disable IPv6 way, don’t want to restart the cluster nodes.

    In the/etc/sysctl. Conf net. Add the following line of ipv6. Conf. All. Disable_ipv6 = 1 net. Ipv6. Conf. Default. Disable_ipv6 = 1 # or perform sed -i '$ A \.net. Ipv6. Conf. All. Disable_ipv6 = 1 \ nnet ipv6. Conf. Default. Disable_ipv6 = 1 '/ etc/sysctl. Conf will make Settings to take effect, please perform sysctl -p

    2. Changes to PHP code

    Reference: https://www.jb51.net/article/39788.htm, throw it to the PHP friend… After all, I don’t know PHP.

Other references:

1. K8s — Coredns disable IPv6 parsing

2. DNS resolution is optimized using the NSCD cache in the container

[

](https://my.oschina.net/u/2322…