diff --git a/extensions/kubernetes/kind/deployment/src/main/java/io/quarkus/kind/deployment/KindProcessor.java b/extensions/kubernetes/kind/deployment/src/main/java/io/quarkus/kind/deployment/KindProcessor.java index 94a42ab4c9c5a..dd6a4476d1e4c 100644 --- a/extensions/kubernetes/kind/deployment/src/main/java/io/quarkus/kind/deployment/KindProcessor.java +++ b/extensions/kubernetes/kind/deployment/src/main/java/io/quarkus/kind/deployment/KindProcessor.java @@ -18,6 +18,7 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.ApplicationInfoBuildItem; +import io.quarkus.deployment.builditem.InitTaskBuildItem; import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem; import io.quarkus.deployment.pkg.PackageConfig; import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem; @@ -26,6 +27,7 @@ import io.quarkus.kubernetes.client.spi.KubernetesClientCapabilityBuildItem; import io.quarkus.kubernetes.deployment.AddPortToKubernetesConfig; import io.quarkus.kubernetes.deployment.DevClusterHelper; +import io.quarkus.kubernetes.deployment.InitTaskProcessor; import io.quarkus.kubernetes.deployment.KubernetesCommonHelper; import io.quarkus.kubernetes.deployment.KubernetesConfig; import io.quarkus.kubernetes.deployment.ResourceNameUtil; @@ -135,4 +137,25 @@ public void postBuild(ContainerImageInfoBuildItem image, List initTasks, + BuildProducer jobs, + BuildProducer initContainers, + BuildProducer env, + BuildProducer roles, + BuildProducer roleBindings, + BuildProducer serviceAccount, + + BuildProducer decorators) { + final String name = ResourceNameUtil.getResourceName(config, applicationInfo); + if (config.isExternalizeInit()) { + InitTaskProcessor.process(KIND, name, image, initTasks, config.getInitTaskDefaults(), config.getInitTasks(), + jobs, initContainers, env, roles, roleBindings, serviceAccount, decorators); + } + } +} diff --git a/extensions/kubernetes/minikube/deployment/src/main/java/io/quarkus/minikube/deployment/MinikubeProcessor.java b/extensions/kubernetes/minikube/deployment/src/main/java/io/quarkus/minikube/deployment/MinikubeProcessor.java index 96343e7f69757..77b357d83b753 100644 --- a/extensions/kubernetes/minikube/deployment/src/main/java/io/quarkus/minikube/deployment/MinikubeProcessor.java +++ b/extensions/kubernetes/minikube/deployment/src/main/java/io/quarkus/minikube/deployment/MinikubeProcessor.java @@ -17,12 +17,14 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.ApplicationInfoBuildItem; +import io.quarkus.deployment.builditem.InitTaskBuildItem; import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem; import io.quarkus.deployment.pkg.PackageConfig; import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem; import io.quarkus.kubernetes.client.spi.KubernetesClientCapabilityBuildItem; import io.quarkus.kubernetes.deployment.AddPortToKubernetesConfig; import io.quarkus.kubernetes.deployment.DevClusterHelper; +import io.quarkus.kubernetes.deployment.InitTaskProcessor; import io.quarkus.kubernetes.deployment.KubernetesCommonHelper; import io.quarkus.kubernetes.deployment.KubernetesConfig; import io.quarkus.kubernetes.deployment.ResourceNameUtil; @@ -122,4 +124,25 @@ public List createDecorators(ApplicationInfoBuildItem applic livenessPath, readinessPath, startupPath, roles, clusterRoles, serviceAccounts, roleBindings, customProjectRoot); } -} \ No newline at end of file + + @BuildStep + void externalizeInitTasks( + ApplicationInfoBuildItem applicationInfo, + KubernetesConfig config, + ContainerImageInfoBuildItem image, + List initTasks, + BuildProducer jobs, + BuildProducer initContainers, + BuildProducer env, + BuildProducer roles, + BuildProducer roleBindings, + BuildProducer serviceAccount, + + BuildProducer decorators) { + final String name = ResourceNameUtil.getResourceName(config, applicationInfo); + if (config.isExternalizeInit()) { + InitTaskProcessor.process(MINIKUBE, name, image, initTasks, config.getInitTaskDefaults(), config.getInitTasks(), + jobs, initContainers, env, roles, roleBindings, serviceAccount, decorators); + } + } +} diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/InitTaskProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/InitTaskProcessor.java index cef2deabd6117..c932d1f28b665 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/InitTaskProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/InitTaskProcessor.java @@ -24,7 +24,7 @@ public class InitTaskProcessor { private static final String INIT_CONTAINER_WAITER_NAME = "wait-for-"; - static void process( + public static void process( String target, // kubernetes, openshift, etc. String name, ContainerImageInfoBuildItem image, diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfig.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfig.java index 999d9c6b0f5a1..6d6e1022707f7 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfig.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfig.java @@ -634,4 +634,16 @@ public KubernetesConfig.DeploymentResourceKind getDeploymentResourceKind(Capabil return DeploymentResourceKind.Deployment; } + + public boolean isExternalizeInit() { + return externalizeInit; + } + + public Map getInitTasks() { + return initTasks; + } + + public InitTaskConfig getInitTaskDefaults() { + return initTaskDefaults; + } }