简体   繁体   English

Kubernetes 中进入 ClusterIP 和 Headless 服务的入口路由连接有什么区别?

[英]What is the different between ingress route connection into ClusterIP and Headless service in Kubernetes?

I know the basic concept of ClusterIP and Headless services.我知道ClusterIPHeadless服务的基本概念。

I think the key different is ClusterIP do some sort of load balancing between underlying pods by applying some iptable rules.我认为关键的不同是ClusterIP通过应用一些 iptable 规则在底层 pod 之间进行某种负载平衡。
Then Headless just a list of ip addresses of pods registered in DNS.然后Headless只是在 DNS 中注册的 Pod 的 ip 地址列表。

And my question is, if ClusterIP do the "load balancing" job, does that mean the ingress controller just do the routing but not load balancing?我的问题是,如果ClusterIP做“负载平衡”工作,这是否意味着入口 controller 只做路由但不做负载平衡?
What if using Headless as the service type, can I configure the ingress controller and let it take over the load balancing job?如果使用Headless作为服务类型,我可以配置入口 controller 并让它接管负载均衡工作吗?

Thanks.谢谢。

Service carries mapping to all of the pods registered with it via selector labels, and to send traffic to any of pods, it is just required to communicate to that service only and it will select some pod to route the request to, while headless service has nothing like clusterIP so it uses Pod's IP only, a chance to do direct communication with pods.服务通过选择器标签映射到向其注册的所有 pod,并将流量发送到任何 pod,只需要与该服务通信,它将 select 一些 pod 将请求路由到,而无头服务有与 clusterIP 完全不同,因此它仅使用 Pod 的 IP,有机会与 Pod 进行直接通信。

Say that you have a set of Kafka brokers deployed and you want to get info about a topic resting in one broker, then probably you can do that via headless service.假设您部署了一组 Kafka 代理,并且您想获取有关某个代理中的某个主题的信息,那么您可能可以通过无头服务来做到这一点。

Now for these pods to talk to external world, they need to be exposed to load balancer layer, here comes the role of ingress that maps the domain URL to the backend services, and only ingress' service is exposed at the load balancer layer, rest remain under the hood.现在这些 pod 与外部世界对话,它们需要暴露在负载均衡器层,这里是 ingress 的作用,将域 URL 映射到后端服务,并且只有 ingress 的服务暴露在负载均衡器层,rest留在引擎盖下。

The advantage of this is, you can attach firewall rules to ingress, URL rewrites can be done, sticky sessions can be implemented ie while services can't offer such things.这样做的好处是,您可以将防火墙规则附加到入口,可以完成 URL 重写,可以实现粘性会话,即服务不能提供这些东西。

And my question is, if ClusterIP do the "load balancing" job, does that mean the ingress controller just do the routing but not load balancing?我的问题是,如果 ClusterIP 做“负载平衡”工作,这是否意味着入口 controller 只做路由但不做负载平衡?

AFAIK, Ingress expose the certain Services , and route external requests to multiple Services . AFAIK, Ingress公开某些Services ,并将外部请求路由到多个Services It usually integrated with Load balancer layers for handling external requests, but it's not just only for loadbalancing.它通常与负载均衡器层集成以处理外部请求,但它不仅用于负载均衡。

What if using Headless as the service type, can I configure the ingress controller and let it take over the load balancing job?如果使用 Headless 作为服务类型,我可以配置入口 controller 并让它接管负载均衡工作吗?

In use case of Headless , it designed for self-managed application on load balancing and transaction management.Headless的用例中,它设计用于负载平衡和事务管理的自我管理应用程序。 Sometimes the clusterIP load balancing on Kubernetes would not fit to the application or middleware which already has their own features with the same things.有时,Kubernetes 上的clusterIP负载平衡不适合已经具有相同功能的应用程序或中间件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM