diff --git a/extensions/kubernetes/openshift/deployment/pom.xml b/extensions/kubernetes/openshift/deployment/pom.xml
index d4c4f315d6628..d6db4ae0a1272 100644
--- a/extensions/kubernetes/openshift/deployment/pom.xml
+++ b/extensions/kubernetes/openshift/deployment/pom.xml
@@ -49,6 +49,11 @@
quarkus-junit5-internal
test
+
+ io.smallrye.config
+ smallrye-config-source-yaml
+ test
+
diff --git a/extensions/kubernetes/openshift/deployment/src/test/java/io/quarkus/openshift/deployment/config/OpenshiftConfigFallbackTest.java b/extensions/kubernetes/openshift/deployment/src/test/java/io/quarkus/openshift/deployment/config/OpenshiftConfigFallbackTest.java
new file mode 100644
index 0000000000000..dabca1dacb383
--- /dev/null
+++ b/extensions/kubernetes/openshift/deployment/src/test/java/io/quarkus/openshift/deployment/config/OpenshiftConfigFallbackTest.java
@@ -0,0 +1,47 @@
+package io.quarkus.openshift.deployment.config;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.nio.file.Path;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import io.quarkus.test.ProdBuildResults;
+import io.quarkus.test.ProdModeTestResults;
+import io.quarkus.test.QuarkusProdModeTest;
+import io.smallrye.config.source.yaml.YamlConfigSource;
+
+public class OpenshiftConfigFallbackTest {
+ @RegisterExtension
+ static final QuarkusProdModeTest TEST = new QuarkusProdModeTest()
+ .setApplicationName("config")
+ .setApplicationVersion("0.1-SNAPSHOT")
+ .overrideConfigKey("quarkus.kubernetes.replicas", "10")
+ .overrideConfigKey("quarkus.openshift.version", "999-SNAPSHOT")
+ .overrideConfigKey("quarkus.openshift.labels.app", "openshift")
+ .setRun(true);
+
+ @ProdBuildResults
+ private ProdModeTestResults prodModeTestResults;
+
+ @Test
+ void configFallback() throws Exception {
+ Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
+ YamlConfigSource kubernetes = new YamlConfigSource(kubernetesDir.resolve("kubernetes.yml").toUri().toURL());
+ YamlConfigSource openshift = new YamlConfigSource(kubernetesDir.resolve("openshift.yml").toUri().toURL());
+
+ // Only in Kubernetes, must fallback to Openshift
+ assertEquals("10", kubernetes.getValue("spec.replicas"));
+ assertEquals("10", openshift.getValue("spec.replicas"));
+
+ // In both, each should retain the value
+ assertEquals("0.1-SNAPSHOT", kubernetes.getValue("spec.template.metadata.labels.\"app.kubernetes.io/version\""));
+ assertEquals("999-SNAPSHOT", openshift.getValue("spec.template.metadata.labels.\"app.kubernetes.io/version\""));
+
+ // Only in Openshift
+ assertNull(kubernetes.getValue("spec.template.metadata.labels.app"));
+ assertEquals("openshift", openshift.getValue("spec.template.metadata.labels.app"));
+ }
+}
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 9b93c34187f78..0665c7e461f8f 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
@@ -40,7 +40,6 @@
import io.quarkus.container.image.deployment.ContainerImageConfig;
import io.quarkus.container.image.deployment.util.ImageUtil;
import io.quarkus.container.spi.BaseImageInfoBuildItem;
-import io.quarkus.container.spi.ContainerImageCustomNameBuildItem;
import io.quarkus.container.spi.ContainerImageInfoBuildItem;
import io.quarkus.container.spi.ContainerImageLabelBuildItem;
import io.quarkus.container.spi.FallbackContainerImageRegistryBuildItem;
@@ -102,12 +101,6 @@ public void checkOpenshift(ApplicationInfoBuildItem applicationInfo, Capabilitie
}
}
- @BuildStep
- public void populateCustomImageName(OpenshiftConfig openshiftConfig,
- BuildProducer containerImageCustomName) {
- openshiftConfig.name.ifPresent(name -> containerImageCustomName.produce(new ContainerImageCustomNameBuildItem(name)));
- }
-
@BuildStep
public void populateInternalRegistry(OpenshiftConfig openshiftConfig, ContainerImageConfig containerImageConfig,
Capabilities capabilities,
diff --git a/extensions/kubernetes/vanilla/runtime/src/main/java/io/quarkus/kubernetes/runtime/config/KubernetesConfigFallback.java b/extensions/kubernetes/vanilla/runtime/src/main/java/io/quarkus/kubernetes/runtime/config/KubernetesConfigFallback.java
new file mode 100644
index 0000000000000..c5d4d112e3b3b
--- /dev/null
+++ b/extensions/kubernetes/vanilla/runtime/src/main/java/io/quarkus/kubernetes/runtime/config/KubernetesConfigFallback.java
@@ -0,0 +1,27 @@
+package io.quarkus.kubernetes.runtime.config;
+
+import java.util.function.Function;
+
+import io.smallrye.config.FallbackConfigSourceInterceptor;
+
+public class KubernetesConfigFallback extends FallbackConfigSourceInterceptor {
+ private static final String QUARKUS_KUBERNETES_CONFIG_PREFIX = "quarkus.kubernetes.";
+ private static final String QUARKUS_OPENSHIFT_CONFIG_PREFIX = "quarkus.openshift.";
+ private static final int OPENSHIFT_CONFIG_NAME_BEGIN = QUARKUS_OPENSHIFT_CONFIG_PREFIX.length();
+ private static final String QUARKUS_KNATIVE_CONFIG_PREFIX = "quarkus.knative.";
+ private static final int KNATIVE_CONFIG_NAME_BEGIN = QUARKUS_KNATIVE_CONFIG_PREFIX.length();
+
+ public KubernetesConfigFallback() {
+ super(new Function() {
+ @Override
+ public String apply(final String name) {
+ if (name.startsWith(QUARKUS_OPENSHIFT_CONFIG_PREFIX)) {
+ return QUARKUS_KUBERNETES_CONFIG_PREFIX + name.substring(OPENSHIFT_CONFIG_NAME_BEGIN);
+ } else if (name.startsWith(QUARKUS_KNATIVE_CONFIG_PREFIX)) {
+ return QUARKUS_KUBERNETES_CONFIG_PREFIX + name.substring(KNATIVE_CONFIG_NAME_BEGIN);
+ }
+ return name;
+ }
+ });
+ }
+}
diff --git a/extensions/kubernetes/vanilla/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor b/extensions/kubernetes/vanilla/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor
new file mode 100644
index 0000000000000..9928c53030f95
--- /dev/null
+++ b/extensions/kubernetes/vanilla/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor
@@ -0,0 +1 @@
+io.quarkus.kubernetes.runtime.config.KubernetesConfigFallback
diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithCustomNameTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithCustomNameTest.java
index 4325e490bff1a..c2cdc5b6e86d0 100644
--- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithCustomNameTest.java
+++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithCustomNameTest.java
@@ -72,14 +72,6 @@ public void assertGeneratedResources() throws IOException {
assertThat(t.getMetadata()).satisfies(metadata -> assertThat(metadata.getLabels()).containsAnyOf(
entry("app.kubernetes.io/name", CUSTOM_NAME),
entry("app.kubernetes.io/version", "0.1-SNAPSHOT")));
-
- assertThat(t.getSpec()).satisfies(podSpec -> {
- assertThat(podSpec.getContainers()).singleElement().satisfies(container -> {
- assertThat(container.getImage())
- .isEqualTo(
- "testme/" + CUSTOM_NAME + ":0.1-SNAPSHOT");
- });
- });
});
});
});