#562 Adding docs, javadoc + removed unused code
This commit is contained in:
28
docs/src/main/asciidoc/load-balancer.adoc
Normal file
28
docs/src/main/asciidoc/load-balancer.adoc
Normal file
@@ -0,0 +1,28 @@
|
||||
== LoadBalancer for Kubernetes
|
||||
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.
|
||||
====
|
||||
[source,xml]
|
||||
----
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
----
|
||||
====
|
||||
|
||||
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`
|
||||
====
|
||||
[source]
|
||||
----
|
||||
spring.cloud.kubernetes.loadbalancer.mode=SERVICE
|
||||
----
|
||||
====
|
||||
|
||||
To enabled load balancing across all namespaces use the following property. Property from `spring-cloud-kubernetes-discovery` module is respected.
|
||||
====
|
||||
[source]
|
||||
----
|
||||
spring.cloud.kubernetes.discovery.all-namespaces=true
|
||||
----
|
||||
====
|
||||
@@ -33,7 +33,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@TestPropertySource(properties = "spring.cloud.kubernetes.discovery.all-namespaces=true")
|
||||
@EnableKubernetesMockClient(https = true, crud = true)
|
||||
@EnableKubernetesMockClient(crud = true)
|
||||
public class LoadBalancerAllNamespacesTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@EnableKubernetesMockClient(https = true, crud = true)
|
||||
@EnableKubernetesMockClient(crud = true)
|
||||
public class LoadBalancerTests {
|
||||
|
||||
@Autowired
|
||||
@@ -40,9 +40,6 @@ public class LoadBalancerTests {
|
||||
@LocalServerPort
|
||||
int randomServerPort;
|
||||
|
||||
// @ClassRule
|
||||
// public static KubernetesServer server = new KubernetesServer(true, true);
|
||||
|
||||
static KubernetesClient client;
|
||||
|
||||
@BeforeAll
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Kubernetes load balancer auto-configuration.
|
||||
*
|
||||
* @author Piotr Minkowski
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* Kubernetes load balancer client properties.
|
||||
* Kubernetes load balancer client configuration.
|
||||
*
|
||||
* @author Piotr Minkowski
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package org.springframework.cloud.kubernetes.loadbalancer;
|
||||
|
||||
/**
|
||||
* Kubernetes load balancer mode enum.
|
||||
*
|
||||
* @author Piotr Minkowski
|
||||
*/
|
||||
public enum KubernetesLoadBalancerMode {
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.cloud.kubernetes.loadbalancer;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Kubernetes load balancer client properties.
|
||||
*
|
||||
* @author Piotr Minkowski
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.cloud.kubernetes.loadbalancer")
|
||||
|
||||
@@ -31,6 +31,8 @@ import org.springframework.cloud.kubernetes.discovery.KubernetesDiscoveryPropert
|
||||
import org.springframework.cloud.kubernetes.discovery.KubernetesServiceInstance;
|
||||
|
||||
/**
|
||||
* Class for mapping Kubernetes Service object into {@link KubernetesServiceInstance}.
|
||||
*
|
||||
* @author Piotr Minkowski
|
||||
*/
|
||||
public class KubernetesServiceInstanceMapper {
|
||||
|
||||
@@ -31,6 +31,9 @@ import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ServiceInstanceListSupplier} for load balancer
|
||||
* in SERVICE mode
|
||||
*
|
||||
* @author Piotr Minkowski
|
||||
*/
|
||||
public class KubernetesServicesListSupplier implements ServiceInstanceListSupplier {
|
||||
|
||||
Reference in New Issue
Block a user