阿里云容器服务(ACK)微服务pod解析互联网DNS或者配置强制hosts,可以采用下面的方式:
进入集群--配置管理--配置项(configmap)--kube-system命名空间下的coredns,点击编辑,如果需要配置强制hosts,则新增配置如下:
hosts
{1.2.3.100 www.a.b.com
fallthrough
}
若需要转发公网如dns10.10.5.5去解析二级域名,则新增配置如下:
qq.com:53 {
errors
cache 30
forward . 10.10.5.5
}
全量配置示例如下:
.:53 {
errors
health {
lameduck 5s
}
hosts {
1.2.3.100 www.a.b.com
fallthrough
}
ready
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods verified
upstream
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
autopath @kubernetes
prometheus :9153
forward . 10.10.180.137 10.10.180.138
cache 30
loop
reload
loadbalance
}
qq.com:53 {
errors
cache 30
forward . 10.10.5.5
}
jd.com:53 {
errors
cache 30
forward . 10.10.5.5
}
aliyuncs.com:53 {
errors
cache 30
forward . 10.10.5.5
}
hello777.com:53 {
errors
cache 30
forward . 10.10.5.5
}
zxxs.yun:53 {
errors
cache 30
forward . 10.10.5.5
}
另外黑屏修改方式可以在master节点执行如下命令去编辑修改:
kubectl edit configmap coredns -n kube-system
之后通过命令:
kubectl exec -it {pod名} -n {命名空间} /bin/sh
进入到pod进行ping域名
ping www.a.b.com和ping www.qq.com,解析测试,测试正常。
工作负载--无状态--点击对应的pod名称--查看yaml,
dnsPolicy: ClusterFirst