Merge branch 'main' of github.com:spring-cloud/spring-cloud-kubernetes
This commit is contained in:
@@ -54,8 +54,8 @@
|
||||
|spring.cloud.kubernetes.config.labels | |
|
||||
|spring.cloud.kubernetes.config.name | |
|
||||
|spring.cloud.kubernetes.config.namespace | |
|
||||
|spring.cloud.kubernetes.config.paths | |
|
||||
|spring.cloud.kubernetes.config.retry.enabled | `+++true+++` |
|
||||
|spring.cloud.kubernetes.config.paths | |
|
||||
|spring.cloud.kubernetes.config.retry.enabled | `+++true+++` |
|
||||
|spring.cloud.kubernetes.config.retry.initial-interval | `+++1000+++` | Initial retry interval in milliseconds.
|
||||
|spring.cloud.kubernetes.config.retry.max-attempts | `+++6+++` | Maximum number of attempts.
|
||||
|spring.cloud.kubernetes.config.retry.max-interval | `+++2000+++` | Maximum interval for backoff.
|
||||
@@ -106,8 +106,8 @@
|
||||
|spring.cloud.kubernetes.secrets.labels | |
|
||||
|spring.cloud.kubernetes.secrets.name | |
|
||||
|spring.cloud.kubernetes.secrets.namespace | |
|
||||
|spring.cloud.kubernetes.secrets.paths | |
|
||||
|spring.cloud.kubernetes.secrets.retry.enabled | `+++true+++` |
|
||||
|spring.cloud.kubernetes.secrets.paths | |
|
||||
|spring.cloud.kubernetes.secrets.retry.enabled | `+++true+++` |
|
||||
|spring.cloud.kubernetes.secrets.retry.initial-interval | `+++1000+++` | Initial retry interval in milliseconds.
|
||||
|spring.cloud.kubernetes.secrets.retry.max-attempts | `+++6+++` | Maximum number of attempts.
|
||||
|spring.cloud.kubernetes.secrets.retry.max-interval | `+++2000+++` | Maximum interval for backoff.
|
||||
@@ -115,4 +115,4 @@
|
||||
|spring.cloud.kubernetes.secrets.sources | |
|
||||
|spring.cloud.kubernetes.secrets.use-name-as-prefix | `+++false+++` |
|
||||
|
||||
|===
|
||||
|===
|
||||
@@ -45,6 +45,10 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.HTTP;
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.HTTPS;
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.PRIMARY_PORT_NAME_LABEL_KEY;
|
||||
|
||||
/**
|
||||
* @author Min Kim
|
||||
* @author Ryan Baxter
|
||||
@@ -54,12 +58,6 @@ public class KubernetesInformerDiscoveryClient implements DiscoveryClient, Initi
|
||||
|
||||
private static final Log log = LogFactory.getLog(KubernetesInformerDiscoveryClient.class);
|
||||
|
||||
private static final String PRIMARY_PORT_NAME_LABEL_KEY = "primary-port-name";
|
||||
|
||||
private static final String HTTPS_PORT_NAME = "https";
|
||||
|
||||
private static final String HTTP_PORT_NAME = "http";
|
||||
|
||||
private final SharedInformerFactory sharedInformerFactory;
|
||||
|
||||
private final Lister<V1Service> serviceLister;
|
||||
@@ -182,7 +180,7 @@ public class KubernetesInformerDiscoveryClient implements DiscoveryClient, Initi
|
||||
// In case no port has been found return -1 to log a warning and fall back to
|
||||
// the first port in the list.
|
||||
int discoveredPort = ports.getOrDefault(primaryPortName,
|
||||
ports.getOrDefault(HTTPS_PORT_NAME, ports.getOrDefault(HTTP_PORT_NAME, -1)));
|
||||
ports.getOrDefault(HTTPS, ports.getOrDefault(HTTP, -1)));
|
||||
|
||||
if (discoveredPort == -1) {
|
||||
if (StringUtils.hasText(primaryPortName)) {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.commons.discovery;
|
||||
|
||||
/**
|
||||
* Constants that are to be used across discovery implementations.
|
||||
*
|
||||
* @author wind57
|
||||
*/
|
||||
public final class KubernetesDiscoveryConstants {
|
||||
|
||||
private KubernetesDiscoveryConstants() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary port label.
|
||||
*/
|
||||
public static final String PRIMARY_PORT_NAME_LABEL_KEY = "primary-port-name";
|
||||
|
||||
/**
|
||||
* Https scheme.
|
||||
*/
|
||||
public static final String HTTPS = "https";
|
||||
|
||||
/**
|
||||
* Http scheme.
|
||||
*/
|
||||
public static final String HTTP = "http";
|
||||
|
||||
/**
|
||||
* Key of the namespace metadata.
|
||||
*/
|
||||
public static final String NAMESPACE_METADATA_KEY = "k8s_namespace";
|
||||
|
||||
}
|
||||
@@ -23,17 +23,12 @@ import java.util.Objects;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.HTTP;
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.HTTPS;
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.NAMESPACE_METADATA_KEY;
|
||||
|
||||
public final class KubernetesServiceInstance implements ServiceInstance {
|
||||
|
||||
/**
|
||||
* Key of the namespace metadata.
|
||||
*/
|
||||
public static final String NAMESPACE_METADATA_KEY = "k8s_namespace";
|
||||
|
||||
private static final String HTTP_PREFIX = "http";
|
||||
|
||||
private static final String HTTPS_PREFIX = "https";
|
||||
|
||||
private String instanceId;
|
||||
|
||||
private String serviceId;
|
||||
@@ -68,7 +63,7 @@ public final class KubernetesServiceInstance implements ServiceInstance {
|
||||
this.port = port;
|
||||
this.metadata = metadata;
|
||||
this.secure = secure;
|
||||
this.uri = createUri(secure ? HTTPS_PREFIX : HTTP_PREFIX, host, port);
|
||||
this.uri = createUri(secure ? HTTPS : HTTP, host, port);
|
||||
this.namespace = null;
|
||||
this.cluster = null;
|
||||
}
|
||||
@@ -91,7 +86,7 @@ public final class KubernetesServiceInstance implements ServiceInstance {
|
||||
this.port = port;
|
||||
this.metadata = metadata;
|
||||
this.secure = secure;
|
||||
this.uri = createUri(secure ? HTTPS_PREFIX : HTTP_PREFIX, host, port);
|
||||
this.uri = createUri(secure ? HTTPS : HTTP, host, port);
|
||||
this.namespace = namespace;
|
||||
this.cluster = cluster;
|
||||
}
|
||||
@@ -136,7 +131,7 @@ public final class KubernetesServiceInstance implements ServiceInstance {
|
||||
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return isSecure() ? HTTPS_PREFIX : HTTP_PREFIX;
|
||||
return isSecure() ? HTTPS : HTTP;
|
||||
}
|
||||
|
||||
private URI createUri(String scheme, String host, int port) {
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2013-2018 the original author or authors.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
@@ -34,7 +17,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-fabric8-autoconfig</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -100,12 +82,6 @@
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<version>${groovy.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-test-support</artifactId>
|
||||
|
||||
@@ -44,7 +44,10 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesServiceInstance.NAMESPACE_METADATA_KEY;
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.HTTP;
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.HTTPS;
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.NAMESPACE_METADATA_KEY;
|
||||
import static org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryConstants.PRIMARY_PORT_NAME_LABEL_KEY;
|
||||
|
||||
/**
|
||||
* Kubernetes implementation of {@link DiscoveryClient}.
|
||||
@@ -56,12 +59,6 @@ public class KubernetesDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
private static final Log log = LogFactory.getLog(KubernetesDiscoveryClient.class);
|
||||
|
||||
private static final String PRIMARY_PORT_NAME_LABEL_KEY = "primary-port-name";
|
||||
|
||||
private static final String HTTPS_PORT_NAME = "https";
|
||||
|
||||
private static final String HTTP_PORT_NAME = "http";
|
||||
|
||||
private final KubernetesDiscoveryProperties properties;
|
||||
|
||||
private final ServicePortSecureResolver servicePortSecureResolver;
|
||||
@@ -231,7 +228,7 @@ public class KubernetesDiscoveryClient implements DiscoveryClient {
|
||||
// In case no port has been found return -1 to log a warning and fall back to
|
||||
// the first port in the list.
|
||||
int discoveredPort = ports.getOrDefault(primaryPortName,
|
||||
ports.getOrDefault(HTTPS_PORT_NAME, ports.getOrDefault(HTTP_PORT_NAME, -1)));
|
||||
ports.getOrDefault(HTTPS, ports.getOrDefault(HTTP, -1)));
|
||||
|
||||
if (discoveredPort == -1) {
|
||||
if (StringUtils.hasText(primaryPortName)) {
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2013-2020 the original author or authors.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
@@ -26,21 +10,13 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-cloud-starter-kubernetes-client</artifactId>
|
||||
<name>Spring Cloud Kubernetes :: Kubernetes Native Starter</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-commons</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-autoconfig</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-client-discovery</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2013-2018 the original author or authors.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
@@ -27,18 +10,9 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-cloud-starter-kubernetes-fabric8</artifactId>
|
||||
<name>Spring Cloud Kubernetes :: Starter</name>
|
||||
<name>Spring Cloud Kubernetes :: Fabric8 Starter</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-commons</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-fabric8-autoconfig</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-kubernetes-fabric8-discovery</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user