linux CoreDns安装
k8s coredns安装介绍:
https://kubernetes.io/zh/docs/tasks/administer-cluster/coredns/
1.下载二进制文件
wget https://github.com/coredns/coredns/releases/download/v1.5.0/coredns_1.5.0_linux_amd64.tgz
tar zxf coredns_1.5.0_linux_amd64.tgz -C /usr/bin/
2.创建用户
useradd coredns -s /sbin/nologin
3.编辑/etc/coredns/Corefile
.:53 {
# 绑定interface ip
bind 127.0.0.1
# 先走本机的hosts
# https://coredns.io/plugins/hosts/
hosts {
# 自定义sms.service search.service 的解析
# 因为解析的域名少我们这里直接用hosts插件即可完成需求
# 如果有大量自定义域名解析那么建议用file插件使用 符合RFC 1035规范的DNS解析配置文件
10.6.6.2 sms.service
10.6.6.3 search.service
# ttl
ttl 60
# 重载hosts配置
reload 1m
# 继续执行
fallthrough
}
# file enables serving zone data from an RFC 1035-style master file.
# https://coredns.io/plugins/file/
# file service.signed service
# 最后所有的都转发到系统配置的上游dns服务器去解析
forward . /etc/resolv.conf
# 缓存时间ttl
cache 120
# 自动加载配置文件的间隔时间
reload 6s
# 输出日志
log
# 输出错误
errors
}
更新插件使用:https://github.com/coredns/coredns
4.编辑/usr/lib/systemd/system/coredns.service
[Unit]
Description=CoreDNS DNS server
Documentation=https://coredns.io
After=network.target
[Service]
PermissionsStartOnly=true
LimitNOFILE=1048576
LimitNPROC=512
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
User=coredns
ExecStart=/usr/bin/coredns -conf=/etc/coredns/Corefile
ExecReload=/bin/kill -SIGUSR1 $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
5.启动coredns
systemctl enable coredns
systemctl start coredns
systemctl status coredns
生产配置
s]# cat corefile.conf
.:53 {
bind 192.168.44.218
errors
log
loadbalance round_robin
health {
lameduck 5s
}
hosts {
192.168.44.218 apollo.config.beta
192.168.6.166 apollo.config.beta
192.168.6.166 apollo.beta
192.168.44.218 apollo.beta
192.168.44.210 BETAWS26
192.168.44.203 BDSGATEWAY
192.168.1.21 HOSTBETAWS21
192.168.6.158 HOSTBETAAS21
192.168.6.159 HOSTBETAAS22
192.168.6.164 HOSTBETAWS22
192.168.44.201 HOSTBETAWS24
192.168.44.203 HOSTBETAWS25
192.168.44.204 HOSTBETADS21
192.168.1.21 HOSTMONGODB
192.168.44.201 HOSTMONGODBWS4
192.168.44.203 HOSTMONGODBWS5
192.168.44.204 HOSTREDIS
192.168.45.0 HOSTAUTH
192.168.44.210 HOSTBIGDATASERVICE
192.168.44.210 HOSTAUTOCOMPLETE
192.168.44.210 HOSTUSERSUBSCRIBE
192.168.44.210 abcba.com
192.168.45.0 w-1.betawm.com
192.168.45.0 w-2.betawm.com
192.168.45.0 HOSTTEST
ttl 50
reload 1m
fallthrough
}
ready
prometheus :9153
forward . 100.100.2.136 100.100.2.138
cache 30
reload
}
[root@BETAWS27 coredns]# ps aux | grep coredns
root 1315411 0.7 0.2 753292 39416 ? Sl Sep11 1016:14 /beta/coredns/coredns -conf /beta/coredns/corefile.conf
root 2014857 0.0 0.0 12108 1044 pts/0 S+ 09:57 0:00 grep --color=auto coredns

浙公网安备 33010602011771号