針對 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 存檔就可以立即生效
  • tech/rancher_coredns_hosts.txt
  • 上一次變更: 2021/01/27 15:48
  • jonathan