CoreDNS ConfigMap選項
先來看看默認的CoreDns的配置文件
Corefile: | .:53 { errors health kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure upstream fallthrough in-addr.arpa ip6.arpa } prometheus :9153 forward . /etc/resolv.conf cache 30 loop reload loadbalance }
解析如下:
- error: 錯誤記錄到stdout
- health:CoreDNS的運行狀況報告為http:// localhost:8080 / health
- kubernetes:CoreDNS將根據Kubernetes服務和pod的IP回復DNS查詢
- prometheus:CoreDNS的度量標准可以在http://localhost:9153/Prometheus格式的指標中找到;可以通過http://localhost:9153/metrics獲取prometheus格式的監控數據
- proxy:任何不在Kubernetes集群域內的查詢都將轉發到預定義的解析器(/etc/resolv.conf);本地無法解析后,向上級地址進行查詢,默認使用宿主機的 /etc/resolv.conf 配置
- cache:啟用前端緩存
- loop:檢測簡單的轉發循環,如果找到循環則停止CoreDNS進程
- reload:允許自動重新加載已更改的Corefile。編輯ConfigMap配置后,請等待兩分鍾以使更改生效
- loadbalance:這是一個循環DNS負載均衡器,可以在答案中隨機化A,AAAA和MX記錄的順序
如何配置外部dns
有些服務不在kubernetes內部,在內部環境內需要通過dns去訪問,名稱后綴為carey.com
carey:53 { errors cache 30 proxy . 10.150.0.1 }
完整的配置文件:
Corefile: | .:53 { errors health kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure upstream fallthrough in-addr.arpa ip6.arpa } prometheus :9153 forward . /etc/resolv.conf cache 30 loop reload loadbalance } carey.com:53 { errors cache 30 proxy . 10.150.0.1 }