使用coredns解決xip.io解析速度慢的問題

????之前公司內(nèi)部的kubernetes集群,在對其他事業(yè)部提供服務的時候,因為服務偏多,所以從nodePort方式改為了ingress暴露服務。使用xip.io這個公網(wǎng)解析來配置域名,但是由于在域名解析的過程中需要訪問該網(wǎng)站,解析速度較慢,因此采用了coredns來解決此問題,代替xip.io來解析kubernetes的ingress服務。

? ? 1、ingress-controller部署就不做陳述,直接講如何使用coredns來解析一個示例服務。

? ? 2、下載coredns:

wget https://github.com/coredns/coredns/releases/download/v1.3.0/coredns_1.3.0_linux_amd64.tgz

? ? 3、配置Corefile文件如下:

. {

? ? proxy . 223.5.5.5:53 {

? ? ? ? except example.com

? ? ? ? protocol dns

? ? }

? ? prometheus? ? # enable metrics

? ? errors stdout? # show errors

? ? log stdout? ? # show query logs

}

example.org {

? ? file /etc/coredns/zones/example.com

? ? prometheus? ? # enable metrics

? ? errors stdout? # show errors

? ? log stdout? ? # show query logs

}

4、配置example.com文件:

$ORIGIN example.com.

@? ? ? 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. (

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2017042745 ; serial

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 7200? ? ? ; refresh (2 hours)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3600? ? ? ; retry (1 hour)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1209600? ? ; expire (2 weeks)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3600? ? ? ; minimum (1 hour)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? )

? ? 3600 IN NS a.iana-servers.net.

? ? ? ? 3600 IN NS b.iana-servers.net.

*? ? ? IN A? ? 10.10.0.0

ps:10.10.0.0是ingress-controller的pod所在的node ip。

5、部署ingress服務:

示例服務:https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/complete-example

kubectl -f cafe*

6、coredns測試:

在測試機器上面編輯/etc/resove.conf

nameserver corednsIP

curl https://cafe.example.com/coffee --insecure


?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容