默认情况下, CoreDNS 不支持节点的 /etc/hosts 文件里的静态域名解析。需要修改 coredns 的 configmap 配置,在 coredns 增加节点 /etc/hosts 的挂载。
登录任意一台控制平面主机,进行下面的操作:
执行下面的命令:
kubectl -n kube-system edit configmap coredns
并在 health 内容的后面增加如下内容:
hosts /etc/add_hosts { fallthrough}
执行下面的命令:
kubectl edit deployment -n kube-system coredns
在 volumeMounts: 这一行下增加如下内容:
- mountPath: /etc/add_hosts name: add-hosts
在 volumes: 这一行下增加如下内容:
- hostPath: path: /etc/hosts type: "" name: add-hosts
在所有 k8s 节点的 /etc/hosts 文件里增加一条 IP 地址映射,然后登录任意一个 pod, 然后 ping 添加到 /etc/hosts 的映射主机,看是否解析成刚才增加的 IP 地址。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。