Merge branch '3.0.x'
This commit is contained in:
@@ -46,7 +46,6 @@ import org.springframework.cloud.kubernetes.commons.config.KubernetesConfigServe
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties;
|
||||
import org.springframework.core.env.AbstractEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.client.KubernetesClientUtils.kubernetesApiClient;
|
||||
|
||||
@@ -57,7 +56,7 @@ class KubernetesClientConfigServerBootstrapper extends KubernetesConfigServerBoo
|
||||
|
||||
@Override
|
||||
public void initialize(BootstrapRegistry registry) {
|
||||
if (!ClassUtils.isPresent("org.springframework.cloud.config.client.ConfigServerInstanceProvider", null)) {
|
||||
if (hasConfigServerInstanceProvider()) {
|
||||
return;
|
||||
}
|
||||
// We need to pass a lambda here rather than create a new instance of
|
||||
@@ -96,7 +95,7 @@ class KubernetesClientConfigServerBootstrapper extends KubernetesConfigServerBoo
|
||||
.getInstances(serviceId);
|
||||
}
|
||||
|
||||
protected KubernetesConfigServerInstanceProvider getInstanceProvider(
|
||||
private KubernetesConfigServerInstanceProvider getInstanceProvider(
|
||||
KubernetesDiscoveryProperties discoveryProperties, KubernetesClientProperties clientProperties,
|
||||
BootstrapContext context, Binder binder, BindHandler bindHandler, Log log) {
|
||||
if (context.isRegistered(KubernetesInformerDiscoveryClient.class)) {
|
||||
@@ -116,12 +115,12 @@ class KubernetesClientConfigServerBootstrapper extends KubernetesConfigServerBoo
|
||||
|
||||
String namespace = getInformerNamespace(kubernetesNamespaceProvider, discoveryProperties);
|
||||
SharedInformerFactory sharedInformerFactory = new SharedInformerFactory(apiClient);
|
||||
final GenericKubernetesApi<V1Service, V1ServiceList> servicesApi = new GenericKubernetesApi<>(
|
||||
V1Service.class, V1ServiceList.class, "", "v1", "services", apiClient);
|
||||
GenericKubernetesApi<V1Service, V1ServiceList> servicesApi = new GenericKubernetesApi<>(V1Service.class,
|
||||
V1ServiceList.class, "", "v1", "services", apiClient);
|
||||
SharedIndexInformer<V1Service> serviceSharedIndexInformer = sharedInformerFactory
|
||||
.sharedIndexInformerFor(servicesApi, V1Service.class, 0L, namespace);
|
||||
Lister<V1Service> serviceLister = new Lister<>(serviceSharedIndexInformer.getIndexer());
|
||||
final GenericKubernetesApi<V1Endpoints, V1EndpointsList> endpointsApi = new GenericKubernetesApi<>(
|
||||
GenericKubernetesApi<V1Endpoints, V1EndpointsList> endpointsApi = new GenericKubernetesApi<>(
|
||||
V1Endpoints.class, V1EndpointsList.class, "", "v1", "endpoints", apiClient);
|
||||
SharedIndexInformer<V1Endpoints> endpointsSharedIndexInformer = sharedInformerFactory
|
||||
.sharedIndexInformerFor(endpointsApi, V1Endpoints.class, 0L, namespace);
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class KubernetesConfigServerBootstrapper implements BootstrapReg
|
||||
|
||||
public static KubernetesDiscoveryProperties createKubernetesDiscoveryProperties(Binder binder,
|
||||
BindHandler bindHandler) {
|
||||
return binder.bind("spring.cloud.kubernetes.discovery", Bindable.of(KubernetesDiscoveryProperties.class),
|
||||
return binder.bind(KubernetesDiscoveryProperties.PREFIX, Bindable.of(KubernetesDiscoveryProperties.class),
|
||||
bindHandler).orElseGet(() -> KubernetesDiscoveryProperties.DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import static org.springframework.cloud.client.discovery.DiscoveryClient.DEFAULT
|
||||
* have "type: ExternalName" in their spec.
|
||||
*/
|
||||
// @formatter:off
|
||||
@ConfigurationProperties("spring.cloud.kubernetes.discovery")
|
||||
@ConfigurationProperties(KubernetesDiscoveryProperties.PREFIX)
|
||||
public record KubernetesDiscoveryProperties(
|
||||
@DefaultValue("true") boolean enabled, boolean allNamespaces,
|
||||
@DefaultValue Set<String> namespaces,
|
||||
@@ -63,6 +63,11 @@ public record KubernetesDiscoveryProperties(
|
||||
boolean includeExternalNameServices) {
|
||||
// @formatter:on
|
||||
|
||||
/**
|
||||
* Prefix of the properties.
|
||||
*/
|
||||
public static final String PREFIX = "spring.cloud.kubernetes.discovery";
|
||||
|
||||
@ConstructorBinding
|
||||
public KubernetesDiscoveryProperties {
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.springframework.cloud.kubernetes.commons.KubernetesClientProperties;
|
||||
import org.springframework.cloud.kubernetes.commons.config.KubernetesConfigServerBootstrapper;
|
||||
import org.springframework.cloud.kubernetes.commons.config.KubernetesConfigServerInstanceProvider;
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
@@ -42,7 +41,7 @@ class ConfigServerBootstrapper extends KubernetesConfigServerBootstrapper {
|
||||
|
||||
@Override
|
||||
public void initialize(BootstrapRegistry registry) {
|
||||
if (!ClassUtils.isPresent("org.springframework.cloud.config.client.ConfigServerInstanceProvider", null)) {
|
||||
if (hasConfigServerInstanceProvider()) {
|
||||
return;
|
||||
}
|
||||
// We need to pass a lambda here rather than create a new instance of
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.cloud.kubernetes.commons.config.KubernetesConfigServe
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties;
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.ServicePortSecureResolver;
|
||||
import org.springframework.cloud.kubernetes.fabric8.Fabric8AutoConfiguration;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
@@ -44,7 +43,7 @@ class Fabric8ConfigServerBootstrapper extends KubernetesConfigServerBootstrapper
|
||||
|
||||
@Override
|
||||
public void initialize(BootstrapRegistry registry) {
|
||||
if (!ClassUtils.isPresent("org.springframework.cloud.config.client.ConfigServerInstanceProvider", null)) {
|
||||
if (hasConfigServerInstanceProvider()) {
|
||||
return;
|
||||
}
|
||||
// We need to pass a lambda here rather than create a new instance of
|
||||
|
||||
Reference in New Issue
Block a user