在GKE DNS中解析豆荚
我对GKE中的Kube-DNS有一个疑问。 当我部署状态填充集时,它将将所有记录基础存储在POD名称上。 例如
dig _mysql._tcp.powerdns-recursor-database-cluster.default.svc.cluster.local. SRV
;; ANSWER SECTION:
_mysql._tcp.powerdns-recursor-database-cluster.default.svc.cluster.local. 30 IN SRV 10 50 3306 powerdns-recursor-database-cluster-1.powerdns-recursor-database-cluster.default.svc.cluster.local.
_mysql._tcp.powerdns-recursor-database-cluster.default.svc.cluster.local. 30 IN SRV 10 50 3306 powerdns-recursor-database-cluster-0.powerdns-recursor-database-cluster.default.svc.cluster.local.
,如您所见,它将返回
powerdns recursor-database-cluster-1
和
powerdns-recursor-database-cluster-0
是正确的POD名称。
但是我有一个CRD,在后端,我的控制器将部署状态填充,但记录却大不相同。
dig _foo._udp.test.default.svc.cluster.local. SRV
;; ANSWER SECTION:
_foo._udp.test.default.svc.cluster.local. 30 IN SRV 10 50 4060 3838313432393332.test.default.svc.cluster.local.
_foo._udp.test.default.svc.cluster.local. 30 IN SRV 10 50 4060 3531343631663839.test.default.svc.cluster.local.
正如您在这里看到的那样,它返回
383831343239332
和
3531343631663839
作为POD名称。 通常,Kubernetes以“”格式返回POD名称或POD IP,但我不知道这些数字是什么以及如何存储它们的Kube-DNS,为什么使用CRD与状态满足不同? 无论如何,这里还可以使用POD名称吗?
I have a question regarding kube-dns in GKE.
When I deploy a statefulset, it will stores all records base on the pod name.
e.g
dig _mysql._tcp.powerdns-recursor-database-cluster.default.svc.cluster.local. SRV
;; ANSWER SECTION:
_mysql._tcp.powerdns-recursor-database-cluster.default.svc.cluster.local. 30 IN SRV 10 50 3306 powerdns-recursor-database-cluster-1.powerdns-recursor-database-cluster.default.svc.cluster.local.
_mysql._tcp.powerdns-recursor-database-cluster.default.svc.cluster.local. 30 IN SRV 10 50 3306 powerdns-recursor-database-cluster-0.powerdns-recursor-database-cluster.default.svc.cluster.local.
So as you can see, it will return
powerdns-recursor-database-cluster-1
and
powerdns-recursor-database-cluster-0
which is a correct pod name.
But I have a CRD and in backend, my controller will deploy a statefulset but the records are very different.
dig _foo._udp.test.default.svc.cluster.local. SRV
;; ANSWER SECTION:
_foo._udp.test.default.svc.cluster.local. 30 IN SRV 10 50 4060 3838313432393332.test.default.svc.cluster.local.
_foo._udp.test.default.svc.cluster.local. 30 IN SRV 10 50 4060 3531343631663839.test.default.svc.cluster.local.
As you can see here, it returns
3838313432393332
and
3531343631663839
as pod name.
Usually kubernetes returns pod name or pod ip in the "-" format but I don't know what is these numbers and how kube-dns storing them and why using CRD is different than statefulset?
Is there anyway to use pod name also here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

经过大量尝试,我发现了这个问题。
通常,我们有两种将无头服务连接到状态填充的方法。
serviceName中使用“ ServiceName”:“ test”
在使用空的“ ServiceName”的情况下, 在GKE内部DNS(Kubedns或CloudDns)中使用podname。
因此,如果我们需要在DNS记录中使用podname,则必须在状态满足中编写
serviceName
。After a lot of tries, I found the issue.
In general, we have two ways for connecting a headless service to a StatefulSet.
serviceName: "test"
selector:
In case of using empty "serviceName" it will not use podName in GKE internal DNS (kubeDNS or CloudDNS).
So if we need to have PodName in our DNS records, we have to write
serviceName
in our statefulSet.