最近在搞kubernetes的CICD,是基于gitlab Autocicd 来做的,Autocicd 有个要求就是要配置一个dns泛解析,所以自己就搭建一个,故记录一下
安装bind9
1 | sudo apt install bind9 |
配置主配置文件name.conf.local,增加以下内容
1 | zone "testk8s.cn" { type master; file "/var/cache/bind/db.test8s.cn"; }; |
新增db.test8s.cn解析文件/var/cache/bind/db.test8s.cn
1 | $TTL 86400 |
重启服务
1 | sudo systemctl restart bind9 |
本机测试
1 | nslookup test.10010k8s.cn |
更改k8s-coredns配置
这段配置大概意思是说,testk8s.cn 的所有域名解析 都转发到192.168.137.205
1
2
3
4
5 testk8s.cn:53 {
errors
cache 30
proxy . 192.168.137.205 //dns地址
}
容器内测试解析
1 | $ [K8sDev] kubectl exec -it -n gitlab centos7 nslookup aa.10010k8s.cn |
- 本文作者: ChuLinx
- 本文链接: http://yoursite.com/2019/11/30/bind9-DNS配置/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!