diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ApplyResolveNamesImagePolicyDecorator.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ApplyResolveNamesImagePolicyDecorator.java new file mode 100644 index 0000000000000..1a41c96452c74 --- /dev/null +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/ApplyResolveNamesImagePolicyDecorator.java @@ -0,0 +1,13 @@ +package io.quarkus.kubernetes.deployment; + +import io.dekorate.kubernetes.decorator.NamedResourceDecorator; +import io.fabric8.kubernetes.api.model.ObjectMeta; +import io.fabric8.kubernetes.api.model.PodTemplateSpecFluent; + +public class ApplyResolveNamesImagePolicyDecorator extends NamedResourceDecorator> { + + @Override + public void andThenVisit(PodTemplateSpecFluent podTemplate, ObjectMeta meta) { + podTemplate.editOrNewMetadata().addToAnnotations("alpha.image.policy.openshift.io/resolve-names", "*").endMetadata(); + } +} 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 18fa42dbc4e26..f49540aed39ef 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 @@ -236,6 +236,8 @@ public List createDecorators(ApplicationInfoBuildItem applic result.add(new DecoratorBuildItem(new RemoveOptionalFromConfigMapKeySelectorDecorator())); } + result.add(new DecoratorBuildItem(new ApplyResolveNamesImagePolicyDecorator())); + DeploymentResourceKind deploymentKind = config.getDeploymentResourceKind(capabilities); switch (deploymentKind) { case Deployment: diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithDeploymentResourceAndLocalLookupTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithDeploymentResourceAndLocalLookupTest.java index ffbb34a7cd4e6..5c586feddcaba 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithDeploymentResourceAndLocalLookupTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithDeploymentResourceAndLocalLookupTest.java @@ -71,6 +71,9 @@ public void assertGeneratedResources() throws IOException { assertThat(d.getSpec()).satisfies(deploymentSpec -> { assertThat(deploymentSpec.getTemplate()).satisfies(t -> { + assertThat(t.getMetadata()).satisfies(metadata -> assertThat(metadata.getAnnotations()).contains( + entry("alpha.image.policy.openshift.io/resolve-names", "*"))); + assertThat(t.getMetadata()).satisfies(metadata -> assertThat(metadata.getLabels()).containsAnyOf( entry("app.kubernetes.io/name", NAME), entry("app.kubernetes.io/version", "0.1-SNAPSHOT")));