初创公司利用Docker持续集成部署(3)

配置DNS的consul-template服务

cat /var/named/smart.com.zone.tmp
#DNS区域文件模板
{{$model:="test"}}
$TTL 1D
@       IN SOA  @ rname.invalid. (
                                    0       ; serial
                                    1D      ; refresh
                                    1H      ; retry
                                    1W      ; expire
                                    3H )    ; minimum
    NS      @
    A       127.0.0.1
    AAAA    ::1
@       IN      NS      ns.smart.com.




{{$ips:=file "/var/named/smart.json" |parseJSON}}

{{range services}}
{{$nameArr := .Name | split "-"}}
{{if gt (len $nameArr) 1}}
{{if eq $model (index $nameArr 1)}}
{{$name := (index $nameArr 0)}}
{{$name}}       IN      A        192.168.10.177
{{end}}
{{end}}
{{end}}

{{range $k,$v := $ips}}{{$kn := $k|regexReplaceAll "$" "-"|regexReplaceAll "$" $model}}{{$sk := service $kn}}{{$l:=len $sk}}{{if $l}}{{else}}
{{$k}}  IN      A       {{$v}}{{end}}{{end}}
#由于系统需要调用外部资源所以增加外部固定资源DNS A记录 smart.json
cat /var/named/smart.json
{
"ns":"192.168.10.86"

,"zk1.paas":"192.168.10.160"
,"zk2.paas":"192.168.10.150"
,"zk3.paas":"192.168.10.209"
,"master1.paas":"192.168.10.203"
,"master2.paas":"192.168.10.210"
,"docker":"192.168.10.200"
,"cms":"192.168.6.54"
,"supplier":"192.168.6.54"
,"user":"192.168.6.54"
,"www":"192.168.6.54"
,"manweb":"192.168.6.54"
,"passport":"192.168.6.54"
,"authcode":"192.168.6.54"
,"shop":"192.168.6.54"
,"manage":"192.168.6.54"
,"upload":"192.168.6.53"
,"chat":"192.168.6.53"
,"csc":"192.168.6.53"
,"titan":"192.168.6.53"
,"orders":"192.168.6.53"
,"static":"192.168.6.53"
"smart.json" 51L, 1157C
,"mapi.pay":"192.168.6.53"
,"pay2":"192.168.6.53"
,"sso":"192.168.6.54"
,"group-admin":"192.168.6.54"
,"group":"192.168.6.54"
,"group-orders":"192.168.6.54"
,"img0":"192.168.6.153"
,"img1":"192.168.6.153"
,"img2":"192.168.6.153"
,"img3":"192.168.6.153"
,"img4":"192.168.6.153"
,"img5":"192.168.6.153"
,"img6":"192.168.6.153"
,"img7":"192.168.6.153"
,"img8":"192.168.6.153"
,"img9":"192.168.6.153"
,"cashier.pay":"192.168.6.53"
,"schedule":"192.168.4.14"
,"dp":"192.168.4.211"
,"apd":"192.168.6.54"
,"marathon":"192.168.10.177"
,"jenkins":"192.168.10.161"
,"leader.paas":"192.168.10.177"
}
#添加consul-template更新DNS的配置文件
cat /usr/local/consul-template/bind.conf
consul="192.168.10.184:8500"
template {
source="/var/named/smart.com.zone.tmp"
destination="/var/named/smart.com.zone"
command="chown root.named /var/named/smart*;/etc/init.d/named restart"
}
nohup consul-template -config=./bind.conf >dns.out &
#运行DNS的consul-template服务 


10)配置Jenkins

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/b8e2c9457544d0567f77feff357fd34b.html