云容器引擎 CCE-使用CoreDNS实现自定义域名解析:为CoreDNS配置存根域

时间:2024-05-17 11:30:04

为CoreDNS配置存根域

集群管理员可以修改CoreDNS Corefile的ConfigMap以更改服务发现的工作方式。

若集群管理员有一个位于10.150.0.1的Consul域名解析服务器,并且所有Consul的域名都带有.consul.local的后缀。

  1. 登录CCE控制台,单击集群名称进入集群。
  2. 在左侧导航栏中选择“插件中心”,在CoreDNS下单击“编辑”,进入插件详情页。
  3. “参数配置”下添加存根域。格式为一个键值对,键为DNS后缀域名,值为一个或一组DNS IP地址,如 'consul.local --10.150.0.1'。

    图1 添加存根域

  4. 单击“确定”完成配置更新。
  5. 在左侧导航栏中选择“配置与密钥”,在“kube-system”命名空间下,查看名为coredns的配置项数据,确认是否更新成功。

    对应Corefile内容如下:

    .:5353 {
        bind {$POD_IP}
        cache 30 {
            servfail 5s
        }
        errors
        health {$POD_IP}:8080
        kubernetes cluster.local in-addr.arpa ip6.arpa {
            pods insecure
            fallthrough in-addr.arpa ip6.arpa
        }
        loadbalance round_robin
        prometheus {$POD_IP}:9153
        forward . /etc/resolv.conf {
            policy random
        }
        reload
        ready {$POD_IP}:8081
    }
    consul.local:5353 {
        bind {$POD_IP}
        errors
        cache 30
        forward . 10.150.0.1
    }

support.huaweicloud.com/usermanual-cce/cce_10_0361.html