k8s的coreDNS添加自定义hosts

1.ack的hosts不会继承宿主机的hosts,而工作中有一个域名默认是走内网解析,内网被限制访问了,只能在coreDNS中加一个hosts解析域名

2.编辑configmap (coredns)
kubectl edit configmap -n kube-system coredns
增加hosts节点

  Corefile: |
    .:53 {
        errors
        health {
          lameduck 5s
        }
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          fallthrough in-addr.arpa ip6.arpa
        }
        hosts {
            192.168.11.241     www.girls.cn
            192.168.11.240     harbor.girls.cn
            fallthrough
        }
        prometheus :9153
        forward . "/etc/resolv.conf"
        cache 30
        loop
        reload
        loadbalance
    }

3.使用命令行添加过程中一直报错无法添加,后来通过图形界面添加了
k8s的coreDNS添加自定义hosts_第1张图片

.:53 {
    errors
    health :10260 {
       lameduck 15s
    }
    ready
    kubeapi
    k8s_event {
      level info error warning
    }

    kubernetes cluster.local in-addr.arpa ip6.arpa {

       pods insecure
       ttl 30
       fallthrough in-addr.arpa ip6.arpa
    }
    hosts {
       47.106.191.109 osale.gemdale.com
       fallthrough
    }
    prometheus :9153
    forward . /etc/resolv.conf {
      prefer_udp
    }
    cache 30
    log
    loop
    reload
    loadbalance
}

你可能感兴趣的:(kubernetes,容器,云原生)