Kubernetes ExternalName服务无法解决

时间:2018-04-26 11:07:11

标签: kubernetes

如果使用指向某个外部服务的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

如果我将服务更改为指向某个其他群集内部服务,我会得到以下预期的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。

1 个答案:

答案 0 :(得分:7)

问题在于使用过的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:

  

从grayluck / externalname合并拉取请求#225   通过重新加载resolv.conf修复外部名称无法解决。