diff --git a/operator/src/main/java/org/keycloak/operator/Config.java b/operator/src/main/java/org/keycloak/operator/Config.java index 9967a7dd61..e54c356078 100644 --- a/operator/src/main/java/org/keycloak/operator/Config.java +++ b/operator/src/main/java/org/keycloak/operator/Config.java @@ -29,8 +29,5 @@ public interface Config { interface Keycloak { String image(); String imagePullPolicy(); - - String initContainerImage(); - String initContainerImagePullPolicy(); } } diff --git a/operator/src/main/java/org/keycloak/operator/Constants.java b/operator/src/main/java/org/keycloak/operator/Constants.java index 6d8a705c8b..fe9ae6afee 100644 --- a/operator/src/main/java/org/keycloak/operator/Constants.java +++ b/operator/src/main/java/org/keycloak/operator/Constants.java @@ -40,13 +40,6 @@ public final class Constants { "cache-stack", "kubernetes" ); - // Init container - public static final String EXTENSIONS_VOLUME_NAME = "extensions"; - public static final String KEYCLOAK_PROVIDERS_FOLDER = "/opt/keycloak/providers"; - public static final String INIT_CONTAINER_NAME = "keycloak-extensions"; - public static final String INIT_CONTAINER_EXTENSIONS_FOLDER = "/opt/extensions"; - public static final String INIT_CONTAINER_EXTENSIONS_ENV_VAR = "KEYCLOAK_EXTENSIONS"; - public static final Integer KEYCLOAK_HTTP_PORT = 8080; public static final Integer KEYCLOAK_HTTPS_PORT = 8443; public static final String KEYCLOAK_SERVICE_PROTOCOL = "TCP"; diff --git a/operator/src/main/java/org/keycloak/operator/v2alpha1/KeycloakDeployment.java b/operator/src/main/java/org/keycloak/operator/v2alpha1/KeycloakDeployment.java index 03cdc29c0d..0ac52107fa 100644 --- a/operator/src/main/java/org/keycloak/operator/v2alpha1/KeycloakDeployment.java +++ b/operator/src/main/java/org/keycloak/operator/v2alpha1/KeycloakDeployment.java @@ -17,7 +17,6 @@ package org.keycloak.operator.v2alpha1; import io.fabric8.kubernetes.api.model.Container; -import io.fabric8.kubernetes.api.model.ContainerBuilder; import io.fabric8.kubernetes.api.model.EnvVar; import io.fabric8.kubernetes.api.model.EnvVarBuilder; import io.fabric8.kubernetes.api.model.EnvVarSourceBuilder; @@ -40,7 +39,6 @@ import org.keycloak.operator.v2alpha1.crds.KeycloakStatusBuilder; import org.keycloak.operator.v2alpha1.crds.ValueOrSecret; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -116,60 +114,6 @@ public class KeycloakDeployment extends OperatorManagedResource implements Statu .get(); } - private void addInitContainer(Deployment baseDeployment, List extensions) { - var skipExtensions = Optional - .ofNullable(extensions) - .map(e -> e.isEmpty()) - .orElse(true); - - if (skipExtensions) { - return; - } - - // Add emptyDir Volume - var volumes = baseDeployment.getSpec().getTemplate().getSpec().getVolumes(); - - var extensionVolume = new VolumeBuilder() - .withName(Constants.EXTENSIONS_VOLUME_NAME) - .withNewEmptyDir() - .endEmptyDir() - .build(); - - volumes.add(extensionVolume); - baseDeployment.getSpec().getTemplate().getSpec().setVolumes(volumes); - - // Add the main deployment Volume Mount - var container = baseDeployment.getSpec().getTemplate().getSpec().getContainers().get(0); - var containerVolumeMounts = container.getVolumeMounts(); - - var extensionVM = new VolumeMountBuilder() - .withName(Constants.EXTENSIONS_VOLUME_NAME) - .withMountPath(Constants.KEYCLOAK_PROVIDERS_FOLDER) - .withReadOnly(true) - .build(); - containerVolumeMounts.add(extensionVM); - - container.setVolumeMounts(containerVolumeMounts); - - // Add the Extensions downloader init container - var extensionsValue = extensions.stream().collect(Collectors.joining(",")); - var initContainer = new ContainerBuilder() - .withName(Constants.INIT_CONTAINER_NAME) - .withImage(config.keycloak().initContainerImage()) - .withImagePullPolicy(config.keycloak().initContainerImagePullPolicy()) - .addNewVolumeMount() - .withName(Constants.EXTENSIONS_VOLUME_NAME) - .withMountPath(Constants.INIT_CONTAINER_EXTENSIONS_FOLDER) - .endVolumeMount() - .addNewEnv() - .withName(Constants.INIT_CONTAINER_EXTENSIONS_ENV_VAR) - .withValue(extensionsValue) - .endEnv() - .build(); - - baseDeployment.getSpec().getTemplate().getSpec().setInitContainers(Collections.singletonList(initContainer)); - } - public void validatePodTemplate(KeycloakStatusBuilder status) { if (keycloakCR.getSpec() == null || keycloakCR.getSpec().getUnsupported() == null || @@ -465,7 +409,6 @@ public class KeycloakDeployment extends OperatorManagedResource implements Statu configureHostname(baseDeployment); configureTLS(baseDeployment); - addInitContainer(baseDeployment, keycloakCR.getSpec().getExtensions()); mergePodTemplate(baseDeployment.getSpec().getTemplate()); return baseDeployment; diff --git a/operator/src/main/java/org/keycloak/operator/v2alpha1/crds/KeycloakSpec.java b/operator/src/main/java/org/keycloak/operator/v2alpha1/crds/KeycloakSpec.java index cce1b8384f..cf8503a0c7 100644 --- a/operator/src/main/java/org/keycloak/operator/v2alpha1/crds/KeycloakSpec.java +++ b/operator/src/main/java/org/keycloak/operator/v2alpha1/crds/KeycloakSpec.java @@ -40,8 +40,6 @@ public class KeycloakSpec { private String tlsSecret; @JsonPropertyDescription("Disable the default ingress.") private boolean disableDefaultIngress; - @JsonPropertyDescription("List of URLs to download Keycloak extensions.") - private List extensions; @JsonPropertyDescription( "In this section you can configure podTemplate advanced features, not production-ready, and not supported settings.\n" + "Use at your own risk and open an issue with your use-case if you don't find an alternative way.") @@ -79,14 +77,6 @@ public class KeycloakSpec { return this.tlsSecret.equals(Constants.INSECURE_DISABLE); } - public List getExtensions() { - return extensions; - } - - public void setExtensions(List extensions) { - this.extensions = extensions; - } - public Unsupported getUnsupported() { return unsupported; } diff --git a/operator/src/main/resources/application.properties b/operator/src/main/resources/application.properties index 57c11002c4..54819207f6 100644 --- a/operator/src/main/resources/application.properties +++ b/operator/src/main/resources/application.properties @@ -7,6 +7,3 @@ quarkus.operator-sdk.crd.validate=false # Operator config operator.keycloak.image=quay.io/keycloak/keycloak:latest operator.keycloak.image-pull-policy=Always - -operator.keycloak.init-container-image=quay.io/keycloak/keycloak-init-container:legacy -operator.keycloak.init-container-image-pull-policy=Always diff --git a/operator/src/test/java/org/keycloak/operator/KeycloakDeploymentE2EIT.java b/operator/src/test/java/org/keycloak/operator/KeycloakDeploymentE2EIT.java index 0a7b49866d..54a0699ac0 100644 --- a/operator/src/test/java/org/keycloak/operator/KeycloakDeploymentE2EIT.java +++ b/operator/src/test/java/org/keycloak/operator/KeycloakDeploymentE2EIT.java @@ -16,7 +16,6 @@ import org.keycloak.operator.v2alpha1.crds.ValueOrSecret; import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Base64; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; @@ -25,7 +24,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.keycloak.operator.Constants.DEFAULT_LABELS; import static org.keycloak.operator.utils.K8sUtils.deployKeycloak; import static org.keycloak.operator.utils.K8sUtils.getDefaultKeycloakDeployment; import static org.keycloak.operator.utils.K8sUtils.waitForKeycloakToBeReady; @@ -158,36 +156,6 @@ public class KeycloakDeploymentE2EIT extends ClusterOperatorTest { } } - @Test - public void testExtensions() { - try { - var kc = getDefaultKeycloakDeployment(); - kc.getSpec().setExtensions( - Collections.singletonList( - "https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar")); - deployKeycloak(k8sclient, kc, true); - - var kcPod = k8sclient - .pods() - .inNamespace(namespace) - .withLabels(DEFAULT_LABELS) - .list() - .getItems() - .get(0); - - Awaitility.await() - .ignoreExceptions() - .untilAsserted(() -> { - var logs = k8sclient.pods().inNamespace(namespace).withName(kcPod.getMetadata().getName()).getLog(); - - assertTrue(logs.contains("metrics-listener (org.jboss.aerogear.keycloak.metrics.MetricsEventListenerFactory) is implementing the internal SPI")); - }); - } catch (Exception e) { - savePodLogs(); - throw e; - } - } - @Test public void testTlsUsesCorrectSecret() { try { diff --git a/operator/src/test/java/org/keycloak/operator/PodTemplateTest.java b/operator/src/test/java/org/keycloak/operator/PodTemplateTest.java index 79e68ef205..ae78e33e3b 100644 --- a/operator/src/test/java/org/keycloak/operator/PodTemplateTest.java +++ b/operator/src/test/java/org/keycloak/operator/PodTemplateTest.java @@ -33,10 +33,6 @@ public class PodTemplateTest { public String imagePullPolicy() { return "Never"; } - @Override - public String initContainerImage() { return "quay.io/keycloak/keycloak-init-container:legacy"; } - @Override - public String initContainerImagePullPolicy() { return "Always"; } }; } };