Merge branch '3.1.x' into refactor_k8s_client_reload

This commit is contained in:
wind57
2025-03-28 11:27:58 +02:00
6 changed files with 17 additions and 15 deletions

View File

@@ -30,7 +30,7 @@ NOTE: If you set `spring.cloud.kubernetes.configserver.config-map-namespaces` an
you will need to include the namespace in which the Config Server is deployed in order to continue to fetch Config Map and Secret data from that namespace.
### Using Advanced Features Of Spring Vault
In order to use some of the [more advanced Spring Vault features](https://docs.spring.io/spring-cloud-config/reference/server/environment-repository/vault-backend.html) of the **Spring Cloud Config Server**, [`spring-vault-core`](https://mvnrepository.com/artifact/org.springframework.vault/spring-vault-core) must be on the classpath. By default, Spring Cloud Kubernetes can generate a Docker image for deploying Config Server to Kubernetes, but it does not include `spring-vault-core` in the classpath. If you need `spring-core-vault` to enable certain functionality in the Config Server you can build your own version of Docker image by enabling the `vault` Maven profile when running Maven build.
In order to use some of the https://docs.spring.io/spring-cloud-config/reference/server/environment-repository/vault-backend.html[more advanced Spring Vault features] of the **Spring Cloud Config Server**, https://mvnrepository.com/artifact/org.springframework.vault/spring-vault-core[`spring-vault-core`] must be on the classpath. By default, Spring Cloud Kubernetes can generate a Docker image for deploying Config Server to Kubernetes, but it does not include `spring-vault-core` in the classpath. If you need `spring-vault-core` to enable certain functionality in the Config Server you can build your own version of Docker image by enabling the `vault` Maven profile when running Maven build.
Example:
```bash

View File

@@ -5,6 +5,6 @@
"@antora/collector-extension": "1.0.1",
"@asciidoctor/tabs": "1.0.0-beta.6",
"@springio/antora-extensions": "1.14.4",
"@springio/asciidoctor-extensions": "1.0.0-alpha.16"
"@springio/asciidoctor-extensions": "1.0.0-alpha.17"
}
}

View File

@@ -48,7 +48,7 @@ record KubernetesCatalogWatchContext(CoreV1Api coreV1Api, ApiClient apiClient, K
}
static String labelSelector(Map<String, String> labels) {
return labels.entrySet().stream().map(en -> en.getKey() + "=" + en.getValue()).collect(Collectors.joining("&"));
return labels.entrySet().stream().map(en -> en.getKey() + "=" + en.getValue()).collect(Collectors.joining(","));
}
}

View File

@@ -16,6 +16,7 @@
package org.springframework.cloud.kubernetes.client.discovery.catalog;
import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
@@ -40,10 +41,11 @@ class KubernetesCatalogWatchContextTests {
@Test
void multipleLabelsLabel() {
String result = KubernetesCatalogWatchContext.labelSelector(Map.of("a", "b", "c", "d"));
Assertions.assertTrue(result.contains("c=d"));
Assertions.assertTrue(result.contains("&"));
Assertions.assertTrue(result.contains("a=b"));
Map<String, String> labels = new LinkedHashMap<>();
labels.put("a", "b");
labels.put("c", "d");
String result = KubernetesCatalogWatchContext.labelSelector(labels);
Assertions.assertEquals("a=b,c=d", result);
}
}

View File

@@ -96,7 +96,7 @@ class KubernetesCatalogWatchEndpointSlicesTests extends KubernetesEndpointsAndEn
@Test
@Override
void testInAllNamespacesWithDoubleLabel() {
stubFor(get("/apis/discovery.k8s.io/v1/endpointslices?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/apis/discovery.k8s.io/v1/endpointslices?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("a", "default")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();
@@ -137,9 +137,9 @@ class KubernetesCatalogWatchEndpointSlicesTests extends KubernetesEndpointsAndEn
@Test
@Override
void testInSpecificNamespacesWithDoubleLabel() {
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/one/endpointslices?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/one/endpointslices?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("aa", "a")))));
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/two/endpointslices?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/two/endpointslices?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("bb", "b")))));
// otherwise the stub might fail
@@ -179,7 +179,7 @@ class KubernetesCatalogWatchEndpointSlicesTests extends KubernetesEndpointsAndEn
@Test
@Override
void testInOneNamespaceWithDoubleLabel() {
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/b/endpointslices?labelSelector=key%3Dvalue%26key1%3Dvalue1")
stubFor(get("/apis/discovery.k8s.io/v1/namespaces/b/endpointslices?labelSelector=key%3Dvalue%2Ckey1%3Dvalue1")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpointSlices("a", "b")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();

View File

@@ -96,7 +96,7 @@ class KubernetesCatalogWatchEndpointsTests extends KubernetesEndpointsAndEndpoin
@Test
@Override
void testInAllNamespacesWithDoubleLabel() {
stubFor(get("/api/v1/endpoints?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/api/v1/endpoints?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("a", "default")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();
@@ -137,9 +137,9 @@ class KubernetesCatalogWatchEndpointsTests extends KubernetesEndpointsAndEndpoin
@Test
@Override
void testInSpecificNamespacesWithDoubleLabel() {
stubFor(get("/api/v1/namespaces/one/endpoints?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/api/v1/namespaces/one/endpoints?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("aa", "a")))));
stubFor(get("/api/v1/namespaces/two/endpoints?labelSelector=a%3Db%26c%3Dd")
stubFor(get("/api/v1/namespaces/two/endpoints?labelSelector=a%3Db%2Cc%3Dd")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("bb", "b")))));
// otherwise the stub might fail
@@ -179,7 +179,7 @@ class KubernetesCatalogWatchEndpointsTests extends KubernetesEndpointsAndEndpoin
@Test
@Override
void testInOneNamespaceWithDoubleLabel() {
stubFor(get("/api/v1/namespaces/b/endpoints?labelSelector=key%3Dvalue%26key1%3Dvalue1")
stubFor(get("/api/v1/namespaces/b/endpoints?labelSelector=key%3Dvalue%2Ckey1%3Dvalue1")
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(endpoints("a", "b")))));
// otherwise the stub might fail
LinkedHashMap<String, String> map = new LinkedHashMap<>();