====== 針對 K8s 環境內定義類似 /etc/hosts 方式 ====== * 以下是在 rancher 下的設定方式 * Clusters(已經建立的 Cluster) -> System * Resources -> Config -> Namespace: kube-system -> coredns -> Edit * Corefile 的內容改成類似以下: .:53 { errors health { lameduck 5s } ready kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } prometheus :9153 forward . "/etc/resolv.conf" cache 30 loop reload loadbalance hosts iiidevops.tw { 192.168.7.101 www.iiidevops.tw 192.168.7.101 gitlab.iiidevops.tw 192.168.7.101 redmine.iiidevops.tw 192.168.7.101 harbor.iiidevops.tw 192.168.7.101 sonarqube.iiidevops.tw fallthrough } } * Save 存檔就可以立即生效 ===== 參考網址 ===== * https://medium.com/@hjrocha/add-a-custom-host-to-kubernetes-a06472cedccb * https://linux-rtdocs.readthedocs.io/en/latest/k8s/coreDNS%E6%B7%BB%E5%8A%A0%E9%9D%99%E6%80%81DNS%E7%9A%84%E6%96%B9%E6%B3%95/ {{tag>coredns rancher k8s}}