Kubernetes StatefulSets:外部 DNS
Kubernetes StatefulSets: External DNS
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.
我正在试验无头服务,这对于各个服务之间的通信非常有用,即 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.com
和 web-0.web.default.svc.clustera.com
.
这样的端点
这可能吗?我想要访问单个服务,而不是负载平衡端点。
我建议您测试以下解决方案并检查它们是否可以帮助您在特定情况下实现目标:
第一个肯定是最简单的,我相信您出于某种原因没有实施它并且您没有在问题中报告原因。
我说的是 Headless services ExternalName-type 服务没有选择器 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 创建具有稳定网络 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.
我正在试验无头服务,这对于各个服务之间的通信非常有用,即 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.com
和 web-0.web.default.svc.clustera.com
.
这可能吗?我想要访问单个服务,而不是负载平衡端点。
我建议您测试以下解决方案并检查它们是否可以帮助您在特定情况下实现目标:
第一个肯定是最简单的,我相信您出于某种原因没有实施它并且您没有在问题中报告原因。
我说的是 Headless services ExternalName-type 服务没有选择器 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.