编辑coredns的配置文件

kubectl edit configmap coredns -n kube-system

增加解析

hosts {
127.0.0.1 nacos.com
fallthrough
}

以下为示例

apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
uid: afe82210-48ab-4e74-a190-7d401a8af49a
resourceVersion: '240420099'
creationTimestamp: '2022-09-29T03:44:33Z'
annotations:
forward_config: ''
data:
Corefile: |-
.:53 {
errors
health
ready
hosts {
127.0.0.1 nacos.com
fallthrough
}
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus :9153
log . {
class all
}
cache 30
loop
reload
loadbalance
forward . /etc/resolv.conf
}