From 541043c862a712da285ad893de8f93eb16fd1621 Mon Sep 17 00:00:00 2001 From: andreaTP Date: Fri, 11 Feb 2022 11:55:57 +0000 Subject: [PATCH] Run the operator tests using a fresh build of Keycloak --- .github/workflows/operator-ci.yml | 14 ++++++++++++-- operator/README.md | 14 ++++++++++++++ .../main/java/org/keycloak/operator/Config.java | 1 + .../operator/v2alpha1/KeycloakDeployment.java | 2 ++ operator/src/main/resources/application.properties | 3 ++- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/workflows/operator-ci.yml b/.github/workflows/operator-ci.yml index 74c01f556f..9fee4a43df 100644 --- a/.github/workflows/operator-ci.yml +++ b/.github/workflows/operator-ci.yml @@ -32,7 +32,7 @@ jobs: - name: Create the Keycloak distribution run: | - mvn clean install -DskipTests -DskipExamples -DskipTestsuite + mvn clean install -Pdistribution -DskipTests -DskipExamples -DskipTestsuite - name: Setup Minikube-Kubernetes uses: manusa/actions-setup-minikube@v2.4.3 @@ -41,6 +41,15 @@ jobs: kubernetes version: v1.22.3 github token: ${{ secrets.GITHUB_TOKEN }} driver: docker + + - name: Build the Keycloak Docker image + run: | + cd quarkus + cp dist/target/keycloak-*.tar.gz container/ + cd container + eval $(minikube -p minikube docker-env) + docker build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t keycloak:${GITHUB_SHA} + - name: Build , deploy and test operator in minikube run: | cd operator @@ -48,4 +57,5 @@ jobs: mvn clean verify \ -Dquarkus.container-image.build=true -Dquarkus.container-image.tag=test \ -Dquarkus.kubernetes.deployment-target=kubernetes \ - --no-transfer-progress -Dtest.operator.deployment=remote \ No newline at end of file + -Dquarkus.jib.jvm-arguments="-Djava.util.logging.manager=org.jboss.logmanager.LogManager","-Doperator.keycloak.image=keycloak:${GITHUB_SHA}","-Doperator.keycloak.image-pull-policy=Never" \ + --no-transfer-progress -Dtest.operator.deployment=remote diff --git a/operator/README.md b/operator/README.md index 8b7316eebf..8e732f9067 100644 --- a/operator/README.md +++ b/operator/README.md @@ -17,6 +17,20 @@ Build the Docker image with: mvn clean package -Doperator -Dquarkus.container-image.build=true ``` +## Configuration + +The Keycloak image can be configured, when starting the operator, using the Java property: + +``` +operator.keycloak.image +``` + +And the imagePullPolicy with: + +``` +operator.keycloak.image-pull-policy +``` + ## Contributing ### Quick start on Minikube diff --git a/operator/src/main/java/org/keycloak/operator/Config.java b/operator/src/main/java/org/keycloak/operator/Config.java index edbde13324..e54c356078 100644 --- a/operator/src/main/java/org/keycloak/operator/Config.java +++ b/operator/src/main/java/org/keycloak/operator/Config.java @@ -28,5 +28,6 @@ public interface Config { interface Keycloak { String image(); + String imagePullPolicy(); } } 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 a63c61d121..f83ff4d55f 100644 --- a/operator/src/main/java/org/keycloak/operator/v2alpha1/KeycloakDeployment.java +++ b/operator/src/main/java/org/keycloak/operator/v2alpha1/KeycloakDeployment.java @@ -105,6 +105,8 @@ public class KeycloakDeployment extends OperatorManagedResource { serverConfig.putAll(keycloakCR.getSpec().getServerConfiguration()); } + container.setImagePullPolicy(config.keycloak().imagePullPolicy()); + container.setEnv(serverConfig.entrySet().stream() .map(e -> new EnvVarBuilder().withName(e.getKey()).withValue(e.getValue()).build()) .collect(Collectors.toList())); diff --git a/operator/src/main/resources/application.properties b/operator/src/main/resources/application.properties index db36f07018..2561345ada 100644 --- a/operator/src/main/resources/application.properties +++ b/operator/src/main/resources/application.properties @@ -5,4 +5,5 @@ quarkus.container-image.builder=jib quarkus.operator-sdk.crd.validate=false # Operator config -operator.keycloak.image=quay.io/keycloak/keycloak-x:latest \ No newline at end of file +operator.keycloak.image=quay.io/keycloak/keycloak-x:latest +operator.keycloak.image-pull-policy=Always