gpt4 book ai didi

Kubernetes ExternalName 服务无法解析

转载 作者:行者123 更新时间:2023-12-01 09:13:55 25 4
gpt4 key购买 nike

如果使用指向某个外部服务的 externalName 创建了一个服务。

apiVersion: v1
kind: Service
metadata:
name: test
spec:
type: ExternalName
externalName: google.com

当我现在尝试进行 DNS 查找时,它不会返回任何有用的信息:
# dig test.development.svc.cluster.local.

; <<>> DiG 9.9.5-9+deb8u15-Debian <<>> test.development.svc.cluster.local.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58159
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;test.development.svc.cluster.local. IN A

;; AUTHORITY SECTION:
cluster.local. 60 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1524736800 28800 7200 604800 60

;; Query time: 0 msec
;; SERVER: 100.64.0.10#53(100.64.0.10)
;; WHEN: Thu Apr 26 10:58:48 UTC 2018
;; MSG SIZE rcvd: 106

如果我明确查询 CNAME 类型,我会得到响应:
# dig -t CNAME test.development.svc.cluster.local.

; <<>> DiG 9.9.5-9+deb8u15-Debian <<>> -t CNAME test.development.svc.cluster.local.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54517
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;test.development.svc.cluster.local. IN CNAME

;; ANSWER SECTION:
test.development.svc.cluster.local. 30 IN CNAME google.com.

;; Query time: 0 msec
;; SERVER: 100.64.0.10#53(100.64.0.10)
;; WHEN: Thu Apr 26 10:59:55 UTC 2018
;; MSG SIZE rcvd: 76

如果我将 Service 更改为指向某个其他集群内部服务,则会得到以下 IP 地址的预期结果:
# dig dogstatsdport.development.svc.cluster.local

; <<>> DiG 9.9.5-9+deb8u15-Debian <<>> dogstatsdport.development.svc.cluster.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32857
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;dogstatsdport.development.svc.cluster.local. IN A

;; ANSWER SECTION:
dogstatsdport.development.svc.cluster.local. 30 IN CNAME dogstatsdport.default.svc.cluster.local.
dogstatsdport.default.svc.cluster.local. 30 IN A 100.68.195.103

;; Query time: 0 msec
;; SERVER: 100.64.0.10#53(100.64.0.10)
;; WHEN: Thu Apr 26 11:02:14 UTC 2018
;; MSG SIZE rcvd: 113

这里有什么遗漏/错误?以及如何解决外部记录?

集群目前在 Kubernetes 1.8.12 上运行,使用 kops 1.9.0 进行设置。

最佳答案

问题在于使用的 kube-dns 版本 1.14.9。

应用以下命令更新到 1.14.10 修复了它:

kubectl set image deployment/kube-dns -n kube-system \
kubedns=gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.10 \
dnsmasq=gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.10 \
sidecar=gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.10

https://github.com/kubernetes/dns/releases 1.14.10 的状态:

Merge pull request #225 from grayluck/externalname Fix external name not solving by reloading resolv.conf.

关于Kubernetes ExternalName 服务无法解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50041411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com