From a3fc4ee525589c11d8baf3cca19f4b3033f02ace Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Thu, 20 Jan 2022 12:49:29 +0200 Subject: [PATCH 1/3] chore: bump dekorate to 2.8.0 --- bom/application/pom.xml | 2 +- .../kubernetes/deployment/OpenshiftProcessor.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 9e16eb02e80a7..1551a8959e5da 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -150,7 +150,7 @@ 1.6.10 1.6.0 1.3.2 - 2.6.0 + 2.8.0 3.0.1 4.1.1 1.0.9 diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java index e1241b31bbc92..552afd20a8c06 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftProcessor.java @@ -17,6 +17,8 @@ import io.dekorate.kubernetes.annotation.ServiceType; import io.dekorate.kubernetes.config.EnvBuilder; +import io.dekorate.kubernetes.config.ImageConfiguration; +import io.dekorate.kubernetes.config.ImageConfigurationBuilder; import io.dekorate.kubernetes.decorator.AddEnvVarDecorator; import io.dekorate.kubernetes.decorator.AddLabelDecorator; import io.dekorate.kubernetes.decorator.ApplicationContainerDecorator; @@ -27,6 +29,7 @@ import io.dekorate.s2i.config.S2iBuildConfig; import io.dekorate.s2i.config.S2iBuildConfigBuilder; import io.dekorate.s2i.decorator.AddBuilderImageStreamResourceDecorator; +import io.dekorate.s2i.decorator.AddDockerImageStreamResourceDecorator; import io.dekorate.utils.Labels; import io.fabric8.kubernetes.client.Config; import io.quarkus.container.image.deployment.ContainerImageConfig; @@ -252,6 +255,14 @@ public List createDecorators(ApplicationInfoBuildItem applic && !capabilities.isPresent("io.quarkus.openshift") && !capabilities.isPresent(Capability.CONTAINER_IMAGE_OPENSHIFT)) { result.add(new DecoratorBuildItem(OPENSHIFT, new RemoveDeploymentTriggerDecorator())); + ImageConfiguration imageConfiguration = new ImageConfigurationBuilder() + .build(); + + image.ifPresent(i -> { + String repo = i.getRegistry().map(reg -> reg + "/" + i.getRepository()).orElse(i.getRepository()); + result.add(new DecoratorBuildItem(OPENSHIFT, + new AddDockerImageStreamResourceDecorator(imageConfiguration, repo))); + }); } return result; From b80cde5ed50f1042e059be8c2f87bdfc5234bf70 Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Thu, 20 Jan 2022 12:49:54 +0200 Subject: [PATCH 2/3] fix: only add mount, ports and envars to app container --- .../quarkus/kubernetes/deployment/ContainerAdapter.java | 8 +++++--- .../kubernetes/deployment/KubernetesCommonHelper.java | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ContainerAdapter.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ContainerAdapter.java index d736beb7a2df6..85eef9a76476b 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ContainerAdapter.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ContainerAdapter.java @@ -19,6 +19,8 @@ */ public class ContainerAdapter { + private static final String ANY = null; + public static Container adapt(io.dekorate.kubernetes.config.Container container) { String name = container.getName(); if (Strings.isNullOrEmpty(name)) { @@ -34,14 +36,14 @@ public static Container adapt(io.dekorate.kubernetes.config.Container container) .withArgs(container.getArguments()); for (Env env : container.getEnvVars()) { - builder.accept(new AddEnvVarDecorator(env)); + builder.accept(new AddEnvVarDecorator(ANY, name, env)); } for (Port port : container.getPorts()) { // this was changed to use our patched port decorator - builder.accept(new AddPortDecorator(port)); + builder.accept(new AddPortDecorator(ANY, name, port)); } for (Mount mount : container.getMounts()) { - builder.accept(new AddMountDecorator(mount)); + builder.accept(new AddMountDecorator(ANY, name, mount)); } builder.accept(new ApplyImagePullPolicyDecorator(name, container.getImagePullPolicy())); diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java index dd1c5387fa7b4..34aa32d81a76e 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java @@ -75,6 +75,7 @@ public class KubernetesCommonHelper { + private static final String ANY = null; private static final String OUTPUT_ARTIFACT_FORMAT = "%s%s.jar"; private static final String[] PROMETHEUS_ANNOTATION_TARGETS = { "Service", "Deployment", "DeploymentConfig" }; @@ -366,7 +367,7 @@ private static List createMountAndVolumeDecorators(Optional< List result = new ArrayList<>(); config.getMounts().entrySet().forEach(e -> { - result.add(new DecoratorBuildItem(target, new AddMountDecorator(MountConverter.convert(e)))); + result.add(new DecoratorBuildItem(target, new AddMountDecorator(ANY, name, MountConverter.convert(e)))); }); config.getSecretVolumes().entrySet().forEach(e -> { From 10a30b7375d83e23097ecc65d02ea9c8537fc89c Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Thu, 20 Jan 2022 12:50:14 +0200 Subject: [PATCH 3/3] chore: substitute refs to deprecated methods --- .../kubernetes/deployment/KubernetesCommonHelper.java | 4 ++-- .../kubernetes/KubernetesWithQuarkusAppNameTest.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java index 34aa32d81a76e..2be2534d6669a 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java @@ -330,7 +330,7 @@ private static List createAppConfigVolumeAndEnvDecorators(Op config.getAppSecret().ifPresent(s -> { result.add(new DecoratorBuildItem(target, new AddSecretVolumeDecorator(new SecretVolumeBuilder() .withSecretName(s) - .withNewVolumeName("app-secret") + .withVolumeName("app-secret") .build()))); result.add(new DecoratorBuildItem(target, new AddMountDecorator(new MountBuilder() .withName("app-secret") @@ -342,7 +342,7 @@ private static List createAppConfigVolumeAndEnvDecorators(Op config.getAppConfigMap().ifPresent(s -> { result.add(new DecoratorBuildItem(target, new AddConfigMapVolumeDecorator(new ConfigMapVolumeBuilder() .withConfigMapName(s) - .withNewVolumeName("app-config-map") + .withVolumeName("app-config-map") .build()))); result.add(new DecoratorBuildItem(target, new AddMountDecorator(new MountBuilder() .withName("app-config-map") diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithQuarkusAppNameTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithQuarkusAppNameTest.java index 515f0ae690952..3f19f8e0051dd 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithQuarkusAppNameTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithQuarkusAppNameTest.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.nio.file.Path; +import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; @@ -12,6 +13,8 @@ import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.apps.Deployment; +import io.quarkus.bootstrap.model.AppArtifact; +import io.quarkus.builder.Version; import io.quarkus.test.ProdBuildResults; import io.quarkus.test.ProdModeTestResults; import io.quarkus.test.QuarkusProdModeTest; @@ -23,7 +26,11 @@ public class KubernetesWithQuarkusAppNameTest { .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) .setApplicationName("kubernetes-with-quarkus-app-name") .setApplicationVersion("0.1-SNAPSHOT") - .withConfigurationResource("kubernetes-with-quarkus-app-name.properties"); + .withConfigurationResource("kubernetes-with-quarkus-app-name.properties") + .setForcedDependencies( + Arrays.asList( + new AppArtifact("io.quarkus", "quarkus-kubernetes", Version.getVersion()), + new AppArtifact("io.quarkus", "quarkus-container-image-s2i", Version.getVersion()))); @ProdBuildResults private ProdModeTestResults prodModeTestResults; @@ -48,7 +55,7 @@ public void assertGeneratedResources() throws IOException { List openshiftList = DeserializationUtil .deserializeAsList(kubernetesDir.resolve("openshift.yml")); assertThat(openshiftList).allSatisfy(h -> { - assertThat(h.getMetadata().getName()).isIn("ofoo", "s2ifoo", "s2i-java"); + assertThat(h.getMetadata().getName()).isIn("ofoo", "foo", "openjdk-11"); assertThat(h.getMetadata().getLabels()).contains(entry("app.kubernetes.io/name", "ofoo"), entry("app.kubernetes.io/version", "1.0-openshift")); });