prefixMap = collectPrefixes(c);
+
c.vars.forEach((k, v) -> validator.process(KubernetesEnvBuildItem.createSimpleVar(k, v.orElse(""), target)));
c.fields.forEach((k, v) -> validator.process(KubernetesEnvBuildItem.createFromField(k, v, target)));
c.configmaps
- .ifPresent(cl -> cl.forEach(cm -> validator.process(KubernetesEnvBuildItem.createFromConfigMap(cm, target))));
- c.secrets.ifPresent(sl -> sl.forEach(s -> validator.process(KubernetesEnvBuildItem.createFromSecret(s, target))));
+ .ifPresent(
+ cl -> cl.forEach(cm -> validator.process(KubernetesEnvBuildItem.createFromConfigMap(cm,
+ target, extractConfigmapPrefix(cm, prefixMap).orElse(null)))));
+ c.secrets.ifPresent(sl -> sl.forEach(s -> validator.process(KubernetesEnvBuildItem.createFromSecret(s,
+ target, extractSecretPrefix(s, prefixMap).orElse(null)))));
c.mapping.forEach(
(varName, config) -> validator.process(KubernetesEnvBuildItem.createFromResourceKey(varName, config.withKey,
config.fromSecret.orElse(null), config.fromConfigmap.orElse(null), target)));
return validator.getBuildItems();
}
+
}
diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarPrefixConfig.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarPrefixConfig.java
new file mode 100644
index 00000000000000..8f361d5329637f
--- /dev/null
+++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarPrefixConfig.java
@@ -0,0 +1,60 @@
+/**
+ * Copyright 2020 Red Hat, Inc. and/or its affiliates.
+ *
+ *
+ * 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 io.quarkus.kubernetes.deployment;
+
+import java.util.Optional;
+
+import io.quarkus.runtime.annotations.ConfigGroup;
+import io.quarkus.runtime.annotations.ConfigItem;
+
+/**
+ * The configuration of environment variables prefix.
+ * It is used with quarkus.kubernetes.env.secrets
and quarkus.kubernetes.env.configmaps
to specify the
+ * prefix to use when adding the environment variable to the container.
+ */
+@ConfigGroup
+public class EnvVarPrefixConfig {
+
+ /**
+ * The optional prefix to use when adding the environment variable to the container.
+ */
+ @ConfigItem
+ Optional fromSecret;
+
+ /**
+ * The optional prefix to use when adding the environment variable to the container.
+ */
+ @ConfigItem
+ Optional fromConfigmap;
+
+ public boolean anyPresent() {
+ return fromSecret.isPresent() || fromConfigmap.isPresent();
+ }
+
+ public boolean hasConfigmap() {
+ return fromConfigmap.isPresent();
+ }
+
+ public boolean hasSecret() {
+ return fromSecret.isPresent();
+ }
+
+ public boolean hasPrefixForSecret(String secret) {
+ return fromSecret.map(s -> s.equals(secret)).orElse(false);
+ }
+
+ public boolean hasPrefixForConfigmap(String configmap) {
+ return fromConfigmap.map(c -> c.equals(configmap)).orElse(false);
+ }
+}
diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarValidator.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarValidator.java
index 6d4cbf74e0f2c9..85c62e5aa0f7c7 100644
--- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarValidator.java
+++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarValidator.java
@@ -18,10 +18,10 @@ public class EnvVarValidator {
private final Set errors = new HashSet<>();
void process(String name, Optional value, Optional secret, Optional configmap,
- Optional field, String target, boolean... oldStyle) {
+ Optional field, String target, Optional prefix, boolean... oldStyle) {
try {
final KubernetesEnvBuildItem kebi = KubernetesEnvBuildItem.create(name, value.orElse(null),
- secret.orElse(null), configmap.orElse(null), field.orElse(null), target, oldStyle);
+ secret.orElse(null), configmap.orElse(null), field.orElse(null), target, prefix.orElse(null), oldStyle);
process(kebi);
} catch (IllegalArgumentException e) {
errors.add(e.getMessage());
diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarsConfig.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarsConfig.java
index 95ff8ea865e4e5..ee55679d9a7c93 100644
--- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarsConfig.java
+++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/EnvVarsConfig.java
@@ -44,4 +44,10 @@ public class EnvVarsConfig {
*/
@ConfigItem
Map mapping;
+
+ /**
+ * The map recording the configuration of environment variable prefix.
+ */
+ @ConfigItem
+ Map prefix;
}
diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VanillaKubernetesProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VanillaKubernetesProcessor.java
index a97429c6cf610c..a482b0030b2104 100644
--- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VanillaKubernetesProcessor.java
+++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VanillaKubernetesProcessor.java
@@ -232,6 +232,7 @@ public List createDecorators(ApplicationInfoBuildItem applic
new AddEnvVarDecorator(ApplicationContainerDecorator.ANY, name,
new EnvBuilder().withName(EnvConverter.convertName(e.getName())).withValue(e.getValue())
.withSecret(e.getSecret()).withConfigmap(e.getConfigMap()).withField(e.getField())
+ .withPrefix(e.getPrefix())
.build())));
});
diff --git a/extensions/kubernetes/vanilla/deployment/src/test/java/io/quarkus/kubernetes/deployment/EnvVarValidatorTest.java b/extensions/kubernetes/vanilla/deployment/src/test/java/io/quarkus/kubernetes/deployment/EnvVarValidatorTest.java
index b0fa7bfcbf901a..747d7052828f3a 100644
--- a/extensions/kubernetes/vanilla/deployment/src/test/java/io/quarkus/kubernetes/deployment/EnvVarValidatorTest.java
+++ b/extensions/kubernetes/vanilla/deployment/src/test/java/io/quarkus/kubernetes/deployment/EnvVarValidatorTest.java
@@ -55,8 +55,8 @@ void getBuildItemsTwoConflictingItemsShouldFail() {
@Test
void getBuildItemsTwoRedundantItemsShouldResultInOnlyOneItem() {
final String name = "name";
- final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createFromConfigMap(name, TARGET);
- final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromConfigMap(name, TARGET);
+ final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createFromConfigMap(name, TARGET, null);
+ final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromConfigMap(name, TARGET, null);
validator.process(first);
validator.process(second);
final Collection items = validator.getBuildItems();
@@ -69,8 +69,8 @@ void getBuildItemsSimilarlyNamedCompatibleItemsShouldWork() {
final String name = "name";
final String value1 = "foo";
final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createSimpleVar(name, value1, TARGET);
- final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromSecret(name, TARGET);
- final KubernetesEnvBuildItem third = KubernetesEnvBuildItem.createFromConfigMap(name, TARGET);
+ final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromSecret(name, TARGET, null);
+ final KubernetesEnvBuildItem third = KubernetesEnvBuildItem.createFromConfigMap(name, TARGET, null);
validator.process(first);
validator.process(second);
validator.process(third);
@@ -117,14 +117,14 @@ void getBuildItemsOldConflictShouldNotPreventNewToWork() {
* quarkus.kubernetes.env.secrets=secret
* quarkus.kubernetes.env-vars.xxx.secret=secret
*/
- final KubernetesEnvBuildItem newCM = KubernetesEnvBuildItem.createFromConfigMap("configmap", TARGET);
- final KubernetesEnvBuildItem newS = KubernetesEnvBuildItem.createFromSecret("secret", TARGET);
+ final KubernetesEnvBuildItem newCM = KubernetesEnvBuildItem.createFromConfigMap("configmap", TARGET, null);
+ final KubernetesEnvBuildItem newS = KubernetesEnvBuildItem.createFromSecret("secret", TARGET, null);
validator.process("foo", Optional.empty(), Optional.empty(), Optional.of("configmap"), Optional.empty(),
- TARGET, true);
+ TARGET, Optional.empty(), true);
validator.process(newS);
validator.process(newCM);
validator.process("foo", Optional.empty(), Optional.of("secret"), Optional.empty(), Optional.empty(),
- TARGET, true);
+ TARGET, Optional.empty(), true);
Collection items = validator.getBuildItems();
assertEquals(2, items.size());
assertTrue(items.contains(newCM));
@@ -168,7 +168,7 @@ void getBuildItemsDirectAndFromSecretShouldConflict() {
final String configmap = "configmap";
final String key = "key";
final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createSimpleVar(name, value1, TARGET);
- final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromConfigMapKey(name, key, configmap,
+ final KubernetesEnvBuildItem second = KubernetesEnvBuildItem.createFromConfigMapKey(name, key, configmap, null,
TARGET);
validator.process(first);
validator.process(second);
@@ -200,10 +200,10 @@ void getBuildItemsUsingOldStyleProcessAndNewStyleCreateForSameItemShouldKeepNewS
final String name = "name";
final String configmap = "configmap";
final String key = "key";
- final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createFromConfigMapKey(name, key, configmap, TARGET);
+ final KubernetesEnvBuildItem first = KubernetesEnvBuildItem.createFromConfigMapKey(name, key, configmap, null, TARGET);
validator.process(first);
validator.process(name, Optional.of("oldKey"), Optional.empty(), Optional.of(configmap), Optional.empty(),
- TARGET, true);
+ TARGET, Optional.empty(), true);
Collection buildItems = validator.getBuildItems();
assertEquals(1, buildItems.size());
assertTrue(buildItems.contains(first));
@@ -211,7 +211,7 @@ void getBuildItemsUsingOldStyleProcessAndNewStyleCreateForSameItemShouldKeepNewS
// check different order
validator = new EnvVarValidator();
validator.process(name, Optional.of("oldKey"), Optional.empty(), Optional.of(configmap), Optional.empty(),
- TARGET, true);
+ TARGET, Optional.empty(), true);
validator.process(first);
buildItems = validator.getBuildItems();
assertEquals(1, buildItems.size());
diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromConfigMapWithPrefixBehaviorsTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromConfigMapWithPrefixBehaviorsTest.java
new file mode 100644
index 00000000000000..891380beb64216
--- /dev/null
+++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromConfigMapWithPrefixBehaviorsTest.java
@@ -0,0 +1,63 @@
+package io.quarkus.it.kubernetes;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import io.fabric8.kubernetes.api.model.HasMetadata;
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+import io.quarkus.test.ProdBuildResults;
+import io.quarkus.test.ProdModeTestResults;
+import io.quarkus.test.QuarkusProdModeTest;
+
+public class KubernetesWithEnvFromConfigMapWithPrefixBehaviorsTest {
+
+ @RegisterExtension
+ static final QuarkusProdModeTest config = new QuarkusProdModeTest()
+ .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class))
+ .setApplicationName("env-from-config-map-with-prefix-behaviors")
+ .setApplicationVersion("0.1-SNAPSHOT")
+ .withConfigurationResource("kubernetes-with-env-from-configmap-with-prefix-behaviors.properties");
+
+ @ProdBuildResults
+ private ProdModeTestResults prodModeTestResults;
+
+ @Test
+ public void assertGeneratedResources() throws IOException {
+ Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
+ assertThat(kubernetesDir)
+ .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json"))
+ .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml"));
+ List kubernetesList = DeserializationUtil
+ .deserializeAsList(kubernetesDir.resolve("kubernetes.yml"));
+ assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> {
+ assertThat(d.getMetadata()).satisfies(m -> {
+ assertThat(m.getName()).isEqualTo("env-from-config-map-with-prefix-behaviors");
+ });
+
+ assertThat(d.getSpec()).satisfies(deploymentSpec -> {
+ assertThat(deploymentSpec.getTemplate()).satisfies(t -> {
+ assertThat(t.getSpec()).satisfies(podSpec -> {
+ assertThat(podSpec.getContainers()).singleElement().satisfies(container -> {
+ assertThat(container.getEnvFrom()).hasSize(3);
+ assertThat(container.getEnvFrom())
+ .anyMatch(item -> item.getConfigMapRef().getName().equals("another")
+ && !item.getPrefix().isBlank());
+ assertThat(container.getEnvFrom())
+ .anyMatch(item -> item.getConfigMapRef().getName().equals("configmap")
+ && !item.getPrefix().isBlank());
+ assertThat(container.getEnvFrom()).anyMatch(
+ item -> item.getConfigMapRef().getName().equals("without") && item.getPrefix() == null);
+
+ });
+ });
+ });
+ });
+ });
+ }
+}
diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromConfigMapWithPrefixTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromConfigMapWithPrefixTest.java
new file mode 100644
index 00000000000000..4bc4120a251b02
--- /dev/null
+++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromConfigMapWithPrefixTest.java
@@ -0,0 +1,60 @@
+package io.quarkus.it.kubernetes;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import io.fabric8.kubernetes.api.model.HasMetadata;
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+import io.quarkus.test.ProdBuildResults;
+import io.quarkus.test.ProdModeTestResults;
+import io.quarkus.test.QuarkusProdModeTest;
+
+public class KubernetesWithEnvFromConfigMapWithPrefixTest {
+
+ @RegisterExtension
+ static final QuarkusProdModeTest config = new QuarkusProdModeTest()
+ .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class))
+ .setApplicationName("env-from-config-map-with-prefix")
+ .setApplicationVersion("0.1-SNAPSHOT")
+ .withConfigurationResource("kubernetes-with-env-from-configmap-with-prefix.properties");
+
+ @ProdBuildResults
+ private ProdModeTestResults prodModeTestResults;
+
+ @Test
+ public void assertGeneratedResources() throws IOException {
+ Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
+ assertThat(kubernetesDir)
+ .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json"))
+ .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml"));
+ List kubernetesList = DeserializationUtil
+ .deserializeAsList(kubernetesDir.resolve("kubernetes.yml"));
+ assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> {
+ assertThat(d.getMetadata()).satisfies(m -> {
+ assertThat(m.getName()).isEqualTo("env-from-config-map-with-prefix");
+ });
+
+ assertThat(d.getSpec()).satisfies(deploymentSpec -> {
+ assertThat(deploymentSpec.getTemplate()).satisfies(t -> {
+ assertThat(t.getSpec()).satisfies(podSpec -> {
+ assertThat(podSpec.getContainers()).singleElement().satisfies(container -> {
+
+ assertThat(container.getEnvFrom()).satisfies(env -> {
+
+ assertThat(env).anyMatch(item -> item.getPrefix().equals("QUARKUS") &&
+ item.getConfigMapRef().getName().equals("my-config-map"));
+
+ });
+ });
+ });
+ });
+ });
+ });
+ }
+}
diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromSecretWithPrefixBehaviorsTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromSecretWithPrefixBehaviorsTest.java
new file mode 100644
index 00000000000000..5e06646bee03e0
--- /dev/null
+++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromSecretWithPrefixBehaviorsTest.java
@@ -0,0 +1,62 @@
+package io.quarkus.it.kubernetes;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import io.fabric8.kubernetes.api.model.HasMetadata;
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+import io.quarkus.test.ProdBuildResults;
+import io.quarkus.test.ProdModeTestResults;
+import io.quarkus.test.QuarkusProdModeTest;
+
+public class KubernetesWithEnvFromSecretWithPrefixBehaviorsTest {
+
+ @RegisterExtension
+ static final QuarkusProdModeTest config = new QuarkusProdModeTest()
+ .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class))
+ .setApplicationName("env-from-secret-with-prefix-behaviors")
+ .setApplicationVersion("0.1-SNAPSHOT")
+ .withConfigurationResource("kubernetes-with-env-from-secret-with-prefix-behaviors.properties");
+
+ @ProdBuildResults
+ private ProdModeTestResults prodModeTestResults;
+
+ @Test
+ public void assertGeneratedResources() throws IOException {
+ Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
+ assertThat(kubernetesDir)
+ .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json"))
+ .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml"));
+ List kubernetesList = DeserializationUtil
+ .deserializeAsList(kubernetesDir.resolve("kubernetes.yml"));
+ assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> {
+ assertThat(d.getMetadata()).satisfies(m -> {
+ assertThat(m.getName()).isEqualTo("env-from-secret-with-prefix-behaviors");
+ });
+
+ assertThat(d.getSpec()).satisfies(deploymentSpec -> {
+ assertThat(deploymentSpec.getTemplate()).satisfies(t -> {
+ assertThat(t.getSpec()).satisfies(podSpec -> {
+ assertThat(podSpec.getContainers()).singleElement().satisfies(container -> {
+
+ assertThat(container.getEnvFrom())
+ .anyMatch(item -> item.getPrefix() != null && !item.getPrefix().isBlank()
+ && item.getSecretRef().getName().equals("another"));
+ assertThat(container.getEnvFrom())
+ .anyMatch(item -> item.getPrefix() != null && !item.getPrefix().isBlank()
+ && item.getSecretRef().getName().equals("secrets"));
+ assertThat(container.getEnvFrom()).anyMatch(
+ item -> item.getPrefix() == null && item.getSecretRef().getName().equals("without"));
+ });
+ });
+ });
+ });
+ });
+ }
+}
diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromSecretWithPrefixTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromSecretWithPrefixTest.java
new file mode 100644
index 00000000000000..985c374f711a30
--- /dev/null
+++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithEnvFromSecretWithPrefixTest.java
@@ -0,0 +1,69 @@
+package io.quarkus.it.kubernetes;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import io.fabric8.kubernetes.api.model.HasMetadata;
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+import io.quarkus.test.ProdBuildResults;
+import io.quarkus.test.ProdModeTestResults;
+import io.quarkus.test.QuarkusProdModeTest;
+
+public class KubernetesWithEnvFromSecretWithPrefixTest {
+
+ @RegisterExtension
+ static final QuarkusProdModeTest config = new QuarkusProdModeTest()
+ .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class))
+ .setApplicationName("env-from-secret-with-prefix")
+ .setApplicationVersion("0.1-SNAPSHOT")
+ .withConfigurationResource("kubernetes-with-env-from-secret-with-prefix.properties");
+
+ @ProdBuildResults
+ private ProdModeTestResults prodModeTestResults;
+
+ @Test
+ public void assertGeneratedResources() throws IOException {
+ Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
+ assertThat(kubernetesDir)
+ .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json"))
+ .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml"));
+ List kubernetesList = DeserializationUtil
+ .deserializeAsList(kubernetesDir.resolve("kubernetes.yml"));
+ assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> {
+ assertThat(d.getMetadata()).satisfies(m -> {
+ assertThat(m.getName()).isEqualTo("env-from-secret-with-prefix");
+ });
+
+ assertThat(d.getSpec()).satisfies(deploymentSpec -> {
+ assertThat(deploymentSpec.getTemplate()).satisfies(t -> {
+ assertThat(t.getSpec()).satisfies(podSpec -> {
+ assertThat(podSpec.getContainers()).singleElement().satisfies(container -> {
+ assertThat(container.getEnvFrom()).singleElement().satisfies(env -> {
+ assertThat(env.getPrefix()).isEqualTo("QUARKUS");
+ assertThat(env.getSecretRef()).satisfies(secretRef -> {
+ assertThat(secretRef.getName()).isEqualTo("my-secret");
+ });
+ });
+
+ assertThat(container.getEnv()).filteredOn(env -> "DB_PASSWORD".equals(env.getName()))
+ .singleElement().satisfies(env -> {
+ assertThat(env.getValueFrom()).satisfies(valueFrom -> {
+ assertThat(valueFrom.getSecretKeyRef()).satisfies(secretKeyRef -> {
+ assertThat(secretKeyRef.getKey()).isEqualTo("database.password");
+ assertThat(secretKeyRef.getName()).isEqualTo("db-secret");
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ }
+}
diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-configmap-with-prefix-behaviors.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-configmap-with-prefix-behaviors.properties
new file mode 100644
index 00000000000000..faaaa717a5d66a
--- /dev/null
+++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-configmap-with-prefix-behaviors.properties
@@ -0,0 +1,11 @@
+quarkus.kubernetes.env.configmaps=configmap,another,without
+
+quarkus.kubernetes.env.prefix."PREFIX".from-configmap=configmap
+quarkus.kubernetes.env.prefix."QUARKUS".from-configmap=another
+
+# should be ignored because was declared later
+quarkus.kubernetes.env.prefix."ANOTHER".from-configmap=another
+quarkus.kubernetes.env.prefix."HELLO".from-configmap=configmap
+
+# blank
+quarkus.kubernetes.env.prefix."".from-configmap=without
diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-configmap-with-prefix.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-configmap-with-prefix.properties
new file mode 100644
index 00000000000000..5e40a3730ac34b
--- /dev/null
+++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-configmap-with-prefix.properties
@@ -0,0 +1,3 @@
+quarkus.kubernetes.env.configmaps=my-config-map,another-config-map
+quarkus.kubernetes.env.prefix."QUARKUS".from-configmap=my-config-map
+quarkus.kubernetes.env.prefix."QUARKIVERSE".from-configmap=another-config-map
diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-secret-with-prefix-behaviors.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-secret-with-prefix-behaviors.properties
new file mode 100644
index 00000000000000..89f5521920177f
--- /dev/null
+++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-secret-with-prefix-behaviors.properties
@@ -0,0 +1,10 @@
+quarkus.kubernetes.env.secrets=secrets,another,without
+
+# the order is not guaranteed by the extension
+quarkus.kubernetes.env.prefix."HELLO".from-secret=secrets
+quarkus.kubernetes.env.prefix."QUARKUS".from-secret=another
+quarkus.kubernetes.env.prefix."ANOTHER".from-secret=another
+quarkus.kubernetes.env.prefix."PREFIX".from-secret=secrets
+
+# blank
+quarkus.kubernetes.env.prefix."".from-secret=without
\ No newline at end of file
diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-secret-with-prefix.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-secret-with-prefix.properties
new file mode 100644
index 00000000000000..51c9f0ac30e8ec
--- /dev/null
+++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-env-from-secret-with-prefix.properties
@@ -0,0 +1,4 @@
+quarkus.kubernetes.env.secrets=my-secret
+quarkus.kubernetes.env.prefix."QUARKUS".from-secret=my-secret
+quarkus.kubernetes.env.mapping.db-password.from-secret=db-secret
+quarkus.kubernetes.env.mapping.db-password.with-key=database.password
\ No newline at end of file