Kubernetes 中不同服务之间可以通过 “service-name” 域名来相互访问,这是通过集群中的 CoreDNS 组件来完成域名解析工作的。但当我们想在 Pod 上增加一些域名解析时,可以通过 Pod 的 spec.hostAliases 字段往 /etc/hosts 文件中添加域名解析(集群需 1.7.x 及以上版)。
它大致等同于以下的 Pod 声明:
apiVersion: v1kind: Podmetadata:name: testspec:hostAliases:– ip: "10.1.2.2"hostnames:– "mc.local"– "rabbitmq.local"containers:– name: cathostsimage: busybox...
