gpt4 book ai didi

Kubernetes StatefulSets : External DNS

转载 作者:行者123 更新时间:2023-12-03 22:36:18 25 4
gpt4 key购买 nike

Kubernetes StatefulSets创建具有稳定网络 ID 的内部 DNS 条目。文档在此处对此进行了描述:

Each Pod in a StatefulSet derives its hostname from the name of the StatefulSet and the ordinal of the Pod. The pattern for the constructed hostname is $(statefulset name)-$(ordinal). The example above will create three Pods named web-0,web-1,web-2. A StatefulSet can use a Headless Service to control the domain of its Pods. The domain managed by this Service takes the form: $(service name).$(namespace).svc.cluster.local, where “cluster.local” is the cluster domain. As each Pod is created, it gets a matching DNS subdomain, taking the form: $(podname).$(governing service domain), where the governing service is defined by the serviceName field on the StatefulSet.

我正在试验 headless 服务,这对于各个服务之间的通信非常有用,即 web-0.web.default.svc.cluster.local 可以与 web- 连接和通信1.web.default.svc.cluster.local就好了。

有什么方法可以将它配置为在集群网络之外工作,其中“cluster.local”被替换为“clustera.com”之类的东西?

我想给另一个kubernetes集群,我们称之为clusterb.com,访问原始集群(clustera.com)的各个服务;我希望它看起来像 clusterb 只是简单地击中 web-1.web.default.svc.clustera.comweb-0.web.default.svc.clustera 这样的端点。 com.

这可能吗?我想要访问单个服务,而不是负载平衡端点。

最佳答案

我建议您测试以下解决方案并检查它们是否可以帮助您在您的特定场景中实现您的目标:

  • 第一个肯定是最简单的,我相信您出于某种原因没有实现它并且您没有在问题中报告原因。

    我说的是Headless services没有用于 ExternalName 类型服务的选择器 CNAME 记录。

    ExternalName: Maps the service to the contents of the externalName field (e.g. foo.bar.example.com), by returning a CNAME record with its value. No proxying of any kind is set up. This requires version 1.7 or higher of kube-dns

    因此如果你需要指向其他集群的服务,你需要注册一个域名指向clusterb的相对IP。

  • 第二种我从未测试过但我相信它可以适用于您的情况的解决方案是使用 Federated Cluster。使用它的原因是根据文档:

    Cross cluster discovery: Federation provides the ability to auto-configure DNS servers and load balancers with backends from all clusters. For example, you can ensure that a global VIP or DNS record can be used to access backends from multiple clusters.

关于Kubernetes StatefulSets : External DNS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49264128/

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