下面的配置应该可以做到这一点

.:53 {
    errors
    health
    ready
    kubernetes cluster.local in-addr.arpa ip6.arpa {
        pods insecure
        fallthrough in-addr.arpa ip6.arpa
    }
    prometheus :9153
    forward . 8.8.8.8 8.8.4.4
    cache 30
    loop
    reload
    loadbalance
    hosts custom.hosts myapi.local {
        192.168.49.2 myapi.local
        fallthrough
    }
}

或者您可以尝试使用hosts插件:https://coredns.io/plugins/hosts/

如果你不想用coredns的方法来解决这个问题,有一种方法可以在特定的pod的host文件中设置条目,这将镜像在节点上设置/etc/hosts

apiVersion: v1
kind: Pod
metadata:
  name: hostaliases-pod
spec:
  restartPolicy: Never
  hostAliases:
    - ip: 127.0.0.1
      hostnames:
        - foo.local
        - bar.local
    - ip: 10.1.2.3
      hostnames:
        - foo.remote
        - bar.remote
  containers:
    - name: cat-hosts
      image: busybox
      command:
        - cat
      args:
        - /etc/hosts