在GKE DNS中解析豆荚

发布于 01-22 22:12 字数 1416 浏览 4 评论 0原文

我对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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗼ふ静2025-01-29 22:12:11

经过大量尝试,我发现了这个问题。

通常,我们有两种将无头服务连接到状态填充的方法。

  1. 在statefulset serviceName中使用“ ServiceName”:“ test”
  2. 使用Service 选择器中的选择器:
  3. 使用两种方式(serviceName + selector)使用这两个方法

在使用空的“ 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.

  1. Using "serviceName" in StatefulSet serviceName: "test"
  2. Using selector in Service selector:
  3. Using both way (serviceName + 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文