diff --git a/extensions/container-image/container-image-openshift/deployment/pom.xml b/extensions/container-image/container-image-openshift/deployment/pom.xml index c101061d05f68..0403d9e816c39 100644 --- a/extensions/container-image/container-image-openshift/deployment/pom.xml +++ b/extensions/container-image/container-image-openshift/deployment/pom.xml @@ -55,6 +55,10 @@ com.sun tools + + io.fabric8 + kubernetes-client + diff --git a/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java b/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java index 256a45aec62a1..00236e4da2849 100644 --- a/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java +++ b/extensions/container-image/container-image-openshift/deployment/src/main/java/io/quarkus/container/image/openshift/deployment/OpenshiftProcessor.java @@ -231,7 +231,7 @@ public void openshiftRequirementsNative(OpenshiftConfig openshiftConfig, public void openshiftBuildFromJar(OpenshiftConfig openshiftConfig, S2iConfig s2iConfig, ContainerImageConfig containerImageConfig, - KubernetesClientBuildItem kubernetesClient, + KubernetesClientBuildItem kubernetesClientSupplier, ContainerImageInfoBuildItem containerImage, ArchiveRootBuildItem archiveRoot, OutputTargetBuildItem out, PackageConfig packageConfig, List generatedResources, @@ -263,26 +263,28 @@ public void openshiftBuildFromJar(OpenshiftConfig openshiftConfig, return; } - String namespace = Optional.ofNullable(kubernetesClient.getClient().getNamespace()).orElse("default"); - LOG.info("Starting (in-cluster) container image build for jar using: " + config.buildStrategy + " on server: " - + kubernetesClient.getClient().getMasterUrl() + " in namespace:" + namespace + "."); - //The contextRoot is where inside the tarball we will add the jars. A null value means everything will be added under '/' while "target" means everything will be added under '/target'. - //For docker kind of builds where we use instructions like: `COPY target/*.jar /deployments` it using '/target' is a requirement. - //For s2i kind of builds where jars are expected directly in the '/' we have to use null. - String outputDirName = out.getOutputDirectory().getFileName().toString(); - String contextRoot = getContextRoot(outputDirName, packageConfig.isFastJar(), config.buildStrategy); - if (packageConfig.isFastJar()) { - createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, jar.getPath().getParent(), - jar.getPath().getParent()); - } else if (jar.getLibraryDir() != null) { //When using uber-jar the libraryDir is going to be null, potentially causing NPE. - createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, jar.getPath().getParent(), - jar.getPath(), jar.getLibraryDir()); - } else { - createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, jar.getPath().getParent(), - jar.getPath()); + try (KubernetesClient kubernetesClient = kubernetesClientSupplier.getClient().get()) { + String namespace = Optional.ofNullable(kubernetesClient.getNamespace()).orElse("default"); + LOG.info("Starting (in-cluster) container image build for jar using: " + config.buildStrategy + " on server: " + + kubernetesClient.getMasterUrl() + " in namespace:" + namespace + "."); + //The contextRoot is where inside the tarball we will add the jars. A null value means everything will be added under '/' while "target" means everything will be added under '/target'. + //For docker kind of builds where we use instructions like: `COPY target/*.jar /deployments` it using '/target' is a requirement. + //For s2i kind of builds where jars are expected directly in the '/' we have to use null. + String outputDirName = out.getOutputDirectory().getFileName().toString(); + String contextRoot = getContextRoot(outputDirName, packageConfig.isFastJar(), config.buildStrategy); + if (packageConfig.isFastJar()) { + createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, jar.getPath().getParent(), + jar.getPath().getParent()); + } else if (jar.getLibraryDir() != null) { //When using uber-jar the libraryDir is going to be null, potentially causing NPE. + createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, jar.getPath().getParent(), + jar.getPath(), jar.getLibraryDir()); + } else { + createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, jar.getPath().getParent(), + jar.getPath()); + } + artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Collections.emptyMap())); + containerImageBuilder.produce(new ContainerImageBuilderBuildItem(OPENSHIFT)); } - artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Collections.emptyMap())); - containerImageBuilder.produce(new ContainerImageBuilderBuildItem(OPENSHIFT)); } private String getContextRoot(String outputDirName, boolean isFastJar, BuildStrategy buildStrategy) { @@ -298,7 +300,7 @@ private String getContextRoot(String outputDirName, boolean isFastJar, BuildStra @BuildStep(onlyIf = { IsNormalNotRemoteDev.class, OpenshiftBuild.class, NativeBuild.class }) public void openshiftBuildFromNative(OpenshiftConfig openshiftConfig, S2iConfig s2iConfig, ContainerImageConfig containerImageConfig, - KubernetesClientBuildItem kubernetesClient, + KubernetesClientBuildItem kubernetesClientSupplier, ContainerImageInfoBuildItem containerImage, ArchiveRootBuildItem archiveRoot, OutputTargetBuildItem out, PackageConfig packageConfig, List generatedResources, @@ -319,31 +321,33 @@ public void openshiftBuildFromNative(OpenshiftConfig openshiftConfig, S2iConfig return; } - String namespace = Optional.ofNullable(kubernetesClient.getClient().getNamespace()).orElse("default"); + try (KubernetesClient kubernetesClient = kubernetesClientSupplier.getClient().get()) { + String namespace = Optional.ofNullable(kubernetesClient.getNamespace()).orElse("default"); - LOG.info("Starting (in-cluster) container image build for jar using: " + config.buildStrategy + " on server: " - + kubernetesClient.getClient().getMasterUrl() + " in namespace:" + namespace + "."); - Optional openshiftYml = generatedResources - .stream() - .filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml")) - .findFirst(); + LOG.info("Starting (in-cluster) container image build for jar using: " + config.buildStrategy + " on server: " + + kubernetesClient.getMasterUrl() + " in namespace:" + namespace + "."); + Optional openshiftYml = generatedResources + .stream() + .filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml")) + .findFirst(); - if (openshiftYml.isEmpty()) { - LOG.warn( - "No Openshift manifests were generated so no openshift build process will be taking place"); - return; + if (openshiftYml.isEmpty()) { + LOG.warn( + "No Openshift manifests were generated so no openshift build process will be taking place"); + return; + } + //The contextRoot is where inside the tarball we will add the jars. A null value means everything will be added under '/' while "target" means everything will be added under '/target'. + //For docker kind of builds where we use instructions like: `COPY target/*.jar /deployments` it using '/target' is a requirement. + //For s2i kind of builds where jars are expected directly in the '/' we have to use null. + String contextRoot = config.buildStrategy == BuildStrategy.DOCKER ? "target" : null; + createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, out.getOutputDirectory(), + nativeImage.getPath()); + artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.emptyMap())); + containerImageBuilder.produce(new ContainerImageBuilderBuildItem(OPENSHIFT)); } - //The contextRoot is where inside the tarball we will add the jars. A null value means everything will be added under '/' while "target" means everything will be added under '/target'. - //For docker kind of builds where we use instructions like: `COPY target/*.jar /deployments` it using '/target' is a requirement. - //For s2i kind of builds where jars are expected directly in the '/' we have to use null. - String contextRoot = config.buildStrategy == BuildStrategy.DOCKER ? "target" : null; - createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, out.getOutputDirectory(), - nativeImage.getPath()); - artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.emptyMap())); - containerImageBuilder.produce(new ContainerImageBuilderBuildItem(OPENSHIFT)); } - public static void createContainerImage(KubernetesClientBuildItem kubernetesClient, + public static void createContainerImage(KubernetesClient kubernetesClient, GeneratedFileSystemResourceBuildItem openshiftManifests, OpenshiftConfig openshiftConfig, String base, @@ -360,7 +364,7 @@ public static void createContainerImage(KubernetesClientBuildItem kubernetesClie throw new RuntimeException("Error creating the openshift binary build archive.", e); } - Config config = kubernetesClient.getClient().getConfiguration(); + Config config = kubernetesClient.getConfiguration(); //Let's disable http2 as it causes issues with duplicate build triggers. config.setHttp2Disable(true); try (KubernetesClient client = Clients.fromConfig(config)) { diff --git a/extensions/container-image/container-image-s2i/deployment/pom.xml b/extensions/container-image/container-image-s2i/deployment/pom.xml index e717ba19077b3..70621164b7f18 100644 --- a/extensions/container-image/container-image-s2i/deployment/pom.xml +++ b/extensions/container-image/container-image-s2i/deployment/pom.xml @@ -51,6 +51,10 @@ com.sun tools + + io.fabric8 + kubernetes-client + diff --git a/extensions/container-image/container-image-s2i/deployment/src/main/java/io/quarkus/container/image/s2i/deployment/S2iProcessor.java b/extensions/container-image/container-image-s2i/deployment/src/main/java/io/quarkus/container/image/s2i/deployment/S2iProcessor.java index 3052fe0666e5a..7585ad2111932 100644 --- a/extensions/container-image/container-image-s2i/deployment/src/main/java/io/quarkus/container/image/s2i/deployment/S2iProcessor.java +++ b/extensions/container-image/container-image-s2i/deployment/src/main/java/io/quarkus/container/image/s2i/deployment/S2iProcessor.java @@ -171,7 +171,7 @@ public void s2iRequirementsNative(S2iConfig s2iConfig, @BuildStep(onlyIf = { IsNormalNotRemoteDev.class, S2iBuild.class }, onlyIfNot = NativeBuild.class) public void s2iBuildFromJar(S2iConfig s2iConfig, ContainerImageConfig containerImageConfig, - KubernetesClientBuildItem kubernetesClient, + KubernetesClientBuildItem kubernetesClientSupplier, ContainerImageInfoBuildItem containerImage, ArchiveRootBuildItem archiveRoot, OutputTargetBuildItem out, PackageConfig packageConfig, List generatedResources, @@ -201,20 +201,21 @@ public void s2iBuildFromJar(S2iConfig s2iConfig, ContainerImageConfig containerI "No Openshift manifests were generated so no s2i process will be taking place"); return; } - - String namespace = Optional.ofNullable(kubernetesClient.getClient().getNamespace()).orElse("default"); - LOG.info("Performing s2i binary build with jar on server: " + kubernetesClient.getClient().getMasterUrl() - + " in namespace:" + namespace + "."); - - createContainerImage(kubernetesClient, openshiftYml.get(), s2iConfig, out.getOutputDirectory(), jar.getPath(), - out.getOutputDirectory().resolve("lib")); - artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Collections.emptyMap())); - containerImageBuilder.produce(new ContainerImageBuilderBuildItem(S2I)); + try (KubernetesClient kubernetesClient = kubernetesClientSupplier.getClient().get()) { + String namespace = Optional.ofNullable(kubernetesClient.getNamespace()).orElse("default"); + LOG.info("Performing s2i binary build with jar on server: " + kubernetesClient.getMasterUrl() + + " in namespace:" + namespace + "."); + + createContainerImage(kubernetesClient, openshiftYml.get(), s2iConfig, out.getOutputDirectory(), jar.getPath(), + out.getOutputDirectory().resolve("lib")); + artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Collections.emptyMap())); + containerImageBuilder.produce(new ContainerImageBuilderBuildItem(S2I)); + } } @BuildStep(onlyIf = { IsNormalNotRemoteDev.class, S2iBuild.class, NativeBuild.class }) public void s2iBuildFromNative(S2iConfig s2iConfig, ContainerImageConfig containerImageConfig, - KubernetesClientBuildItem kubernetesClient, + KubernetesClientBuildItem kubernetesClientSupplier, ContainerImageInfoBuildItem containerImage, ArchiveRootBuildItem archiveRoot, OutputTargetBuildItem out, PackageConfig packageConfig, List generatedResources, @@ -233,28 +234,30 @@ public void s2iBuildFromNative(S2iConfig s2iConfig, ContainerImageConfig contain return; } - String namespace = Optional.ofNullable(kubernetesClient.getClient().getNamespace()).orElse("default"); - LOG.info("Performing s2i binary build with native image on server: " + kubernetesClient.getClient().getMasterUrl() - + " in namespace:" + namespace + "."); + try (KubernetesClient kubernetesClient = kubernetesClientSupplier.getClient().get()) { + String namespace = Optional.ofNullable(kubernetesClient.getNamespace()).orElse("default"); + LOG.info("Performing s2i binary build with native image on server: " + kubernetesClient.getMasterUrl() + + " in namespace:" + namespace + "."); - Optional openshiftYml = generatedResources - .stream() - .filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml")) - .findFirst(); + Optional openshiftYml = generatedResources + .stream() + .filter(r -> r.getName().endsWith("kubernetes" + File.separator + "openshift.yml")) + .findFirst(); - if (openshiftYml.isEmpty()) { - LOG.warn( - "No Openshift manifests were generated so no s2i process will be taking place"); - return; - } + if (openshiftYml.isEmpty()) { + LOG.warn( + "No Openshift manifests were generated so no s2i process will be taking place"); + return; + } - createContainerImage(kubernetesClient, openshiftYml.get(), s2iConfig, out.getOutputDirectory(), - nativeImage.getPath()); - artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.emptyMap())); - containerImageBuilder.produce(new ContainerImageBuilderBuildItem(S2I)); + createContainerImage(kubernetesClient, openshiftYml.get(), s2iConfig, out.getOutputDirectory(), + nativeImage.getPath()); + artifactResultProducer.produce(new ArtifactResultBuildItem(null, "native-container", Collections.emptyMap())); + containerImageBuilder.produce(new ContainerImageBuilderBuildItem(S2I)); + } } - public static void createContainerImage(KubernetesClientBuildItem kubernetesClient, + public static void createContainerImage(KubernetesClient kubernetesClient, GeneratedFileSystemResourceBuildItem openshiftManifests, S2iConfig s2iConfig, Path output, @@ -270,7 +273,7 @@ public static void createContainerImage(KubernetesClientBuildItem kubernetesClie throw new RuntimeException("Error creating the s2i binary build archive.", e); } - Config config = kubernetesClient.getClient().getConfiguration(); + Config config = kubernetesClient.getConfiguration(); //Let's disable http2 as it causes issues with duplicate build triggers. config.setHttp2Disable(true); try (KubernetesClient client = Clients.fromConfig(config)) { diff --git a/extensions/kubernetes-client/deployment-internal/pom.xml b/extensions/kubernetes-client/deployment-internal/pom.xml index 5f50448a7e887..a564ff686f0c2 100644 --- a/extensions/kubernetes-client/deployment-internal/pom.xml +++ b/extensions/kubernetes-client/deployment-internal/pom.xml @@ -33,6 +33,16 @@ io.fabric8 kubernetes-client + + + io.fabric8 + kubernetes-httpclient-okhttp + + + + + io.fabric8 + kubernetes-httpclient-vertx io.quarkus diff --git a/extensions/kubernetes-client/deployment-internal/src/main/java/io/quarkus/kubernetes/client/deployment/KubernetesClientBuildStep.java b/extensions/kubernetes-client/deployment-internal/src/main/java/io/quarkus/kubernetes/client/deployment/KubernetesClientBuildStep.java index a65b82da207ae..6c5bd544cf0cd 100644 --- a/extensions/kubernetes-client/deployment-internal/src/main/java/io/quarkus/kubernetes/client/deployment/KubernetesClientBuildStep.java +++ b/extensions/kubernetes-client/deployment-internal/src/main/java/io/quarkus/kubernetes/client/deployment/KubernetesClientBuildStep.java @@ -13,6 +13,6 @@ public class KubernetesClientBuildStep { @BuildStep public KubernetesClientBuildItem process(TlsConfig tlsConfig) { - return new KubernetesClientBuildItem(createClient(buildConfig, tlsConfig)); + return new KubernetesClientBuildItem(createConfig(buildConfig, tlsConfig)); } } diff --git a/extensions/kubernetes-client/deployment/pom.xml b/extensions/kubernetes-client/deployment/pom.xml index e2b5006e0b5b8..bd989bda54851 100644 --- a/extensions/kubernetes-client/deployment/pom.xml +++ b/extensions/kubernetes-client/deployment/pom.xml @@ -25,6 +25,10 @@ io.quarkus quarkus-jackson-deployment + + io.quarkus + quarkus-vertx-deployment + diff --git a/extensions/kubernetes-client/runtime-internal/pom.xml b/extensions/kubernetes-client/runtime-internal/pom.xml index 9a99ba4a8f9aa..2b01e9e2ab69f 100644 --- a/extensions/kubernetes-client/runtime-internal/pom.xml +++ b/extensions/kubernetes-client/runtime-internal/pom.xml @@ -23,6 +23,17 @@ io.fabric8 kubernetes-client provided + + + io.fabric8 + kubernetes-httpclient-okhttp + + + + + io.fabric8 + kubernetes-httpclient-vertx + provided diff --git a/extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesClientUtils.java b/extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesClientUtils.java index 9a5e9c33056f4..d0e605c3b3d38 100644 --- a/extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesClientUtils.java +++ b/extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesClientUtils.java @@ -6,8 +6,8 @@ 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 io.quarkus.runtime.TlsConfig; public class KubernetesClientUtils { @@ -49,13 +49,13 @@ public static Config createConfig(KubernetesClientBuildConfig buildConfig, TlsCo } public static KubernetesClient createClient(KubernetesClientBuildConfig buildConfig, TlsConfig tlsConfig) { - return new DefaultKubernetesClient(createConfig(buildConfig, tlsConfig)); + return new KubernetesClientBuilder().withConfig(createConfig(buildConfig, tlsConfig)).build(); } public static KubernetesClient createClient() { org.eclipse.microprofile.config.Config config = ConfigProvider.getConfig(); Config base = Config.autoConfigure(null); - return new DefaultKubernetesClient(new ConfigBuilder() + return new KubernetesClientBuilder().withConfig(new ConfigBuilder() .withTrustCerts(config.getOptionalValue(PREFIX + "trust-certs", Boolean.class).orElse(base.isTrustCerts())) .withWatchReconnectLimit(config.getOptionalValue(PREFIX + "watch-reconnect-limit", Integer.class) .orElse(base.getWatchReconnectLimit())) @@ -92,6 +92,7 @@ public static KubernetesClient createClient() { .withProxyPassword( config.getOptionalValue(PREFIX + "proxy-password", String.class).orElse(base.getProxyPassword())) .withNoProxy(config.getOptionalValue(PREFIX + "no-proxy", String[].class).orElse(base.getNoProxy())) - .build()); + .build()) + .build(); } } diff --git a/extensions/kubernetes-client/runtime/pom.xml b/extensions/kubernetes-client/runtime/pom.xml index 044e3100e236d..1d6a02ef24a3b 100644 --- a/extensions/kubernetes-client/runtime/pom.xml +++ b/extensions/kubernetes-client/runtime/pom.xml @@ -26,9 +26,23 @@ io.quarkus quarkus-jackson + + io.quarkus + quarkus-vertx + io.fabric8 kubernetes-client + + + io.fabric8 + kubernetes-httpclient-okhttp + + + + + io.fabric8 + kubernetes-httpclient-vertx org.graalvm.nativeimage diff --git a/extensions/kubernetes-client/runtime/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesClientProducer.java b/extensions/kubernetes-client/runtime/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesClientProducer.java index e459973e3e10e..b87ce32197945 100644 --- a/extensions/kubernetes-client/runtime/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesClientProducer.java +++ b/extensions/kubernetes-client/runtime/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesClientProducer.java @@ -5,8 +5,8 @@ import javax.inject.Singleton; 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 io.quarkus.arc.DefaultBean; @Singleton @@ -18,7 +18,7 @@ public class KubernetesClientProducer { @Singleton @Produces public KubernetesClient kubernetesClient(Config config) { - client = new DefaultKubernetesClient(config); + client = new KubernetesClientBuilder().withConfig(config).build(); return client; } diff --git a/extensions/kubernetes-client/runtime/src/main/java/io/quarkus/kubernetes/client/runtime/QuarkusHttpClientFactory.java b/extensions/kubernetes-client/runtime/src/main/java/io/quarkus/kubernetes/client/runtime/QuarkusHttpClientFactory.java new file mode 100644 index 0000000000000..31c5c53d2618c --- /dev/null +++ b/extensions/kubernetes-client/runtime/src/main/java/io/quarkus/kubernetes/client/runtime/QuarkusHttpClientFactory.java @@ -0,0 +1,38 @@ +package io.quarkus.kubernetes.client.runtime; + +import javax.enterprise.inject.spi.CDI; + +import io.fabric8.kubernetes.client.Config; +import io.fabric8.kubernetes.client.http.HttpClient; +import io.fabric8.kubernetes.client.vertx.VertxHttpClientBuilder; +import io.vertx.core.Vertx; + +public class QuarkusHttpClientFactory implements io.fabric8.kubernetes.client.http.HttpClient.Factory { + + private Vertx vertx; + + public QuarkusHttpClientFactory() { + // The client might get initialized outside a Quarkus context that can provide the Vert.x instance + // This is the case for the MockServer / @KubernetesTestServer where the server provides the KubernetesClient instance + try { + this.vertx = CDI.current().select(Vertx.class).get(); + } catch (Exception e) { + this.vertx = Vertx.vertx(); + } + } + + @Override + public HttpClient.Builder newBuilder(Config config) { + return HttpClient.Factory.super.newBuilder(config); + } + + @Override + public VertxHttpClientBuilder newBuilder() { + return new VertxHttpClientBuilder<>(this, vertx); + } + + @Override + public int priority() { + return 1; + } +} diff --git a/extensions/kubernetes-client/runtime/src/main/resources/META-INF/services/io.fabric8.kubernetes.client.http.HttpClient$Factory b/extensions/kubernetes-client/runtime/src/main/resources/META-INF/services/io.fabric8.kubernetes.client.http.HttpClient$Factory new file mode 100644 index 0000000000000..5ad0eb6326624 --- /dev/null +++ b/extensions/kubernetes-client/runtime/src/main/resources/META-INF/services/io.fabric8.kubernetes.client.http.HttpClient$Factory @@ -0,0 +1 @@ +io.quarkus.kubernetes.client.runtime.QuarkusHttpClientFactory diff --git a/extensions/kubernetes-client/spi/pom.xml b/extensions/kubernetes-client/spi/pom.xml index 57ef85a82ecfb..a2d91bf7654e7 100644 --- a/extensions/kubernetes-client/spi/pom.xml +++ b/extensions/kubernetes-client/spi/pom.xml @@ -22,6 +22,10 @@ io.fabric8 kubernetes-client + + io.fabric8 + kubernetes-httpclient-okhttp + javax.annotation javax.annotation-api @@ -36,6 +40,10 @@ + + io.fabric8 + kubernetes-httpclient-vertx + diff --git a/extensions/kubernetes-client/spi/src/main/java/io/quarkus/kubernetes/client/spi/KubernetesClientBuildItem.java b/extensions/kubernetes-client/spi/src/main/java/io/quarkus/kubernetes/client/spi/KubernetesClientBuildItem.java index c8f9971b3e03d..b68b3fd113fb1 100644 --- a/extensions/kubernetes-client/spi/src/main/java/io/quarkus/kubernetes/client/spi/KubernetesClientBuildItem.java +++ b/extensions/kubernetes-client/spi/src/main/java/io/quarkus/kubernetes/client/spi/KubernetesClientBuildItem.java @@ -1,18 +1,26 @@ package io.quarkus.kubernetes.client.spi; +import java.util.function.Supplier; + +import io.fabric8.kubernetes.client.Config; import io.fabric8.kubernetes.client.KubernetesClient; +import io.fabric8.kubernetes.client.KubernetesClientBuilder; import io.quarkus.builder.item.SimpleBuildItem; public final class KubernetesClientBuildItem extends SimpleBuildItem { - private final KubernetesClient client; + private final Config config; + + public KubernetesClientBuildItem(Config config) { + this.config = config; + } - public KubernetesClientBuildItem(KubernetesClient client) { - this.client = client; + public Supplier getClient() { + return () -> new KubernetesClientBuilder().withConfig(config).build(); } - public KubernetesClient getClient() { - return this.client; + public Config getConfig() { + return config; } } diff --git a/extensions/kubernetes-service-binding/deployment/pom.xml b/extensions/kubernetes-service-binding/deployment/pom.xml index 067af3efaecd1..958dccc3df41f 100644 --- a/extensions/kubernetes-service-binding/deployment/pom.xml +++ b/extensions/kubernetes-service-binding/deployment/pom.xml @@ -43,8 +43,26 @@ com.sun tools + + io.fabric8 + kubernetes-client + + + + + io.fabric8 + kubernetes-client + + + io.fabric8 + kubernetes-httpclient-okhttp + + + io.fabric8 + kubernetes-httpclient-vertx + diff --git a/extensions/kubernetes/kind/deployment/pom.xml b/extensions/kubernetes/kind/deployment/pom.xml index 1046c28165a32..cfbc1ef49ae53 100644 --- a/extensions/kubernetes/kind/deployment/pom.xml +++ b/extensions/kubernetes/kind/deployment/pom.xml @@ -34,6 +34,10 @@ com.sun tools + + io.fabric8 + kubernetes-client + diff --git a/extensions/kubernetes/openshift/deployment/pom.xml b/extensions/kubernetes/openshift/deployment/pom.xml index 98a6583756a03..d4c4f315d6628 100644 --- a/extensions/kubernetes/openshift/deployment/pom.xml +++ b/extensions/kubernetes/openshift/deployment/pom.xml @@ -38,6 +38,10 @@ com.sun tools + + io.fabric8 + kubernetes-client + diff --git a/extensions/kubernetes/vanilla/deployment/pom.xml b/extensions/kubernetes/vanilla/deployment/pom.xml index 3898ab1f2e153..8c1d9f4b0c8d7 100644 --- a/extensions/kubernetes/vanilla/deployment/pom.xml +++ b/extensions/kubernetes/vanilla/deployment/pom.xml @@ -42,6 +42,10 @@ com.sun tools + + io.fabric8 + kubernetes-client + @@ -57,6 +61,10 @@ com.sun tools + + io.fabric8 + kubernetes-client + @@ -72,6 +80,10 @@ com.sun tools + + io.fabric8 + kubernetes-client + diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeDeployer.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeDeployer.java index 4e9079689f8f2..7edfbeb45d6a9 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeDeployer.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeDeployer.java @@ -17,14 +17,14 @@ public class KnativeDeployer { @BuildStep public void checkEnvironment(Optional selectedDeploymentTarget, List resources, - KubernetesClientBuildItem client, BuildProducer deploymentCluster) { + KubernetesClientBuildItem clientSupplier, BuildProducer deploymentCluster) { selectedDeploymentTarget.ifPresent(target -> { if (!KubernetesDeploy.INSTANCE.checkSilently()) { return; } if (target.getEntry().getName().equals(KNATIVE)) { - try (DefaultKnativeClient knativeClient = client.getClient().adapt(DefaultKnativeClient.class)) { - if (knativeClient.isSupported()) { + try (DefaultKnativeClient client = clientSupplier.getClient().get().adapt(DefaultKnativeClient.class)) { + if (client.isSupported()) { deploymentCluster.produce(new KubernetesDeploymentClusterBuildItem(KNATIVE)); } else { throw new IllegalStateException( diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java index 8e2e067cecf34..e5037121a6c7c 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java @@ -102,7 +102,7 @@ public void checkEnvironment(Optional deploymentClusters, Optional selectedDeploymentTarget, @@ -130,10 +130,11 @@ public void deploy(KubernetesClientBuildItem kubernetesClient, return; } - final KubernetesClient client = Clients.fromConfig(kubernetesClient.getClient().getConfiguration()); - deploymentResult - .produce(deploy(selectedDeploymentTarget.get().getEntry(), client, outputTarget.getOutputDirectory(), - openshiftConfig, applicationInfo, optionalResourceDefinitions)); + try (final KubernetesClient client = Clients.fromConfig(kubernetesClientSupplier.getConfig())) { + deploymentResult + .produce(deploy(selectedDeploymentTarget.get().getEntry(), client, outputTarget.getOutputDirectory(), + openshiftConfig, applicationInfo, optionalResourceDefinitions)); + } } /** diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftDeployer.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftDeployer.java index 82ecd5a305eed..b74b863826fd7 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftDeployer.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftDeployer.java @@ -18,13 +18,13 @@ public class OpenshiftDeployer { @BuildStep public void checkEnvironment(Optional selectedDeploymentTarget, List resources, - KubernetesClientBuildItem client, BuildProducer deploymentCluster) { + KubernetesClientBuildItem clientSupplier, BuildProducer deploymentCluster) { selectedDeploymentTarget.ifPresent(target -> { if (!KubernetesDeploy.INSTANCE.checkSilently()) { return; } if (target.getEntry().getName().equals(OPENSHIFT)) { - try (var openShiftClient = client.getClient().adapt(OpenShiftClient.class)) { + try (var openShiftClient = clientSupplier.getClient().get().adapt(OpenShiftClient.class)) { if (openShiftClient.isSupported()) { deploymentCluster.produce(new KubernetesDeploymentClusterBuildItem(OPENSHIFT)); } else { diff --git a/independent-projects/enforcer-rules/src/main/resources/enforcer-rules/quarkus-banned-dependencies.xml b/independent-projects/enforcer-rules/src/main/resources/enforcer-rules/quarkus-banned-dependencies.xml index 30f9458575ccd..0e95dae390b0c 100644 --- a/independent-projects/enforcer-rules/src/main/resources/enforcer-rules/quarkus-banned-dependencies.xml +++ b/independent-projects/enforcer-rules/src/main/resources/enforcer-rules/quarkus-banned-dependencies.xml @@ -102,6 +102,8 @@ org.javassist:javassist org.jboss:jandex + + io.fabric8:kubernetes-httpclient-okhttp @@ -109,4 +111,4 @@ - \ No newline at end of file + diff --git a/integration-tests/istio/maven-invoker-way/pom.xml b/integration-tests/istio/maven-invoker-way/pom.xml index a06e4d17f8447..5996caa02d815 100644 --- a/integration-tests/istio/maven-invoker-way/pom.xml +++ b/integration-tests/istio/maven-invoker-way/pom.xml @@ -56,23 +56,41 @@ io.fabric8 - kubernetes-httpclient-okhttp + kubernetes-httpclient-vertx test io.dekorate kubernetes-annotations noapt + + + io.fabric8 + kubernetes-client + + io.dekorate openshift-annotations noapt + + + io.fabric8 + kubernetes-client + + io.dekorate knative-annotations noapt + + + io.fabric8 + kubernetes-client + + io.quarkus diff --git a/integration-tests/kubernetes/maven-invoker-way/pom.xml b/integration-tests/kubernetes/maven-invoker-way/pom.xml index 54b1df4d12d9e..2d4dd82b1d282 100644 --- a/integration-tests/kubernetes/maven-invoker-way/pom.xml +++ b/integration-tests/kubernetes/maven-invoker-way/pom.xml @@ -49,16 +49,34 @@ io.dekorate kubernetes-annotations noapt + + + io.fabric8 + kubernetes-client + + io.dekorate openshift-annotations noapt + + + io.fabric8 + kubernetes-client + + io.dekorate knative-annotations noapt + + + io.fabric8 + kubernetes-client + + io.quarkus diff --git a/integration-tests/kubernetes/quarkus-standard-way/pom.xml b/integration-tests/kubernetes/quarkus-standard-way/pom.xml index 8769ab42082de..db695f26cfe3b 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/pom.xml +++ b/integration-tests/kubernetes/quarkus-standard-way/pom.xml @@ -119,6 +119,26 @@ io.dekorate servicebinding-annotations noapt + + + io.fabric8 + kubernetes-client + + + + + io.fabric8 + kubernetes-client + + + io.fabric8 + kubernetes-httpclient-okhttp + + + + + io.fabric8 + kubernetes-httpclient-vertx @@ -214,7 +234,7 @@ - + basic-test-suite @@ -249,5 +269,5 @@ - + diff --git a/pom.xml b/pom.xml index 38df7473994f2..a9d1c5c15d237 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ 0.8.8 - 6.3.1 + 6.4.1 1.52.1 diff --git a/test-framework/kubernetes-client/pom.xml b/test-framework/kubernetes-client/pom.xml index 257f3eb1438d0..ad83c16dba30f 100644 --- a/test-framework/kubernetes-client/pom.xml +++ b/test-framework/kubernetes-client/pom.xml @@ -46,6 +46,16 @@ io.fabric8 kubernetes-server-mock + + + io.fabric8 + kubernetes-httpclient-okhttp + + + + + io.fabric8 + kubernetes-httpclient-vertx jakarta.annotation diff --git a/test-framework/openshift-client/pom.xml b/test-framework/openshift-client/pom.xml index 4f74c92e8868d..734f9725baeb3 100644 --- a/test-framework/openshift-client/pom.xml +++ b/test-framework/openshift-client/pom.xml @@ -22,8 +22,8 @@ openshift-server-mock - com.squareup.okhttp3 - okhttp + io.fabric8 + kubernetes-httpclient-okhttp javax.annotation