Update to fabric8 6.2.0 (#1165)

Co-authored-by: Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com>
This commit is contained in:
erabii
2022-12-07 17:06:08 +02:00
committed by GitHub
parent 411e8a14f7
commit 9862e248e1
44 changed files with 281 additions and 188 deletions

View File

@@ -33,9 +33,8 @@
<description>Spring Cloud Kubernetes Dependencies</description>
<properties>
<hoverfly.version>0.13.0</hoverfly.version>
<kubernetes-fabric8-client.version>5.12.2</kubernetes-fabric8-client.version>
<kubernetes-fabric8-client.version>6.2.0</kubernetes-fabric8-client.version>
<kubernetes-native-client.version>16.0.2</kubernetes-native-client.version>
<istio-client.version>1.7.7.1</istio-client.version>
<wiremock.version>2.26.3</wiremock.version>
<spring-retry.version>1.3.1</spring-retry.version>
<commons.collections4.version>4.4</commons.collections4.version>
@@ -72,12 +71,6 @@
<version>${kubernetes-native-client.version}</version>
</dependency>
<dependency>
<groupId>me.snowdrop</groupId>
<artifactId>istio-client</artifactId>
<version>${istio-client.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>

View File

@@ -20,8 +20,8 @@ import java.time.Duration;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnCloudPlatform;
@@ -107,7 +107,7 @@ public class Fabric8AutoConfiguration {
@Bean
@ConditionalOnMissingBean
public KubernetesClient kubernetesClient(Config config) {
return new DefaultKubernetesClient(config);
return new KubernetesClientBuilder().withConfig(config).build();
}
@Bean

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-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.
@@ -16,7 +16,8 @@
package org.springframework.cloud.kubernetes.fabric8.profile;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.springframework.cloud.kubernetes.commons.profile.AbstractKubernetesProfileEnvironmentPostProcessor;
import org.springframework.cloud.kubernetes.fabric8.Fabric8PodUtils;
@@ -26,7 +27,8 @@ public class Fabric8ProfileEnvironmentPostProcessor extends AbstractKubernetesPr
@Override
protected boolean isInsideKubernetes(Environment environment) {
try (DefaultKubernetesClient client = new DefaultKubernetesClient()) {
try (KubernetesClient client = new KubernetesClientBuilder().build()) {
Fabric8PodUtils podUtils = new Fabric8PodUtils(client);
return environment.containsProperty(Fabric8PodUtils.KUBERNETES_SERVICE_HOST)
|| podUtils.isInsideKubernetes();

View File

@@ -62,11 +62,11 @@ class Fabric8PodUtilsTest {
private final File certFile = Mockito.mock(File.class);
private final MixedOperation<Pod, PodList, PodResource<Pod>> mixed = Mockito.mock(MixedOperation.class);
private final MixedOperation<Pod, PodList, PodResource> mixed = Mockito.mock(MixedOperation.class);
private final Pod pod = Mockito.mock(Pod.class);
private final PodResource<Pod> podResource = Mockito.mock(PodResource.class);
private final PodResource podResource = Mockito.mock(PodResource.class);
private MockedStatic<EnvReader> envReader;

View File

@@ -37,7 +37,7 @@ class Fabric8UserAgentDefaultConfigurationTests {
@Test
void testUserAgent() {
String userAgent = client.getConfiguration().getUserAgent();
assertThat(userAgent).isEqualTo("Spring-Cloud-Kubernetes-Application");
assertThat(userAgent).isEqualTo("fabric8-kubernetes-client/6.2.0");
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2013-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.fabric8;
import io.fabric8.kubernetes.client.KubernetesClient;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* @author wind57
*/
class Fabric8UtilsMockTests {
private final KubernetesClient mockClient = Mockito.mock(KubernetesClient.class);
@Test
void testNamespaceFromClient() {
Mockito.when(mockClient.getNamespace()).thenReturn("qwe");
String result = Fabric8Utils.getApplicationNamespace(mockClient, "", "target", null);
assertThat(result).isEqualTo("qwe");
}
@Test
void testNamespaceResolutionFailed() {
assertThatThrownBy(() -> Fabric8Utils.getApplicationNamespace(mockClient, "", "target", null))
.isInstanceOf(NamespaceResolutionFailedException.class);
}
}

View File

@@ -16,17 +16,14 @@
package org.springframework.cloud.kubernetes.fabric8;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* @author wind57
@@ -36,8 +33,6 @@ class Fabric8UtilsTests {
private KubernetesClient client;
private final DefaultKubernetesClient mockClient = Mockito.mock(DefaultKubernetesClient.class);
private final KubernetesNamespaceProvider provider = Mockito.mock(KubernetesNamespaceProvider.class);
@Test
@@ -65,17 +60,4 @@ class Fabric8UtilsTests {
assertThat(result).isEqualTo("def");
}
@Test
void testNamespaceFromClient() {
Mockito.when(mockClient.getNamespace()).thenReturn("qwe");
String result = Fabric8Utils.getApplicationNamespace(mockClient, "", "target", null);
assertThat(result).isEqualTo("qwe");
}
@Test
void testNamespaceResolutionFailed() {
assertThatThrownBy(() -> Fabric8Utils.getApplicationNamespace(mockClient, "", "target", null))
.isInstanceOf(NamespaceResolutionFailedException.class);
}
}

View File

@@ -25,7 +25,6 @@ import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
import io.fabric8.kubernetes.client.informers.SharedInformer;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.apache.commons.logging.LogFactory;
@@ -104,7 +103,7 @@ public class Fabric8EventBasedConfigMapChangeDetector extends ConfigurationChang
@PreDestroy
private void shutdown() {
informers.forEach(SharedInformer::close);
informers.forEach(SharedIndexInformer::close);
// Ensure the kubernetes client is cleaned up from spare threads when shutting
// down
kubernetesClient.close();

View File

@@ -25,7 +25,6 @@ import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
import io.fabric8.kubernetes.client.informers.SharedInformer;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.apache.commons.logging.LogFactory;
@@ -81,7 +80,7 @@ public class Fabric8EventBasedSecretsChangeDetector extends ConfigurationChangeD
@PreDestroy
private void shutdown() {
informers.forEach(SharedInformer::close);
informers.forEach(SharedIndexInformer::close);
// Ensure the kubernetes client is cleaned up from spare threads when shutting
// down
kubernetesClient.close();

View File

@@ -35,29 +35,29 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Charles Moulliard
*/
@EnableKubernetesMockClient(crud = true, https = false)
public class ConfigMapsTest {
class ConfigMapsTest {
private static KubernetesClient mockClient;
@Test
public void testConfigMapList() {
mockClient.configMaps().inNamespace("ns1")
.create(new ConfigMapBuilder().withNewMetadata().withName("empty").endMetadata().build());
.resource(new ConfigMapBuilder().withNewMetadata().withName("empty").endMetadata().build()).create();
ConfigMapList configMapList = mockClient.configMaps().inNamespace("ns1").list();
assertThat(configMapList).isNotNull();
// metadata is an element
assertThat(configMapList.getItems().size()).isEqualTo(1);
assertThat(configMapList.getItems().get(0).getData()).isNull();
assertThat(configMapList.getItems().get(0).getData()).isEmpty();
}
@Test
public void testConfigMapGet() {
void testConfigMapGet() {
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName("reload-example").endMetadata()
.addToData("KEY", "123").build();
mockClient.configMaps().inNamespace("ns2").create(configMap);
mockClient.configMaps().inNamespace("ns2").resource(configMap).create();
ConfigMapList configMapList = mockClient.configMaps().inNamespace("ns2").list();
assertThat(configMapList).isNotNull();
@@ -68,13 +68,13 @@ public class ConfigMapsTest {
}
@Test
public void testConfigMapFromSingleApplicationProperties() {
void testConfigMapFromSingleApplicationProperties() {
String configMapName = "app-properties-test";
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName(configMapName).endMetadata()
.addToData("application.properties", ConfigMapTestUtil.readResourceFile("application.properties"))
.build();
mockClient.configMaps().inNamespace("test").create(configMap);
mockClient.configMaps().inNamespace("test").resource(configMap).create();
NormalizedSource source = new NamedConfigMapNormalizedSource(configMapName, "test", false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "", new MockEnvironment());
@@ -86,12 +86,12 @@ public class ConfigMapsTest {
}
@Test
public void testConfigMapFromSingleApplicationYaml() {
void testConfigMapFromSingleApplicationYaml() {
String configMapName = "app-yaml-test";
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName(configMapName).endMetadata()
.addToData("application.yaml", ConfigMapTestUtil.readResourceFile("application.yaml")).build();
mockClient.configMaps().inNamespace("test").create(configMap);
mockClient.configMaps().inNamespace("test").resource(configMap).create();
NormalizedSource source = new NamedConfigMapNormalizedSource(configMapName, "test", false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "", new MockEnvironment());
@@ -103,12 +103,12 @@ public class ConfigMapsTest {
}
@Test
public void testConfigMapFromSingleNonStandardFileName() {
void testConfigMapFromSingleNonStandardFileName() {
String configMapName = "single-non-standard-test";
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName(configMapName).endMetadata()
.addToData("adhoc.yml", ConfigMapTestUtil.readResourceFile("adhoc.yml")).build();
mockClient.configMaps().inNamespace("test").create(configMap);
mockClient.configMaps().inNamespace("test").resource(configMap).create();
NormalizedSource source = new NamedConfigMapNormalizedSource(configMapName, "test", false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "", new MockEnvironment());
@@ -120,12 +120,12 @@ public class ConfigMapsTest {
}
@Test
public void testConfigMapFromSingleInvalidPropertiesContent() {
void testConfigMapFromSingleInvalidPropertiesContent() {
String configMapName = "single-unparseable-properties-test";
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName(configMapName).endMetadata()
.addToData("application.properties", "somevalue").build();
mockClient.configMaps().inNamespace("test").create(configMap);
mockClient.configMaps().inNamespace("test").resource(configMap).create();
NormalizedSource source = new NamedConfigMapNormalizedSource(configMapName, "namespace", false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "", new MockEnvironment());
@@ -135,12 +135,12 @@ public class ConfigMapsTest {
}
@Test
public void testConfigMapFromSingleInvalidYamlContent() {
void testConfigMapFromSingleInvalidYamlContent() {
String configMapName = "single-unparseable-yaml-test";
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName(configMapName).endMetadata()
.addToData("application.yaml", "somevalue").build();
mockClient.configMaps().inNamespace("test").create(configMap);
mockClient.configMaps().inNamespace("test").resource(configMap).create();
NormalizedSource source = new NamedConfigMapNormalizedSource(configMapName, "namespace", false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "", new MockEnvironment());
@@ -150,13 +150,13 @@ public class ConfigMapsTest {
}
@Test
public void testConfigMapFromMultipleApplicationProperties() {
void testConfigMapFromMultipleApplicationProperties() {
String configMapName = "app-multiple-properties-test";
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName(configMapName).endMetadata()
.addToData("application.properties", ConfigMapTestUtil.readResourceFile("application.properties"))
.addToData("adhoc.properties", ConfigMapTestUtil.readResourceFile("adhoc.properties")).build();
mockClient.configMaps().inNamespace("test").create(configMap);
mockClient.configMaps().inNamespace("test").resource(configMap).create();
NormalizedSource source = new NamedConfigMapNormalizedSource(configMapName, "test", false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "", new MockEnvironment());

View File

@@ -0,0 +1,60 @@
/*
* Copyright 2013-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.fabric8.config;
import java.util.List;
import java.util.Map;
import io.fabric8.kubernetes.client.KubernetesClient;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties;
import org.springframework.cloud.kubernetes.commons.config.ConfigUtils;
import org.springframework.cloud.kubernetes.commons.config.NamedConfigMapNormalizedSource;
import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException;
import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
import org.springframework.cloud.kubernetes.commons.config.RetryProperties;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* @author wind57
*/
class Fabric8ConfigMapPropertySourceLocatorMockTests {
private final KubernetesClient client = Mockito.mock(KubernetesClient.class);
private static final ConfigUtils.Prefix PREFIX = ConfigUtils.findPrefix("prefix", false, false, "irrelevant");
@Test
void constructorWithoutClientNamespaceMustFail() {
ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(),
Map.of(), true, "name", null, false, true, false, RetryProperties.DEFAULT);
Mockito.when(client.getNamespace()).thenReturn(null);
Fabric8ConfigMapPropertySourceLocator source = new Fabric8ConfigMapPropertySourceLocator(client,
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
NormalizedSource normalizedSource = new NamedConfigMapNormalizedSource("name", null, false, PREFIX, false);
assertThatThrownBy(() -> source.getMapPropertySource(normalizedSource, new MockEnvironment()))
.isInstanceOf(NamespaceResolutionFailedException.class);
}
}

View File

@@ -19,19 +19,13 @@ package org.springframework.cloud.kubernetes.fabric8.config;
import java.util.List;
import java.util.Map;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties;
import org.springframework.cloud.kubernetes.commons.config.ConfigUtils;
import org.springframework.cloud.kubernetes.commons.config.NamedConfigMapNormalizedSource;
import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException;
import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
import org.springframework.cloud.kubernetes.commons.config.RetryProperties;
import org.springframework.mock.env.MockEnvironment;
@@ -48,10 +42,6 @@ class Fabric8ConfigMapPropertySourceLocatorTests {
private KubernetesClient mockClient;
private final DefaultKubernetesClient client = Mockito.mock(DefaultKubernetesClient.class);
private static final ConfigUtils.Prefix PREFIX = ConfigUtils.findPrefix("prefix", false, false, "irrelevant");
@Test
void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
String name = "my-config";
@@ -87,18 +77,4 @@ class Fabric8ConfigMapPropertySourceLocatorTests {
assertThatNoException().isThrownBy(() -> locator.locate(new MockEnvironment()));
}
@Test
void constructorWithoutClientNamespaceMustFail() {
ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(),
Map.of(), true, "name", null, false, true, false, RetryProperties.DEFAULT);
Mockito.when(client.getNamespace()).thenReturn(null);
Fabric8ConfigMapPropertySourceLocator source = new Fabric8ConfigMapPropertySourceLocator(client,
configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment()));
NormalizedSource normalizedSource = new NamedConfigMapNormalizedSource("name", null, false, PREFIX, false);
assertThatThrownBy(() -> source.getMapPropertySource(normalizedSource, new MockEnvironment()))
.isInstanceOf(NamespaceResolutionFailedException.class);
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright 2013-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.fabric8.config;
import io.fabric8.kubernetes.client.KubernetesClient;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.cloud.kubernetes.commons.config.NamedConfigMapNormalizedSource;
import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author wind57
*/
class Fabric8ConfigMapPropertySourceMockTests {
private final KubernetesClient client = Mockito.mock(KubernetesClient.class);
@Test
void constructorWithClientNamespaceMustNotFail() {
Mockito.when(client.getNamespace()).thenReturn("namespace");
NormalizedSource source = new NamedConfigMapNormalizedSource("configmap", null, false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(client, source, "", new MockEnvironment());
assertThat(new Fabric8ConfigMapPropertySource(context)).isNotNull();
}
@Test
void constructorWithNamespaceMustNotFail() {
Mockito.when(client.getNamespace()).thenReturn(null);
NormalizedSource source = new NamedConfigMapNormalizedSource("configMap", null, false, true);
Fabric8ConfigContext context = new Fabric8ConfigContext(client, source, "", new MockEnvironment());
assertThat(new Fabric8ConfigMapPropertySource(context)).isNotNull();
}
}

View File

@@ -16,19 +16,16 @@
package org.springframework.cloud.kubernetes.fabric8.config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.cloud.kubernetes.commons.config.ConfigUtils;
import org.springframework.cloud.kubernetes.commons.config.NamedConfigMapNormalizedSource;
import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -42,15 +39,13 @@ class Fabric8ConfigMapPropertySourceTests {
private KubernetesClient mockClient;
private final DefaultKubernetesClient client = Mockito.mock(DefaultKubernetesClient.class);
private static final ConfigUtils.Prefix DEFAULT = ConfigUtils.findPrefix("default", false, false, "irrelevant");
@Test
void constructorShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
final String name = "my-config";
final String namespace = "default";
final String path = String.format("/api/v1/namespaces/%s/configmaps", namespace);
String name = "my-config";
String namespace = "default";
String path = String.format("/api/v1/namespaces/%s/configmaps", namespace);
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
NormalizedSource source = new NamedConfigMapNormalizedSource(name, namespace, true, DEFAULT, true);
@@ -61,9 +56,9 @@ class Fabric8ConfigMapPropertySourceTests {
@Test
void constructorShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
final String name = "my-config";
final String namespace = "default";
final String path = String.format("/api/v1/namespaces/%s/configmaps/%s", namespace, name);
String name = "my-config";
String namespace = "default";
String path = String.format("/api/v1/namespaces/%s/configmaps/%s", namespace, name);
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once();
NormalizedSource source = new NamedConfigMapNormalizedSource(name, namespace, false, false);
@@ -71,22 +66,4 @@ class Fabric8ConfigMapPropertySourceTests {
assertThatNoException().isThrownBy(() -> new Fabric8ConfigMapPropertySource(context));
}
@Test
void constructorWithClientNamespaceMustNotFail() {
Mockito.when(client.getNamespace()).thenReturn("namespace");
NormalizedSource source = new NamedConfigMapNormalizedSource("configmap", null, false, false);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "", new MockEnvironment());
assertThat(new Fabric8ConfigMapPropertySource(context)).isNotNull();
}
@Test
void constructorWithNamespaceMustNotFail() {
Mockito.when(client.getNamespace()).thenReturn(null);
NormalizedSource source = new NamedConfigMapNormalizedSource("configMap", null, false, true);
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, source, "", new MockEnvironment());
assertThat(new Fabric8ConfigMapPropertySource(context)).isNotNull();
}
}

View File

@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-kubernetes-fabric8-discovery</artifactId>
<name>Spring Cloud Kubernetes :: Discovery</name>
<name>Spring Cloud Kubernetes :: Fabric8 Discovery</name>
<dependencies>

View File

@@ -47,20 +47,20 @@ final class Fabric8EndpointSliceV1CatalogWatch
if (context.properties().allNamespaces()) {
LOG.debug(() -> "discovering endpoints in all namespaces");
try (KubernetesClient client = context.kubernetesClient()) {
endpointSlices = client.discovery().v1().endpointSlices().inAnyNamespace()
.withLabels(context.properties().serviceLabels()).list().getItems();
}
// can't use try with resources here as it will close the client
KubernetesClient client = context.kubernetesClient();
endpointSlices = client.discovery().v1().endpointSlices().inAnyNamespace()
.withLabels(context.properties().serviceLabels()).list().getItems();
}
else {
String namespace = Fabric8Utils.getApplicationNamespace(context.kubernetesClient(), null, "catalog-watcher",
context.namespaceProvider());
LOG.debug(() -> "fabric8 catalog watcher will use namespace : " + namespace);
try (KubernetesClient client = context.kubernetesClient()) {
endpointSlices = client.discovery().v1().endpointSlices().inNamespace(namespace)
.withLabels(context.properties().serviceLabels()).list().getItems();
}
// can't use try with resources here as it will close the client
KubernetesClient client = context.kubernetesClient();
endpointSlices = client.discovery().v1().endpointSlices().inNamespace(namespace)
.withLabels(context.properties().serviceLabels()).list().getItems();
}
Stream<ObjectReference> references = endpointSlices.stream().map(EndpointSlice::getEndpoints)

View File

@@ -49,20 +49,20 @@ final class Fabric8EndpointsCatalogWatch
if (context.properties().allNamespaces()) {
LOG.debug(() -> "discovering endpoints in all namespaces");
try (KubernetesClient client = context.kubernetesClient()) {
endpoints = client.endpoints().inAnyNamespace().withLabels(context.properties().serviceLabels()).list()
.getItems();
}
// can't use try with resources here as it will close the client
KubernetesClient client = context.kubernetesClient();
endpoints = client.endpoints().inAnyNamespace().withLabels(context.properties().serviceLabels()).list()
.getItems();
}
else {
String namespace = Fabric8Utils.getApplicationNamespace(context.kubernetesClient(), null, "catalog-watcher",
context.namespaceProvider());
LOG.debug(() -> "fabric8 catalog watcher will use namespace : " + namespace);
try (KubernetesClient client = context.kubernetesClient()) {
endpoints = client.endpoints().inNamespace(namespace).withLabels(context.properties().serviceLabels())
.list().getItems();
}
// can't use try with resources here as it will close the client
KubernetesClient client = context.kubernetesClient();
endpoints = client.endpoints().inNamespace(namespace).withLabels(context.properties().serviceLabels())
.list().getItems();
}
/**

View File

@@ -86,20 +86,20 @@ public class KubernetesCatalogWatch implements ApplicationEventPublisherAware {
void postConstruct() {
if (context.properties().useEndpointSlices()) {
try (KubernetesClient client = context.kubernetesClient()) {
// this emulates : 'kubectl api-resources | grep -i EndpointSlice'
boolean found = client.getApiGroups().getGroups().stream().flatMap(x -> x.getVersions().stream())
.map(GroupVersionForDiscovery::getGroupVersion).filter(DISCOVERY_GROUP_VERSION::equals)
.findFirst().map(client::getApiResources).map(APIResourceList::getResources)
.map(x -> x.stream().map(APIResource::getKind))
.flatMap(x -> x.filter(y -> y.equals(ENDPOINT_SLICE)).findFirst()).isPresent();
// can't use try with resources here as it will close the client
KubernetesClient client = context.kubernetesClient();
// this emulates : 'kubectl api-resources | grep -i EndpointSlice'
boolean found = client.getApiGroups().getGroups().stream().flatMap(x -> x.getVersions().stream())
.map(GroupVersionForDiscovery::getGroupVersion).filter(DISCOVERY_GROUP_VERSION::equals).findFirst()
.map(client::getApiResources).map(APIResourceList::getResources)
.map(x -> x.stream().map(APIResource::getKind))
.flatMap(x -> x.filter(y -> y.equals(ENDPOINT_SLICE)).findFirst()).isPresent();
if (!found) {
throw new IllegalArgumentException("EndpointSlices are not supported on the cluster");
}
else {
stateGenerator = new Fabric8EndpointSliceV1CatalogWatch();
}
if (!found) {
throw new IllegalArgumentException("EndpointSlices are not supported on the cluster");
}
else {
stateGenerator = new Fabric8EndpointSliceV1CatalogWatch();
}
}
else {

View File

@@ -22,6 +22,7 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServiceList;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
import io.fabric8.kubernetes.client.dsl.ServiceResource;
/**
* A regular java.util.function that is used to hide the complexity of the
@@ -42,6 +43,6 @@ import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
* @author Georgios Andrianakis
*/
public interface KubernetesClientServicesFunction
extends Function<KubernetesClient, FilterWatchListDeletable<Service, ServiceList>> {
extends Function<KubernetesClient, FilterWatchListDeletable<Service, ServiceList, ServiceResource<Service>>> {
}

View File

@@ -88,6 +88,7 @@ class Fabric8KubernetesCatalogWatchEndpointSlicesTests {
System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false");
System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test");
System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true");
}
@AfterEach
@@ -120,7 +121,7 @@ class Fabric8KubernetesCatalogWatchEndpointSlicesTests {
mockServer.expect()
.withPath("/apis/discovery.k8s.io/v1/namespaces/namespaceA/endpointslices?labelSelector=color%3Dblue")
.andReturn(200, listInNamespaceA).once();
.andReturn(200, listInNamespaceA).always();
// this is mocked, but never supposed to be called
EndpointSlice sliceD = createSingleEndpointWithEndpointSlices("namespaceB", Map.of("color", "blue"), "podD");

View File

@@ -70,7 +70,7 @@ class KubernetesCatalogWatchTest {
private static final NonNamespaceOperation<Endpoints, EndpointsList, Resource<Endpoints>> NON_NAMESPACE_OPERATION = Mockito
.mock(NonNamespaceOperation.class);
private static final FilterWatchListDeletable<Endpoints, EndpointsList> FILTER_WATCH_LIST_DELETABLE = Mockito
private static final FilterWatchListDeletable<Endpoints, EndpointsList, Resource<Endpoints>> FILTER_WATCH_LIST_DELETABLE = Mockito
.mock(FilterWatchListDeletable.class);
private static final ArgumentCaptor<HeartbeatEvent> HEARTBEAT_EVENT_ARGUMENT_CAPTOR = ArgumentCaptor

View File

@@ -72,7 +72,7 @@ public class KubernetesDiscoveryClientFilterMetadataTest {
private ServiceResource<Service> serviceResource;
@Mock
FilterWatchListDeletable<Endpoints, EndpointsList> filter;
FilterWatchListDeletable<Endpoints, EndpointsList, Resource<Endpoints>> filter;
@Test
public void testAllExtraMetadataDisabled() {

View File

@@ -26,7 +26,7 @@
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>me.snowdrop</groupId>
<groupId>io.fabric8</groupId>
<artifactId>istio-client</artifactId>
</dependency>
<dependency>

View File

@@ -16,9 +16,9 @@
package org.springframework.cloud.kubernetes.fabric8.istio;
import io.fabric8.istio.client.DefaultIstioClient;
import io.fabric8.istio.client.IstioClient;
import io.fabric8.kubernetes.client.Config;
import me.snowdrop.istio.client.DefaultIstioClient;
import me.snowdrop.istio.client.IstioClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnCloudPlatform;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;

View File

@@ -16,7 +16,7 @@
package org.springframework.cloud.kubernetes.fabric8.istio;
import me.snowdrop.istio.client.IstioClient;
import io.fabric8.istio.client.IstioClient;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -16,7 +16,7 @@
package org.springframework.cloud.kubernetes.fabric8.istio;
import me.snowdrop.istio.client.IstioClient;
import io.fabric8.istio.client.IstioClient;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -16,7 +16,7 @@
package org.springframework.cloud.kubernetes.fabric8.istio;
import me.snowdrop.istio.client.IstioClient;
import io.fabric8.istio.client.IstioClient;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -16,7 +16,7 @@
package org.springframework.cloud.kubernetes.fabric8.istio;
import me.snowdrop.istio.client.IstioClient;
import io.fabric8.istio.client.IstioClient;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -22,7 +22,7 @@ import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
import io.fabric8.kubernetes.client.dsl.PodResource;
import io.fabric8.kubernetes.client.internal.readiness.Readiness;
import io.fabric8.kubernetes.client.readiness.Readiness;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +60,7 @@ public class Fabric8PodReadinessWatcher implements PodReadinessWatcher, Watcher<
synchronized (this.lock) {
if (this.watch == null) {
LOGGER.debug("Starting pod readiness watcher for '{}'", this.podName);
PodResource<Pod> podResource = this.kubernetesClient.pods().withName(this.podName);
PodResource podResource = this.kubernetesClient.pods().withName(this.podName);
this.previousState = podResource.isReady();
this.watch = podResource.watch(this);
}

View File

@@ -50,10 +50,10 @@ public class Fabric8PodReadinessWatcherTest {
private KubernetesClient mockKubernetesClient;
@Mock
private MixedOperation<Pod, PodList, PodResource<Pod>> mockPodsOperation;
private MixedOperation<Pod, PodList, PodResource> mockPodsOperation;
@Mock
private PodResource<Pod> mockPodResource;
private PodResource mockPodResource;
@Mock
private Pod mockPod;

View File

@@ -115,7 +115,7 @@ class Fabric8ServiceInstanceMapperTests {
private Service buildService(String name, String uid, List<ServicePort> ports, Map<String, String> labels,
Map<String, String> annotations) {
return new ServiceBuilder().withNewMetadata().withName(name).withNewUid(uid).addToLabels(labels)
return new ServiceBuilder().withNewMetadata().withName(name).withUid(uid).addToLabels(labels)
.withAnnotations(annotations).endMetadata().withNewSpec().addAllToPorts(ports).endSpec().build();
}

View File

@@ -24,7 +24,7 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServiceBuilder;
import io.fabric8.kubernetes.api.model.ServiceList;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.FilterWatchListMultiDeletable;
import io.fabric8.kubernetes.client.dsl.AnyNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.ServiceResource;
@@ -65,7 +65,7 @@ class KubernetesServiceListSupplierTests {
ServiceResource<Service> serviceResource;
@Mock
FilterWatchListMultiDeletable<Service, ServiceList> multiDeletable;
AnyNamespaceOperation<Service, ServiceList, ServiceResource<Service>> multiDeletable;
@Test
void testPositiveMatch() {

View File

@@ -190,7 +190,8 @@ class ConfigurationWatcherMultipleAppIT {
.getImage().split(":");
Commons.pullImage(image[0], image[1], K3S);
Commons.loadImage(image[0], image[1], "rabbitmq", K3S);
api.createNamespacedReplicationController(NAMESPACE, getRabbitMQReplicationController(), null, null, null, null);
api.createNamespacedReplicationController(NAMESPACE, getRabbitMQReplicationController(), null, null, null,
null);
}
private V1ReplicationController getRabbitMQReplicationController() throws Exception {

View File

@@ -25,8 +25,8 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -76,7 +76,7 @@ class CatalogWatchIT {
static void beforeAll() throws Exception {
K3S.start();
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
Commons.validateImage(APP_NAME, K3S);
Commons.loadSpringCloudKubernetesImage(APP_NAME, K3S);

View File

@@ -31,9 +31,9 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.base.HasMetadataOperation;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperation;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -84,7 +84,7 @@ class ConfigMapEventReloadIT {
Commons.validateImage(IMAGE_NAME, K3S);
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
createNamespaces();
Fabric8Utils.setUpClusterWide(client, "default", Set.of("left", "right"));

View File

@@ -28,9 +28,9 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.base.HasMetadataOperation;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperation;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -76,7 +76,7 @@ class ConfigMapPollingReloadIT {
Commons.validateImage(IMAGE_NAME, K3S);
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
Fabric8Utils.setUp(client, NAMESPACE);
deployManifests();
}
@@ -106,9 +106,9 @@ class ConfigMapPollingReloadIT {
// the weird cast comes from :
// https://github.com/fabric8io/kubernetes-client/issues/2445
((HasMetadataOperation) client.configMaps().inNamespace("default").withName("poll-reload"))
.createOrReplace(map);
.resource(map).createOrReplace();
await().timeout(Duration.ofSeconds(30)).until(() -> webClient.method(HttpMethod.GET).retrieve()
await().timeout(Duration.ofSeconds(60)).until(() -> webClient.method(HttpMethod.GET).retrieve()
.bodyToMono(String.class).retryWhen(retrySpec()).block().equals("after-change"));
}
@@ -135,7 +135,7 @@ class ConfigMapPollingReloadIT {
ConfigMap configMap = client.configMaps().load(getConfigMap()).get();
configMapName = configMap.getMetadata().getName();
client.configMaps().create(configMap);
client.configMaps().resource(configMap).create();
Deployment deployment = client.apps().deployments().load(getDeployment()).get();
@@ -148,11 +148,11 @@ class ConfigMapPollingReloadIT {
Service service = client.services().load(getService()).get();
serviceName = service.getMetadata().getName();
client.services().inNamespace(NAMESPACE).create(service);
client.services().inNamespace(NAMESPACE).resource(service).create();
Ingress ingress = client.network().v1().ingresses().load(getIngress()).get();
ingressName = ingress.getMetadata().getName();
client.network().v1().ingresses().inNamespace(NAMESPACE).create(ingress);
client.network().v1().ingresses().inNamespace(NAMESPACE).resource(ingress).create();
Fabric8Utils.waitForDeployment(client,
"spring-cloud-kubernetes-fabric8-client-configmap-deployment-polling-reload", NAMESPACE, 2, 600);

View File

@@ -25,8 +25,8 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -67,7 +67,7 @@ class Fabric8ConfigMapIT {
Commons.validateImage(IMAGE_NAME, K3S);
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
Fabric8Utils.setUp(client, NAMESPACE);
deployManifests();
}

View File

@@ -25,8 +25,8 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -75,7 +75,7 @@ class Fabric8DiscoveryIT {
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
Fabric8Utils.setUp(client, NAMESPACE);
deployManifests();

View File

@@ -29,8 +29,8 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -84,7 +84,7 @@ class Fabric8DiscoveryNamespaceFilterIT {
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
Fabric8Utils.setUp(client, NAMESPACE);
deployManifests();

View File

@@ -25,8 +25,8 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
@@ -78,7 +78,7 @@ public class Fabric8ClientLoadbalancerIT {
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
Fabric8Utils.setUp(client, NAMESPACE);
}

View File

@@ -29,9 +29,9 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.base.HasMetadataOperation;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperation;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -77,7 +77,7 @@ class SecretsEventsReloadIT {
Commons.validateImage(IMAGE_NAME, K3S);
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
Fabric8Utils.setUp(client, NAMESPACE);
deployManifests();
}

View File

@@ -24,8 +24,8 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -68,7 +68,7 @@ class SimpleCoreIT {
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
Fabric8Utils.setUp(client, NAMESPACE);
deployManifests();

View File

@@ -19,7 +19,7 @@ package org.springframework.cloud.kubernetes.fabric8.istio;
import java.util.Arrays;
import java.util.List;
import me.snowdrop.istio.client.IstioClient;
import io.fabric8.istio.client.IstioClient;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;

View File

@@ -26,8 +26,8 @@ import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -104,7 +104,7 @@ class Fabric8IstioIT {
}
Config config = Config.fromKubeconfig(K3S.getKubeConfigYaml());
client = new DefaultKubernetesClient(config);
client = new KubernetesClientBuilder().withConfig(config).build();
Fabric8Utils.setUpIstio(client, NAMESPACE);
deployManifests();