From bd4622b6a9a1ec6204cabe531f1dc927ac390f53 Mon Sep 17 00:00:00 2001 From: Charles_Sabourdin Date: Fri, 20 Aug 2021 12:44:06 +0200 Subject: [PATCH 01/18] testing KIND_REGISTRY on github action --- .github/workflows/TomcatIntegrationTest.yml | 132 +++++++++++++++++- tomcat/k8s/operator.yaml | 21 ++- .../src/test/java/sample/IntegrationTest.java | 2 +- webserver/k8s/operator.yaml | 22 +++ 4 files changed, 172 insertions(+), 5 deletions(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index 4221783..8c4b2e4 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -21,20 +21,146 @@ jobs: - name: Create kind cluster uses: helm/kind-action@v1.2.0 + with: + cluster_name: ${{ job }} - name: Apply CRDs run: kubectl apply -f tomcat/k8s/crd.yaml - name: Set up Java and Maven - uses: actions/setup-java@v1 + uses: actions/setup-java@v2 with: # java-version: ${{ matrix.java }} java-version: 15 - - uses: actions/cache@v2 + distribution: adopt-hotspot + + - name: cache + uses: actions/cache@v2 + if: ${{ !env.ACT }} with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- + + - name: Set up Maven + uses: stCarolas/setup-maven@v4 + if: ${{ env.ACT }} + with: + maven-version: 3.8.1 + + - name: Run unit tests + if: ${{ env.ACT }} + run: mvn --version + - name: Run unit tests - run: mvn -B test --file tomcat/pom.xml \ No newline at end of file + run: mvn -B test -q --file tomcat/pom.xml + + tomcat_local_apply_setup_test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Helm + uses: azure/setup-helm@v1 + with: + version: v3.4.0 + + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: test + if: ${{ !env.ACT }} + run: | + mkdir -p /etc/docker + echo -n "{\"exec-opts\": [\"native.cgroupdriver=systemd\"],\"log-driver\": \"json-file\",\"log-opts\": {\"max-size\": \"100m\"},\"storage-driver\": \"overlay2\"}" > /etc/docker/daemon.json + cat /etc/docker/daemon.json + sudo service docker status + + - name: Create Kubernetes KinD Cluster + uses: container-tools/kind-action@v1.5.0 + with: + cluster_name: tomcat-local-apply + registry: true + + # - name: Create kind cluster + # uses: helm/kind-action@v1.2.0 + # with: + # cluster_name: tomcat-local-apply #${{ job.name }} + # registry: true + # # docker stop tomcat-local-apply-control-plane ; docker rm tomcat-local-apply-control-plane ; sleep 1 + + - name: Apply CRDs + run: kubectl apply -f tomcat/k8s/crd.yaml + + - name: Set up Java and Maven + uses: actions/setup-java@v2 + with: + # java-version: ${{ matrix.java }} + java-version: 15 + distribution: adopt-hotspot + + - name: cache + uses: actions/cache@v2 + if: ${{ !env.ACT }} + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Set up Maven + uses: stCarolas/setup-maven@v4 + if: ${{ env.ACT }} + with: + maven-version: 3.8.1 + + - name: check that kube is empty + run: kubectl get tomcats,webapps,po + + - name: test local registry + run: | + # Checking env variable + if [[ "$KIND_REGISTRY" != "localhost:5000" ]]; then + echo "Wrong KIND_REGISTRY env variable: $KIND_REGISTRY" + exit 1 + fi + docker pull busybox + docker tag busybox localhost:5000/localbusybox + docker push localhost:5000/localbusybox + + - name: build jib + run: mvn install jib:dockerBuild jib:build -Djib.to.image=localhost:5000/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT --file tomcat/pom.xml -DskipTests + + - name: build jib + run: docker images + + - name: install tomcat operator + run: kubectl apply -f tomcat/k8s/operator.yaml + + - name: install sample operators + run: kubectl create ns tomcatoperator-sample + + - name: install sample operators + run: for sample in $(ls tomcat/k8s/*sample*); do echo kubectl -n tomcatoperator-sample apply -f $sample; done + + - name: wait for sample operators + run: | + LOOP=0 &&\ + while [[ $(kubectl get pods -n tomcat-operator -l app=tomcat-operator -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do \ + echo "waiting for pod" &&\ + kubectl logs -n tomcat-operator -l app=tomcat-operator &&\ + (( LOOP++ )) &&\ + if [[ $LOOP -gt 10 ]]; then break; fi &&\ + echo "loop number $LOOP" &&\ + sleep 5; \ + done + + - name: check operators + run: kubectl get deploy,tomcats,webapps,po -n tomcatoperator-sample + + + - name: check operators + run: kubectl get deploy,tomcats,webapps,po -n tomcat-operator diff --git a/tomcat/k8s/operator.yaml b/tomcat/k8s/operator.yaml index c3e5776..3248851 100644 --- a/tomcat/k8s/operator.yaml +++ b/tomcat/k8s/operator.yaml @@ -28,7 +28,8 @@ spec: serviceAccountName: tomcat-operator containers: - name: operator - image: tomcat-operator + image: localhost:5000/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT + #image: tomcat-operator imagePullPolicy: IfNotPresent ports: - containerPort: 80 @@ -65,8 +66,26 @@ metadata: rules: - apiGroups: - "" + - "extensions" + - "apps" resources: - deployments - services + - pods verbs: - '*' +- apiGroups: + - "apiextensions.k8s.io" + resources: + - customresourcedefinitions + verbs: + - '*' +- apiGroups: + - "tomcatoperator.io" + resources: + - tomcats + - tomcats/status + - webapps + - webapps/status + verbs: + - '*' \ No newline at end of file diff --git a/tomcat/src/test/java/sample/IntegrationTest.java b/tomcat/src/test/java/sample/IntegrationTest.java index 3af8cd0..32c17d2 100644 --- a/tomcat/src/test/java/sample/IntegrationTest.java +++ b/tomcat/src/test/java/sample/IntegrationTest.java @@ -55,7 +55,7 @@ public void test() throws InterruptedException { tomcatClient.inNamespace("tomcat-test").create(tomcat); - await().atMost(60, SECONDS).until(() -> { + await().atMost(120, SECONDS).until(() -> { Tomcat updatedTomcat = tomcatClient.inNamespace("tomcat-test").withName("test-tomcat1").get(); return updatedTomcat.getStatus() != null && (int) updatedTomcat.getStatus().getReadyReplicas() == 3; }); diff --git a/webserver/k8s/operator.yaml b/webserver/k8s/operator.yaml index a6e56ef..926b2c3 100644 --- a/webserver/k8s/operator.yaml +++ b/webserver/k8s/operator.yaml @@ -72,5 +72,27 @@ rules: - deployments - services - configmaps + - pods + verbs: + - '*' +- apiGroups: + - "apps" + resources: + - deployments + - services + - configmaps + verbs: + - '*' +- apiGroups: + - "apiextensions.k8s.io" + resources: + - customresourcedefinitions + verbs: + - '*' +- apiGroups: + - "sample.javaoperatorsdk" + resources: + - webservers + - webservers/status verbs: - '*' From 9868d4bba3387a8fce971705d635b137152a79a8 Mon Sep 17 00:00:00 2001 From: Charles_Sabourdin Date: Fri, 20 Aug 2021 12:46:46 +0200 Subject: [PATCH 02/18] correct cluster name --- .github/workflows/TomcatIntegrationTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index 8c4b2e4..12c9450 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -22,7 +22,7 @@ jobs: - name: Create kind cluster uses: helm/kind-action@v1.2.0 with: - cluster_name: ${{ job }} + cluster_name: tomcat-integration - name: Apply CRDs run: kubectl apply -f tomcat/k8s/crd.yaml From 7917f89f37e85a40da0c262b7e80d4053eaf3cb8 Mon Sep 17 00:00:00 2001 From: Charles_Sabourdin Date: Fri, 20 Aug 2021 12:48:04 +0200 Subject: [PATCH 03/18] correct cluster name --- .github/workflows/TomcatIntegrationTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index 12c9450..43dcdf1 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -72,7 +72,7 @@ jobs: python-version: 3.7 - name: test - if: ${{ !env.ACT }} + if: ${{ env.ACT }} run: | mkdir -p /etc/docker echo -n "{\"exec-opts\": [\"native.cgroupdriver=systemd\"],\"log-driver\": \"json-file\",\"log-opts\": {\"max-size\": \"100m\"},\"storage-driver\": \"overlay2\"}" > /etc/docker/daemon.json From f0a70365b9a2e30d512b9d946c23a4093e2fc3af Mon Sep 17 00:00:00 2001 From: Charles_Sabourdin Date: Fri, 20 Aug 2021 12:58:05 +0200 Subject: [PATCH 04/18] set --- .github/workflows/TomcatIntegrationTest.yml | 4 ++-- tomcat/k8s/operator.yaml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index 43dcdf1..720a3e2 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -111,7 +111,7 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - - name: Set up Maven + - name: Set up Maven for local ACT uses: stCarolas/setup-maven@v4 if: ${{ env.ACT }} with: @@ -132,7 +132,7 @@ jobs: docker push localhost:5000/localbusybox - name: build jib - run: mvn install jib:dockerBuild jib:build -Djib.to.image=localhost:5000/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT --file tomcat/pom.xml -DskipTests + run: mvn install jib:dockerBuild jib:build -Djib.to.image=$KIND_REGISTRY/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT --file tomcat/pom.xml -DskipTests - name: build jib run: docker images diff --git a/tomcat/k8s/operator.yaml b/tomcat/k8s/operator.yaml index 3248851..2d3d69a 100644 --- a/tomcat/k8s/operator.yaml +++ b/tomcat/k8s/operator.yaml @@ -28,7 +28,8 @@ spec: serviceAccountName: tomcat-operator containers: - name: operator - image: localhost:5000/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT + #image: localhost:5000/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT + image: kind-registry:5000/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT #image: tomcat-operator imagePullPolicy: IfNotPresent ports: From e0a71ea899680619cb6a877196fec52404577b3c Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Fri, 20 Aug 2021 13:14:24 +0200 Subject: [PATCH 05/18] set $KIND_REGISTRY --- .github/workflows/TomcatIntegrationTest.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index 720a3e2..6911509 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -125,7 +125,6 @@ jobs: # Checking env variable if [[ "$KIND_REGISTRY" != "localhost:5000" ]]; then echo "Wrong KIND_REGISTRY env variable: $KIND_REGISTRY" - exit 1 fi docker pull busybox docker tag busybox localhost:5000/localbusybox From 886096dd52995e3d56614a191a7c7d8954ad5f6d Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Fri, 20 Aug 2021 13:19:55 +0200 Subject: [PATCH 06/18] set -Djib.allowInsecureRegistries=true --- .github/workflows/TomcatIntegrationTest.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index 6911509..90eafc5 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -126,12 +126,9 @@ jobs: if [[ "$KIND_REGISTRY" != "localhost:5000" ]]; then echo "Wrong KIND_REGISTRY env variable: $KIND_REGISTRY" fi - docker pull busybox - docker tag busybox localhost:5000/localbusybox - docker push localhost:5000/localbusybox - name: build jib - run: mvn install jib:dockerBuild jib:build -Djib.to.image=$KIND_REGISTRY/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT --file tomcat/pom.xml -DskipTests + run: mvn -B install jib:dockerBuild jib:build -Djib.allowInsecureRegistries=true -Djib.to.image=$KIND_REGISTRY/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT --file tomcat/pom.xml -DskipTests - name: build jib run: docker images From cc4042b3ab1afed1d28644d19bb880864ec0c011 Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Fri, 20 Aug 2021 13:51:34 +0200 Subject: [PATCH 07/18] renamed and clean actions --- .github/workflows/TomcatIntegrationTest.yml | 38 +++++++++++++-------- tomcat/k8s/operator.yaml | 1 + 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index 90eafc5..b5a3158 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -92,9 +92,6 @@ jobs: # registry: true # # docker stop tomcat-local-apply-control-plane ; docker rm tomcat-local-apply-control-plane ; sleep 1 - - name: Apply CRDs - run: kubectl apply -f tomcat/k8s/crd.yaml - - name: Set up Java and Maven uses: actions/setup-java@v2 with: @@ -118,9 +115,12 @@ jobs: maven-version: 3.8.1 - name: check that kube is empty + if: ${{ env.ACT }} run: kubectl get tomcats,webapps,po + - name: test local registry + if: ${{ env.ACT }} run: | # Checking env variable if [[ "$KIND_REGISTRY" != "localhost:5000" ]]; then @@ -130,19 +130,16 @@ jobs: - name: build jib run: mvn -B install jib:dockerBuild jib:build -Djib.allowInsecureRegistries=true -Djib.to.image=$KIND_REGISTRY/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT --file tomcat/pom.xml -DskipTests - - name: build jib - run: docker images + - name: Apply CRDs + run: kubectl apply -f tomcat/k8s/crd.yaml - name: install tomcat operator run: kubectl apply -f tomcat/k8s/operator.yaml - - name: install sample operators + - name: create ns tomcatoperator-sample run: kubectl create ns tomcatoperator-sample - - name: install sample operators - run: for sample in $(ls tomcat/k8s/*sample*); do echo kubectl -n tomcatoperator-sample apply -f $sample; done - - - name: wait for sample operators + - name: wait for operators ready run: | LOOP=0 &&\ while [[ $(kubectl get pods -n tomcat-operator -l app=tomcat-operator -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do \ @@ -154,9 +151,22 @@ jobs: sleep 5; \ done - - name: check operators - run: kubectl get deploy,tomcats,webapps,po -n tomcatoperator-sample + - name: install sample operators + run: | + for sample in $(ls tomcat/k8s/*sample*); do + kubectl -n tomcatoperator-sample apply -f $sample; + done - - name: check operators - run: kubectl get deploy,tomcats,webapps,po -n tomcat-operator + - name: check pod correctly started + run: | + LOOP=0 &&\ + while [[ $(kubectl get pods -n tomcatoperator-sample -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True True True True True True" ]]; do \ + echo "waiting for pod" &&\ + kubectl logs -n tomcat-operator -l app=tomcat-operator &&\ + (( LOOP++ )) &&\ + if [[ $LOOP -gt 10 ]]; then break; fi &&\ + echo "loop number $LOOP" &&\ + sleep 5; \ + done + \ No newline at end of file diff --git a/tomcat/k8s/operator.yaml b/tomcat/k8s/operator.yaml index 2d3d69a..0b61b2d 100644 --- a/tomcat/k8s/operator.yaml +++ b/tomcat/k8s/operator.yaml @@ -73,6 +73,7 @@ rules: - deployments - services - pods + - pods/exec verbs: - '*' - apiGroups: From 6315926c969bbc27b2a5493e5b1d0ebf8d40afc3 Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Mon, 23 Aug 2021 10:00:52 +0200 Subject: [PATCH 08/18] put a cleanner break --- .github/workflows/TomcatIntegrationTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index b5a3158..f0c119b 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -165,7 +165,7 @@ jobs: echo "waiting for pod" &&\ kubectl logs -n tomcat-operator -l app=tomcat-operator &&\ (( LOOP++ )) &&\ - if [[ $LOOP -gt 10 ]]; then break; fi &&\ + if [[ $LOOP -gt 10 ]]; then exit 1; fi &&\ echo "loop number $LOOP" &&\ sleep 5; \ done From 06a873afe3a1fafdaa7fccef6abcb2babdd00c39 Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Mon, 23 Aug 2021 12:55:24 +0200 Subject: [PATCH 09/18] clean ressource after test --- .../io/javaoperatorsdk/operator/sample/IntegrationTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java index 9bdf9ec..d944e94 100644 --- a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java +++ b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java @@ -7,6 +7,7 @@ import io.fabric8.kubernetes.client.extended.run.RunConfigBuilder; import io.javaoperatorsdk.operator.Operator; import io.javaoperatorsdk.operator.config.runtime.DefaultConfigurationService; +import org.junit.AfterClass; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -102,5 +103,9 @@ public void test() { } }); + webappClient.inNamespace(TEST_NS).delete(webapp1); + tomcatClient.inNamespace(TEST_NS).delete(tomcat); + client.pods().inNamespace(TEST_NS).withName(curlPod.getMetadata().getName()).delete(); } + } From cceb2fa31076dc82582eea9897ecb61c00060101 Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Mon, 23 Aug 2021 14:06:09 +0200 Subject: [PATCH 10/18] increase time out --- .../io/javaoperatorsdk/operator/sample/IntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java index d944e94..52720d0 100644 --- a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java +++ b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java @@ -94,7 +94,7 @@ public void test() { .withImage("curlimages/curl:7.78.0") .withRestartPolicy("Never") .build()).done(); - await().atMost(2, MINUTES).untilAsserted(() -> { + await().atMost(5, MINUTES).untilAsserted(() -> { try { String curlOutput = client.pods().inNamespace(TEST_NS).withName(curlPod.getMetadata().getName()).getLog(); assertThat(curlOutput, equalTo("200")); From c164a913a43e89998ca6421a953d85615b17c4ca Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Tue, 24 Aug 2021 15:30:50 +0200 Subject: [PATCH 11/18] change webapps path --- tomcat/k8s/webapp-sample2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tomcat/k8s/webapp-sample2.yaml b/tomcat/k8s/webapp-sample2.yaml index a548451..e0415f9 100644 --- a/tomcat/k8s/webapp-sample2.yaml +++ b/tomcat/k8s/webapp-sample2.yaml @@ -5,4 +5,4 @@ metadata: spec: tomcat: test-tomcat2 url: charlottemach.com/assets/jax.war - contextPath: mysample + contextPath: othercontext From 5ee5527a620f867edf17a6f168bd9aae47fbe709 Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Tue, 24 Aug 2021 15:32:23 +0200 Subject: [PATCH 12/18] reverte to default image (deploy change in the github action) --- tomcat/k8s/operator.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tomcat/k8s/operator.yaml b/tomcat/k8s/operator.yaml index 0b61b2d..a88b651 100644 --- a/tomcat/k8s/operator.yaml +++ b/tomcat/k8s/operator.yaml @@ -28,9 +28,7 @@ spec: serviceAccountName: tomcat-operator containers: - name: operator - #image: localhost:5000/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT - image: kind-registry:5000/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT - #image: tomcat-operator + image: tomcat-operator imagePullPolicy: IfNotPresent ports: - containerPort: 80 From 716b96277a2b5c20c6b1a69170154a05389ee470 Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Tue, 24 Aug 2021 15:33:58 +0200 Subject: [PATCH 13/18] improve feedback on webapps download --- tomcat/k8s/crd.yaml | 4 + .../operator/sample/WebappController.java | 87 ++++++++++++++++--- .../operator/sample/WebappStatus.java | 10 +++ .../operator/sample/IntegrationTest.java | 11 +-- 4 files changed, 93 insertions(+), 19 deletions(-) diff --git a/tomcat/k8s/crd.yaml b/tomcat/k8s/crd.yaml index 44533a3..509c77b 100644 --- a/tomcat/k8s/crd.yaml +++ b/tomcat/k8s/crd.yaml @@ -80,6 +80,10 @@ spec: properties: deployedArtifact: type: string + deploymentStatus: + type: array + items: + type: string required: [spec] # either Namespaced or Cluster scope: Namespaced diff --git a/tomcat/src/main/java/io/javaoperatorsdk/operator/sample/WebappController.java b/tomcat/src/main/java/io/javaoperatorsdk/operator/sample/WebappController.java index 0c06c71..682ca2a 100644 --- a/tomcat/src/main/java/io/javaoperatorsdk/operator/sample/WebappController.java +++ b/tomcat/src/main/java/io/javaoperatorsdk/operator/sample/WebappController.java @@ -3,14 +3,23 @@ import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.client.KubernetesClient; +import io.fabric8.kubernetes.client.dsl.ExecListener; +import io.fabric8.kubernetes.client.dsl.ExecWatch; import io.javaoperatorsdk.operator.api.*; import io.javaoperatorsdk.operator.processing.event.EventSourceManager; +import okhttp3.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.nio.charset.Charset; import java.util.List; import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; @Controller public class WebappController implements ResourceController { @@ -47,17 +56,21 @@ public UpdateControl createOrUpdateResource(Webapp webapp, Context createOrUpdateResource(Webapp webapp, Context context) { String[] command = new String[] {"rm", "/data/" + webapp.getSpec().getContextPath() + ".war"}; - executeCommandInAllPods(kubernetesClient, webapp, command); + String[] commandStatusInAllPods = executeCommandInAllPods(kubernetesClient, webapp, command); if (webapp.getStatus() != null) { webapp.getStatus().setDeployedArtifact(null); + webapp.getStatus().setDeploymentStatus(commandStatusInAllPods); } return DeleteControl.DEFAULT_DELETE; } - private void executeCommandInAllPods( + private String[] executeCommandInAllPods( KubernetesClient kubernetesClient, Webapp webapp, String[] command) { + String[] status = new String[0]; + Deployment deployment = kubernetesClient .apps() @@ -91,20 +107,67 @@ private void executeCommandInAllPods( .withLabels(deployment.getSpec().getSelector().getMatchLabels()) .list() .getItems(); - for (Pod pod : pods) { + status = new String[pods.size()]; + for (int i=0; i data = new CompletableFuture<>(); + try (ExecWatch execWatch = execCmd(pod, data, command)) { + status[i] = ""+pod.getMetadata().getName()+":"+data.get(30, TimeUnit.SECONDS);; + } catch (ExecutionException e) { + status[i] = ""+pod.getMetadata().getName()+": ExecutionException - "+e.getMessage(); + } catch (InterruptedException e) { + status[i] = ""+pod.getMetadata().getName()+": InterruptedException - "+e.getMessage(); + } catch (TimeoutException e) { + status[i] = ""+pod.getMetadata().getName()+": TimeoutException - "+e.getMessage(); + } + } + } + return status; + } + + private ExecWatch execCmd(Pod pod, CompletableFuture data, String... command) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + return kubernetesClient.pods() + .inNamespace(pod.getMetadata().getNamespace()) .withName(pod.getMetadata().getName()) .inContainer("war-downloader") - .writingOutput(new ByteArrayOutputStream()) - .writingError(new ByteArrayOutputStream()) + .writingOutput(baos) + .writingError(baos) + .usingListener(new SimpleListener(data, baos)) .exec(command); - } + } + + static class SimpleListener implements ExecListener { + + private CompletableFuture data; + private ByteArrayOutputStream baos; + private final Logger log = LoggerFactory.getLogger(getClass()); + public SimpleListener(CompletableFuture data, ByteArrayOutputStream baos) { + this.data = data; + this.baos = baos; + } + + @Override + public void onOpen(Response response) { + log.debug("Reading data... " + response.message()); + } + + @Override + public void onFailure(Throwable t, Response response) { + log.debug(t.getMessage() + " " + response.message()); + data.completeExceptionally(t); + } + + @Override + public void onClose(int code, String reason) { + log.debug("Exit with: " + code + " and with reason: " + reason); + data.complete(baos.toString()); } } + } diff --git a/tomcat/src/main/java/io/javaoperatorsdk/operator/sample/WebappStatus.java b/tomcat/src/main/java/io/javaoperatorsdk/operator/sample/WebappStatus.java index 53e71fe..8267abe 100644 --- a/tomcat/src/main/java/io/javaoperatorsdk/operator/sample/WebappStatus.java +++ b/tomcat/src/main/java/io/javaoperatorsdk/operator/sample/WebappStatus.java @@ -11,4 +11,14 @@ public String getDeployedArtifact() { public void setDeployedArtifact(String deployedArtifact) { this.deployedArtifact = deployedArtifact; } + + private String[] deploymentStatus; + + public String[] getDeploymentStatus() { + return deploymentStatus; + } + + public void setDeploymentStatus(String[] deploymentStatus) { + this.deploymentStatus = deploymentStatus; + } } diff --git a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java index 52720d0..a9651a0 100644 --- a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java +++ b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java @@ -59,7 +59,7 @@ public void test() { Namespace testNs = new NamespaceBuilder().withMetadata( new ObjectMetaBuilder().withName(TEST_NS).build()).build(); - if (testNs != null) { + if (testNs != null && client.namespaces().withName(TEST_NS).isReady() == true ) { // We perform a pre-run cleanup instead of a post-run cleanup. This is to help with debugging test results // when running against a persistent cluster. The test namespace would stay after the test run so we can // check what's there, but it would be cleaned up during the next test run. @@ -84,7 +84,7 @@ public void test() { assertThat(updatedWebapp.getStatus(), is(notNullValue())); assertThat(updatedWebapp.getStatus().getDeployedArtifact(), is(notNullValue())); }); - + String url = "http://" + tomcat.getMetadata().getName() + "/" + webapp1.getSpec().getContextPath() + "/"; log.info("Starting curl Pod and waiting 2 minutes for GET of {} to return 200", url); Pod curlPod = client.run().inNamespace(TEST_NS) @@ -94,18 +94,15 @@ public void test() { .withImage("curlimages/curl:7.78.0") .withRestartPolicy("Never") .build()).done(); - await().atMost(5, MINUTES).untilAsserted(() -> { + await().atMost(2, MINUTES).untilAsserted(() -> { try { + //let's do som tries String curlOutput = client.pods().inNamespace(TEST_NS).withName(curlPod.getMetadata().getName()).getLog(); assertThat(curlOutput, equalTo("200")); } catch (KubernetesClientException ex) { throw new AssertionError(ex); } }); - - webappClient.inNamespace(TEST_NS).delete(webapp1); - tomcatClient.inNamespace(TEST_NS).delete(tomcat); - client.pods().inNamespace(TEST_NS).withName(curlPod.getMetadata().getName()).delete(); } } From d5b9048f80f778b2ee73afbaf5690a33bd5caf33 Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Tue, 24 Aug 2021 16:32:06 +0200 Subject: [PATCH 14/18] add Waiting 5 seconds for Tomcat to unpack the downloaded war --- .github/workflows/TomcatIntegrationTest.yml | 57 +++++++++++++------ .../operator/sample/IntegrationTest.java | 13 ++++- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index 0669169..bf7e1ba 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -46,6 +46,12 @@ jobs: - name: Run unit tests run: mvn -B test -q --file tomcat/pom.xml + - name: Get webapps + if: ${{ failure() }} + run: | + kubectl get tomcats,webapps -A -o yaml | tee -a debug + kubectl logs + tomcat_local_apply_setup_test: runs-on: ubuntu-latest steps: @@ -63,20 +69,22 @@ jobs: mkdir -p /etc/docker echo -n "{\"exec-opts\": [\"native.cgroupdriver=systemd\"],\"log-driver\": \"json-file\",\"log-opts\": {\"max-size\": \"100m\"},\"storage-driver\": \"overlay2\"}" > /etc/docker/daemon.json cat /etc/docker/daemon.json - sudo service docker status + #sudo service docker status - name: Create Kubernetes KinD Cluster uses: container-tools/kind-action@v1.5.0 + if: ${{ !env.ACT }} with: cluster_name: tomcat-local-apply registry: true - # - name: Create kind cluster - # uses: helm/kind-action@v1.2.0 - # with: - # cluster_name: tomcat-local-apply #${{ job.name }} - # registry: true - # # docker stop tomcat-local-apply-control-plane ; docker rm tomcat-local-apply-control-plane ; sleep 1 + - name: Create kind cluster without registry + uses: helm/kind-action@v1.2.0 + if: ${{ env.ACT }} + with: + cluster_name: tomcat-local-apply #${{ job.name }} + registry: false + # for DIMG in "tomcat-local-apply-control-plane kind-registry tomcat_local_apply_setup_test "; do docker stop $DIMG ; docker rm $DIMG ; done ; sleep 1 - name: Set up Java and Maven uses: actions/setup-java@v2 @@ -99,11 +107,6 @@ jobs: if: ${{ env.ACT }} with: maven-version: 3.8.1 - - - name: check that kube is empty - if: ${{ env.ACT }} - run: kubectl get tomcats,webapps,po - - name: test local registry if: ${{ env.ACT }} @@ -114,20 +117,42 @@ jobs: fi - name: build jib + if: ${{ !env.ACT }} run: | mvn -B install jib:dockerBuild jib:build -Djib.allowInsecureRegistries=true \ -Djib.to.image=$KIND_REGISTRY/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT \ --file tomcat/pom.xml -DskipTests + - name: build jib + if: ${{ env.ACT }} + run: | + mvn -B install jib:dockerBuild \ + -Djib.to.image=sample:1.7.1-SNAPSHOT --file tomcat/pom.xml -DskipTests + kind load docker-image sample:1.7.1-SNAPSHOT --name=tomcat-local-apply + - name: Apply CRDs run: kubectl apply -f tomcat/k8s/crd.yaml - name: install tomcat operator - run: kubectl apply -f tomcat/k8s/operator.yaml + if: ${{ !env.ACT }} + run: | + sed 's@image\: tomcat-operator@image\: kind-registry\:5000/io.javaoperatorsdk/sample\:1.7.1-SNAPSHOT@g' tomcat/k8s/operator.yaml > tomcat/target/operator.yaml + kubectl apply -f tomcat/target/operator.yaml + + - name: install tomcat operator + if: ${{ env.ACT }} + run: | + sed 's@image\: tomcat-operator@image\: sample\:1.7.1-SNAPSHOT@g' tomcat/k8s/operator.yaml > tomcat/target/operator.yaml + kubectl apply -f tomcat/target/operator.yaml - name: create ns tomcatoperator-sample run: kubectl create ns tomcatoperator-sample + - name: debug local kind + if: ${{ env.ACT }} + run: | + kubectl get pods -n tomcat-operator -l app=tomcat-operator -o yaml | tee -a debug.log + - name: wait for operators ready run: | LOOP=0 &&\ @@ -135,7 +160,7 @@ jobs: echo "waiting for pod" &&\ kubectl logs -n tomcat-operator -l app=tomcat-operator &&\ (( LOOP++ )) &&\ - if [[ $LOOP -gt 10 ]]; then break; fi &&\ + if [[ $LOOP -gt 10 ]]; then exit 1; fi &&\ echo "loop number $LOOP" &&\ sleep 5; \ done @@ -146,7 +171,6 @@ jobs: kubectl -n tomcatoperator-sample apply -f $sample; done - - name: check pod correctly started run: | LOOP=0 &&\ @@ -158,4 +182,5 @@ jobs: echo "loop number $LOOP" &&\ sleep 5; \ done - \ No newline at end of file + + \ No newline at end of file diff --git a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java index a9651a0..14fb136 100644 --- a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java +++ b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory; import static java.util.concurrent.TimeUnit.MINUTES; +import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; @@ -84,7 +85,17 @@ public void test() { assertThat(updatedWebapp.getStatus(), is(notNullValue())); assertThat(updatedWebapp.getStatus().getDeployedArtifact(), is(notNullValue())); }); - + + log.info("Waiting 5 seconds for Tomcat to unpack the downloaded war"); + // this delays is du to allows the tomcat to unpack + // kubectl -n tomcat-test -c war-downloader logs -l app=test-tomcat1 + // Deployment of web application archive [/usr/local/tomcat/webapps/webapp1.war] has finished in [xxx] ms + try { + Thread.sleep(5*1000); + } catch (InterruptedException e) { + log.warn(e.getMessage(),e); + } + String url = "http://" + tomcat.getMetadata().getName() + "/" + webapp1.getSpec().getContextPath() + "/"; log.info("Starting curl Pod and waiting 2 minutes for GET of {} to return 200", url); Pod curlPod = client.run().inNamespace(TEST_NS) From efedf39535faec0760892fa2d4f8682acc4b3859 Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Tue, 24 Aug 2021 17:10:14 +0200 Subject: [PATCH 15/18] testing full --- .github/workflows/TomcatIntegrationTest.yml | 28 ++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index bf7e1ba..bd8f436 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -47,10 +47,10 @@ jobs: run: mvn -B test -q --file tomcat/pom.xml - name: Get webapps - if: ${{ failure() }} + #if: ${{ failure() }} run: | kubectl get tomcats,webapps -A -o yaml | tee -a debug - kubectl logs + kubectl -n tomcat-test -c tomcat logs -l app=test-tomcat1 | grep startup tomcat_local_apply_setup_test: runs-on: ubuntu-latest @@ -182,5 +182,27 @@ jobs: echo "loop number $LOOP" &&\ sleep 5; \ done + #Waiting 5 seconds for Tomcat to unpack the downloaded war + sleep 5; - \ No newline at end of file + - name: Get webapps + #if: ${{ failure() }} + run: | + kubectl get tomcats,webapps -A -o yaml | tee -a debug + kubectl -n tomcat-test -c tomcat logs -l app=test-tomcat1 | grep startup + + - name: check code + run: | + kubectl -n tomcatoperator-sample run sample1 --labels=app=curl --image=curlimages/curl:7.78.0 --restart=Never --timeout=30s --command -- curl -s -v http://test-tomcat1/mysample/; + kubectl -n tomcatoperator-sample run sample2 --labels=app=curl --image=curlimages/curl:7.78.0 --restart=Never --timeout=30s --command -- curl -s -v http://test-tomcat2/othercontext/; + LOOP=0 &&\ + while [[ $(kubectl get pods -n tomcatoperator-sample -l app=curl -o 'jsonpath={..status.phase}') != "Succeeded Succeeded" ]]; do \ + echo "waiting for pod" &&\ + kubectl logs -n tomcatoperator-sample -l app=curl &&\ + (( LOOP++ )) &&\ + if [[ $LOOP -gt 5 ]]; then exit 1; fi &&\ + echo "loop number $LOOP" &&\ + sleep 5; \ + done + if [[ $(kubectl logs -n tomcatoperator-sample sample1 --tail=500 | grep tomcat.gif | wc -l) -ne 1 ]]; then exit 1; fi + if [[ $(kubectl logs -n tomcatoperator-sample sample2 --tail=500 | grep dog.jpeg | wc -l) -ne 1 ]]; then exit 1; fi From a02000139bc60494e091fc9f563046103632fb6e Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Tue, 24 Aug 2021 17:20:40 +0200 Subject: [PATCH 16/18] correct callimg the wrong namespace --- .github/workflows/TomcatIntegrationTest.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index bd8f436..2629c53 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -46,12 +46,6 @@ jobs: - name: Run unit tests run: mvn -B test -q --file tomcat/pom.xml - - name: Get webapps - #if: ${{ failure() }} - run: | - kubectl get tomcats,webapps -A -o yaml | tee -a debug - kubectl -n tomcat-test -c tomcat logs -l app=test-tomcat1 | grep startup - tomcat_local_apply_setup_test: runs-on: ubuntu-latest steps: @@ -189,7 +183,7 @@ jobs: #if: ${{ failure() }} run: | kubectl get tomcats,webapps -A -o yaml | tee -a debug - kubectl -n tomcat-test -c tomcat logs -l app=test-tomcat1 | grep startup + kubectl -n tomcatoperator-sample -c tomcat logs -l app=test-tomcat1 | grep startup - name: check code run: | From d49b13e68a43fccb86020659d6aed50487a247c2 Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Tue, 24 Aug 2021 17:29:16 +0200 Subject: [PATCH 17/18] improving sleeping time for webapp deployment --- .../io/javaoperatorsdk/operator/sample/IntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java index 14fb136..d085545 100644 --- a/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java +++ b/tomcat/src/test/java/io/javaoperatorsdk/operator/sample/IntegrationTest.java @@ -86,12 +86,12 @@ public void test() { assertThat(updatedWebapp.getStatus().getDeployedArtifact(), is(notNullValue())); }); - log.info("Waiting 5 seconds for Tomcat to unpack the downloaded war"); + log.info("Waiting 60 seconds for Tomcat to unpack the downloaded war"); // this delays is du to allows the tomcat to unpack // kubectl -n tomcat-test -c war-downloader logs -l app=test-tomcat1 // Deployment of web application archive [/usr/local/tomcat/webapps/webapp1.war] has finished in [xxx] ms try { - Thread.sleep(5*1000); + Thread.sleep(60*1000); } catch (InterruptedException e) { log.warn(e.getMessage(),e); } From f3c8e778f9626ad5f841ba187ec1fc03ff72cc2a Mon Sep 17 00:00:00 2001 From: Charles Sabourdin Date: Mon, 30 Aug 2021 22:23:13 +0200 Subject: [PATCH 18/18] set use of jib+kind for local run --- .github/workflows/TomcatIntegrationTest.yml | 61 +++------------------ tomcat/pom.xml | 2 +- 2 files changed, 10 insertions(+), 53 deletions(-) diff --git a/.github/workflows/TomcatIntegrationTest.yml b/.github/workflows/TomcatIntegrationTest.yml index 2629c53..297c23b 100644 --- a/.github/workflows/TomcatIntegrationTest.yml +++ b/.github/workflows/TomcatIntegrationTest.yml @@ -48,36 +48,18 @@ jobs: tomcat_local_apply_setup_test: runs-on: ubuntu-latest + env: + KIND_CL_NAME: tomcat-local-apply steps: - name: Checkout uses: actions/checkout@v2 - - - name: Set up Helm - uses: azure/setup-helm@v1 - with: - version: v3.4.0 - - - name: test - if: ${{ env.ACT }} - run: | - mkdir -p /etc/docker - echo -n "{\"exec-opts\": [\"native.cgroupdriver=systemd\"],\"log-driver\": \"json-file\",\"log-opts\": {\"max-size\": \"100m\"},\"storage-driver\": \"overlay2\"}" > /etc/docker/daemon.json - cat /etc/docker/daemon.json - #sudo service docker status - name: Create Kubernetes KinD Cluster uses: container-tools/kind-action@v1.5.0 - if: ${{ !env.ACT }} with: cluster_name: tomcat-local-apply - registry: true - - - name: Create kind cluster without registry - uses: helm/kind-action@v1.2.0 - if: ${{ env.ACT }} - with: - cluster_name: tomcat-local-apply #${{ job.name }} - registry: false + registry: false + # for DIMG in "tomcat-local-apply-control-plane kind-registry tomcat_local_apply_setup_test "; do docker stop $DIMG ; docker rm $DIMG ; done ; sleep 1 - name: Set up Java and Maven @@ -101,43 +83,18 @@ jobs: if: ${{ env.ACT }} with: maven-version: 3.8.1 - - - name: test local registry - if: ${{ env.ACT }} - run: | - # Checking env variable - if [[ "$KIND_REGISTRY" != "localhost:5000" ]]; then - echo "Wrong KIND_REGISTRY env variable: $KIND_REGISTRY" - fi - - - name: build jib - if: ${{ !env.ACT }} - run: | - mvn -B install jib:dockerBuild jib:build -Djib.allowInsecureRegistries=true \ - -Djib.to.image=$KIND_REGISTRY/io.javaoperatorsdk/sample:1.7.1-SNAPSHOT \ - --file tomcat/pom.xml -DskipTests - name: build jib - if: ${{ env.ACT }} run: | - mvn -B install jib:dockerBuild \ - -Djib.to.image=sample:1.7.1-SNAPSHOT --file tomcat/pom.xml -DskipTests - kind load docker-image sample:1.7.1-SNAPSHOT --name=tomcat-local-apply + mvn -B package jib:dockerBuild jib:buildTar -Djib-maven-image=tomcat-operator --file tomcat/pom.xml -DskipTests + kind load image-archive tomcat/target/jib-image.tar --name=${{ env.KIND_CL_NAME }} - name: Apply CRDs run: kubectl apply -f tomcat/k8s/crd.yaml - name: install tomcat operator - if: ${{ !env.ACT }} - run: | - sed 's@image\: tomcat-operator@image\: kind-registry\:5000/io.javaoperatorsdk/sample\:1.7.1-SNAPSHOT@g' tomcat/k8s/operator.yaml > tomcat/target/operator.yaml - kubectl apply -f tomcat/target/operator.yaml - - - name: install tomcat operator - if: ${{ env.ACT }} run: | - sed 's@image\: tomcat-operator@image\: sample\:1.7.1-SNAPSHOT@g' tomcat/k8s/operator.yaml > tomcat/target/operator.yaml - kubectl apply -f tomcat/target/operator.yaml + kubectl apply -f tomcat/k8s/operator.yaml - name: create ns tomcatoperator-sample run: kubectl create ns tomcatoperator-sample @@ -171,16 +128,16 @@ jobs: while [[ $(kubectl get pods -n tomcatoperator-sample -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True True True True True True" ]]; do \ echo "waiting for pod" &&\ kubectl logs -n tomcat-operator -l app=tomcat-operator &&\ + kubectl get pods -n tomcatoperator-sample &&\ (( LOOP++ )) &&\ if [[ $LOOP -gt 10 ]]; then exit 1; fi &&\ echo "loop number $LOOP" &&\ - sleep 5; \ + sleep 10; \ done #Waiting 5 seconds for Tomcat to unpack the downloaded war sleep 5; - name: Get webapps - #if: ${{ failure() }} run: | kubectl get tomcats,webapps -A -o yaml | tee -a debug kubectl -n tomcatoperator-sample -c tomcat logs -l app=test-tomcat1 | grep startup diff --git a/tomcat/pom.xml b/tomcat/pom.xml index 781154b..586dca7 100644 --- a/tomcat/pom.xml +++ b/tomcat/pom.xml @@ -19,7 +19,7 @@ 11 11 - 2.7.1 + 3.1.4