zoukankan      html  css  js  c++  java
  • CoreDNS配置etcd作为后端

    配置说明

    官方有使用etcd插件的详细说明,地址如下:https://coredns.io/plugins/etcd/

    需要特别说明的是,目前coredns只支持etcd v2版本的api

    这里直接摘出用法示例:

    etcd [ZONES...] {
        stubzones
        fallthrough [ZONES...]
        path PATH
        endpoint ENDPOINT...
        upstream [ADDRESS...]
        tls CERT KEY CACERT
    }
    

    常用参数说明:

    • ZONES :经过授权的区域,可以为空
    • stubzones:启用存根区域功能。stubzone仅在位于指定的第一个区域下方的etcd树中完成。
    • fallthrough:如果区域匹配但不能生成记录,则将请求传递给下一个插件
    • path:etcd里面的路径 默认为"/skydns",以后所有的dns记录就是存储在该存根路径底下
    • endpoint:etcd访问地址,默认http://localhost:2397

    示例

    添加dns解析

    etcd配置示例:

    etcd {
        stubzones
        path /skydns
        endpoint http://10.1.61.129:2379
        upstream /etc/resolv.conf
    }
    

    那么我们往etcd中添加如下记录:

    curl -XPUT http://10.1.61.129:2379/v2/keys/skydns/com/test/dynamic/coredns -d value='{"host":"10.1.61.134"}'
    

    通过coredns解析coredns.dynamic.test.com可以返回10.1.61.134,可以看出,com/test/dynamic/corednscoredns.dynamic.test.com正好相反

    添加指定dns解析

    etcd配置示例

    etcd test.com{
        stubzones
        path /skydns
        endpoint http://10.1.61.129:2379
        upstream /etc/resolv.conf
    }
    

    那么就必须添加/com/test/*/*的域名才能访问

    curl -XPUT http://10.1.61.129:2379/v2/keys/skydns/com/test/dynamic/www -d value='{"host":"10.1.61.133"}'
    

    单个域名对应多个ip:

    curl -XPUT http://10.1.61.129:2379/v2/keys/skydns/com/test/www/ttggxuxp -d value='{"host":"10.1.61.134"}'
    
    curl -XPUT http://10.1.61.129:2379/v2/keys/skydns/com/test/www/jzlnykyj -d value='{"host":"10.1.61.135"}'
    

    这样,解析www.test.com得到的结果就是10.1.61.135和10.1.61.134

    反向解析

    coredns是支持反向解析的。如果要添加172.0.0.0/24的反向,则需要将zone 0.0.172.in-addr.arpa添加到区域列表中。如果需要添加172.16.80.0/8的反向,则需要将zone 172.in-addr.arpai添加到区域列表中。

    下面是将10.1.61.135/8指向breeze.test.com,Corefile配置:

    .:53 {
        etcd test.com 10.in-addr.arpa {
            stubzones
            path /skydns
            endpoint http://10.1.61.129:2379
            upstream /etc/resolv.conf
        }
        log
        errors
        proxy . /etc/resolv.conf
    }
    

    向etcd中添加记录如下:

    curl -XPUT http://10.1.61.129:2379/v2/keys/skydns/arpa/in-addr/10/1/61/135 -d value='{"host":"breeze.test.com"}'
    

    最后再贴一个完整的etcd的配置示例:

    .:53 {
        etcd wh04 test2.com {
            stubzones
            path /coredns
            endpoint http://10.1.61.129:2379
            upstream /etc/resolv.conf
            fallthrough
        }
        health
        log
        errors
        prometheus :9153
        proxy . /etc/resolv.conf
        cache 30
        reload 10s
    }
    test.com {
        etcd {
            stubzones
            path /coredns
            endpoint http://127.0.0.1:2379
            upstream /etc/resolv.conf
        }
        health :8081
        log
        errors
        prometheus :9253
        proxy . /etc/resolv.conf
        cache 30
        relaod 10s
    }
    
  • 相关阅读:
    详细深入分析 Java ClassLoader 工作机制
    centos 文件系统权限
    leaflet 实现地图上标记的发散闪烁动画
    GEOJSON 的渲染实例
    【转】多用户同时登陆Windows远程桌面 | 最近升级了win10系统,以前一直用的RDPWrap-1.6版本无法使用,解决方案
    getopt 用法
    安装oracle报:oracle net configuration assistant失败
    【Delphi学习】ADOQuery 用法
    如何为DOS批处理%time%小时的值小于10的时候如何在这个值前加0?
    .bat 中显示出的时间格式问题,如2:36:00,如何让运行脚本显示为02:36:00
  • 原文地址:https://www.cnblogs.com/breezey/p/9100375.html
Copyright © 2011-2022 走看看