Skip to content

Commit

Permalink
Change default image for init container waiters
Browse files Browse the repository at this point in the history
To groundnuty/k8s-wait-for:no-root-v1.7.

Related to quarkusio#33097 (comment)
  • Loading branch information
Sgitario committed May 18, 2023
1 parent 9d2fff9 commit 1a6b852
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public final class KubernetesInitContainerBuildItem extends MultiBuildItem {
private final boolean sharedEnvironment;
private final boolean sharedFilesystem;

public static KubernetesInitContainerBuildItem create(String image) {
return new KubernetesInitContainerBuildItem("init", null, image, Collections.emptyList(), Collections.emptyList(),
public static KubernetesInitContainerBuildItem create(String name, String image) {
return new KubernetesInitContainerBuildItem(name, null, image, Collections.emptyList(), Collections.emptyList(),
Collections.emptyMap(), false, false);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.quarkus.kubernetes.deployment;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

Expand All @@ -20,6 +20,9 @@

public class InitTaskProcessor {

private static final String INIT_CONTAINER_WAITER_NAME = "init";
private static final String INIT_CONTAINER_WAITER_DEFAULT_IMAGE = "groundnuty/k8s-wait-for:no-root-v1.7";

static void process(
String target, // kubernetes, openshift, etc.
String name,
Expand All @@ -31,11 +34,11 @@ static void process(
BuildProducer<KubernetesRoleBindingBuildItem> roleBindings,
BuildProducer<DecoratorBuildItem> decorators) {

initTasks.forEach(task -> {
initContainers.produce(KubernetesInitContainerBuildItem.create("groundnuty/k8s-wait-for:1.3")
.withTarget(target)
.withArguments(Arrays.asList("job", task.getName())));
List<String> initContainerWaiterArgs = new ArrayList<>(initTasks.size() + 1);
initContainerWaiterArgs.add("job");

initTasks.forEach(task -> {
initContainerWaiterArgs.add(task.getName());
jobs.produce(KubernetesJobBuildItem.create(image.getImage())
.withName(task.getName())
.withTarget(target)
Expand All @@ -53,7 +56,9 @@ static void process(
.build())));

});
});

if (!initTasks.isEmpty()) {
roles.produce(new KubernetesRoleBuildItem("view-jobs", Collections.singletonList(
new PolicyRule(
Collections.singletonList("batch"),
Expand All @@ -62,6 +67,10 @@ static void process(
target));
roleBindings.produce(new KubernetesRoleBindingBuildItem(null, "view-jobs", false, target));

});
initContainers.produce(KubernetesInitContainerBuildItem.create(INIT_CONTAINER_WAITER_NAME,
INIT_CONTAINER_WAITER_DEFAULT_IMAGE)
.withTarget(target)
.withArguments(initContainerWaiterArgs));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public void assertGeneratedResources() throws IOException {
assertThat(t.getSpec()).satisfies(podSpec -> {
assertThat(podSpec.getInitContainers()).singleElement().satisfies(container -> {
assertThat(container.getName()).isEqualTo("init");
assertThat(container.getImage()).isEqualTo("groundnuty/k8s-wait-for:no-root-v1.7");
});

});
Expand Down

0 comments on commit 1a6b852

Please sign in to comment.