LoadBalancer for Kubernetes
此项目包括用于根据 Kubernetes 端点进行负载均衡的 Spring Cloud Load Balancer,并提供基于 Kubernetes 服务的负载均衡器实现。要将其包含到你的项目中,请添加以下依赖项。Fabric8 实现
This project includes Spring Cloud Load Balancer for load balancing based on Kubernetes Endpoints and provides implementation of load balancer based on Kubernetes Service. To include it to your project add the following dependency. Fabric8 Implementation
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-fabric8-loadbalancer</artifactId>
</dependency>
Kubernetes Java 客户端实现
Kubernetes Java Client Implementation
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-client-loadbalancer</artifactId>
</dependency>
要启用基于 Kubernetes 服务名称的负载均衡,请使用以下属性。然后负载均衡器将尝试使用地址调用应用程序,例如 service-a.default.svc.cluster.local
To enable load balancing based on Kubernetes Service name use the following property. Then load balancer would try to call application using address, for example service-a.default.svc.cluster.local
spring.cloud.kubernetes.loadbalancer.mode=SERVICE
要跨所有命名空间启用负载均衡,请使用以下属性。spring-cloud-kubernetes-discovery
模块中的属性受到尊重。
To enabled load balancing across all namespaces use the following property. Property from spring-cloud-kubernetes-discovery
module is respected.
spring.cloud.kubernetes.discovery.all-namespaces=true
如果需要通过 HTTPS 访问服务,则需要向你的服务定义添加一个标签或注释,名称为 secured
,值设为 true
,然后负载均衡器将使用 HTTPS 向服务发出请求。
If a service needs to be accessed over HTTPS you need to add a label or annotation to your service definition with the name secured
and the value true
and the load balancer will then use HTTPS to make requests to the service.