APISIX cannot run on kubernetes possibly due to unrecognized resolv.conf

Hi, I’m planning to use apisix as api gateway in k8s. but apisix complaint “failed to set server peer [some-k8s-svc.default.svc.cluster.local:5202] err: no host allowed”.

having dug into the problem and read nginx/openresty’s source code, i found the problem might be related to dns resolution in openresty(after openresty/src/ngx_http_lua_balancer.c:ngx_http_lua_ffi_balancer_set_current_peer -> src/core/ngx_inet.c:ngx_parse_url -> ngx_parse_inet_url, url’s address is null).

one possible reason could be apisix don’t understand search and option in resolv.conf: https://github.com/apache/apisix/issues/2533

so i would like to try to remove search and option to see if it works. but a problem is that search and option field in yaml seems to be merge with preset values into resolv.conf, instead of replacing them. so is there a method to remove/replace these lines?

or is there anybody that has met this problem? is there a workaround?

Cluster information:

Kubernetes version: v1.18.8-aliyun.1
Cloud being used: alibabacloud
Installation method: web console
Host OS: CentOS 7.7a
CNI and version: registry-vpc.cn-hangzhou.aliyuncs.com/acs/flannel:v0.11.0.2-g6e46593e-aliyun
CRI and version: docker 19.03.5

You should be able to customize the pod’s DNS config to suit your needs by setting dnsPolicy to None then specifying your own dnsConfig.

Here are the details:


Hi, thanks! though it does not resolve the problem of apisix, i make it to configure resolv.conf.