From 310414ae868186f9d41cbe44037efab767271c7c Mon Sep 17 00:00:00 2001 From: Frank Thomschke Date: Tue, 30 Jul 2024 10:47:45 +0200 Subject: [PATCH 1/7] helm: support tomcat accesslog --- .../helm/service/src/main/chart/templates/configmap-env.yaml | 1 + .../docker/repository/helm/service/src/main/chart/values.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/archetypes/project/src/main/resources/archetype-resources/deploy/docker/repository/helm/service/src/main/chart/templates/configmap-env.yaml b/archetypes/project/src/main/resources/archetype-resources/deploy/docker/repository/helm/service/src/main/chart/templates/configmap-env.yaml index 110112d6..e64d5dea 100644 --- a/archetypes/project/src/main/resources/archetype-resources/deploy/docker/repository/helm/service/src/main/chart/templates/configmap-env.yaml +++ b/archetypes/project/src/main/resources/archetype-resources/deploy/docker/repository/helm/service/src/main/chart/templates/configmap-env.yaml @@ -68,6 +68,7 @@ data: REPOSITORY_SERVICE_ALLOW_ORIGIN: "{{- join "," .Values.config.http.server.allowOrigin}}" REPOSITORY_SERVICE_HOST_EXTERNAL: {{ .Values.ingress.hosts | first | quote }} REPOSITORY_SERVICE_HOST_INTERNAL: {{ printf "%s.%s.svc.%s" (include "edusharing_repository_service.name" .) .Release.Namespace .Values.global.cluster.domain | quote }} + REPOSITORY_SERVICE_HTTP_ACCESSLOG_ENABLED: "{{ if .Values.config.connector.accesslog }}true{{ end }}" REPOSITORY_SERVICE_HTTP_CLIENT_DISABLE_SNI4HOSTS: {{ .Values.config.http.client.disablesni4host | quote }} REPOSITORY_SERVICE_HTTP_CLIENT_PROXY_HOST: {{ .Values.config.http.client.proxy.host | quote }} REPOSITORY_SERVICE_HTTP_CLIENT_PROXY_NONPROXYHOSTS: "'{{- join "|" .Values.config.http.client.proxy.nonproxyhosts }}'" diff --git a/archetypes/project/src/main/resources/archetype-resources/deploy/docker/repository/helm/service/src/main/chart/values.yaml b/archetypes/project/src/main/resources/archetype-resources/deploy/docker/repository/helm/service/src/main/chart/values.yaml index b62b276a..bfa991e9 100644 --- a/archetypes/project/src/main/resources/archetype-resources/deploy/docker/repository/helm/service/src/main/chart/values.yaml +++ b/archetypes/project/src/main/resources/archetype-resources/deploy/docker/repository/helm/service/src/main/chart/values.yaml @@ -161,6 +161,8 @@ config: connector: + accesslog: false + external: threads: 200 timeout: 20000 From b00b657a9e9c68e915920a08e2d97eb2351d8472 Mon Sep 17 00:00:00 2001 From: Sebastian Wollner Date: Fri, 16 Aug 2024 13:22:32 +0200 Subject: [PATCH 2/7] feat: AdminApi.getVersion returns detailed version information of submodules DESP-4 --- .../repository/config/defaults/pom.xml | 4 ++++ .../src/main/templates/project-version.json} | 15 +-------------- 2 files changed, 5 insertions(+), 14 deletions(-) rename archetypes/project/src/main/resources/archetype-resources/repository/{webapp/src/main/templates/WEB-INF/classes/version.json => config/defaults/src/main/templates/project-version.json} (55%) diff --git a/archetypes/project/src/main/resources/archetype-resources/repository/config/defaults/pom.xml b/archetypes/project/src/main/resources/archetype-resources/repository/config/defaults/pom.xml index 03670b6a..be0c4ba4 100644 --- a/archetypes/project/src/main/resources/archetype-resources/repository/config/defaults/pom.xml +++ b/archetypes/project/src/main/resources/archetype-resources/repository/config/defaults/pom.xml @@ -24,6 +24,10 @@ src/generated/resources + + src/main/templates + true + diff --git a/archetypes/project/src/main/resources/archetype-resources/repository/webapp/src/main/templates/WEB-INF/classes/version.json b/archetypes/project/src/main/resources/archetype-resources/repository/config/defaults/src/main/templates/project-version.json similarity index 55% rename from archetypes/project/src/main/resources/archetype-resources/repository/webapp/src/main/templates/WEB-INF/classes/version.json rename to archetypes/project/src/main/resources/archetype-resources/repository/config/defaults/src/main/templates/project-version.json index f85e6415..17029cd2 100644 --- a/archetypes/project/src/main/resources/archetype-resources/repository/webapp/src/main/templates/WEB-INF/classes/version.json +++ b/archetypes/project/src/main/resources/archetype-resources/repository/config/defaults/src/main/templates/project-version.json @@ -1,7 +1,5 @@ { - "build": { - "timestamp": "${build.timestamp}" - }, + "repository": "project", "git": { "branch": "${git.branch}", "closest": { @@ -18,17 +16,6 @@ "dirty": "${git.dirty}" }, "maven": { - "bom": { - "bom": "${bom.bom.version}", - "repository": "${bom.repository.version}", - "repository-antivirus": "${bom.repository-antivirus.version}", - "repository-cluster": "${bom.repository-cluster.version}", - "repository-elastic": "${bom.repository-elastic.version}", - "repository-mongo": "${bom.repository-mongo.version}", - "repository-remote": "${bom.repository-remote.version}", - "repository-transform": "${bom.repository-transform.version}", - "services-rendering": "${bom.services-rendering.version}" - }, "project": { "artifactId": "${project.artifactId}", "groupId": "${project.groupId}", From e0c6b69e4904b32fe55823368206d0abfee1adb1 Mon Sep 17 00:00:00 2001 From: Sebastian Wollner Date: Wed, 28 Aug 2024 11:04:32 +0200 Subject: [PATCH 3/7] deploy.sh added modes for ci/cd --- .../resources/archetype-resources/deploy.sh | 302 +++++++++++------- 1 file changed, 178 insertions(+), 124 deletions(-) diff --git a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh index 845d014e..7ac4cef5 100755 --- a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh +++ b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh @@ -4,17 +4,40 @@ set -o pipefail if [[ -z $1 ]] ; then echo "" - echo "deploy.sh [-s skip checks and deploy directly] []" + echo "deploy.sh [options] []" + echo " options:" + echo " -s # skip checks and deploy directly" + echo " -d # run diff" + echo " -t # run try run" + echo " -e # run execute deployment" echo "" exit 0 fi SKIP=false -while getopts s: opt; do +WIZARD=true +DIFF=false +TRY_RUN=false +DEPLOY=false +while getopts sdte opt; do case $opt in - s) SKIP=true + s) + SKIP=true + ;; + d) + WIZARD=false + DIFF=true + ;; + t) + WIZARD=false + TRY_RUN=true + ;; + e) + WIZARD=false + DEPLOY=true + ;; + *);; esac - shift done RELEASE=${1?"release required"} @@ -92,127 +115,158 @@ fi popd >/dev/null || exit -if [ "$SKIP" = false ] ; then -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -echo "cluster: ${CONTEXT}" -echo "namespace: ${NAMESPACE}" -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -read -p "---> kubectl context ok [y/N] " answer -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -case ${answer:0:1} in - y | Y) - echo "Request existing releases, please wait ..." - echo "" - helm repo update >/dev/null - helm ls -a - ;; - *) - exit 0 - ;; -esac - -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -echo "release: ${RELEASE}" -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -read -p "---> helm release ok [y/N] " answer -echo "" -echo "--------------------------------------------------------------------------------" -echo "" - -case ${answer:0:1} in - y | Y) - echo "Request existing revisions, please wait ..." - echo "" - helm history ${RELEASE} 2>/dev/null || echo "skipped ..." - ;; - *) - exit 0 - ;; -esac - -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -echo "chart: ${CHART}" -echo "version: ${VERSION}" -echo "options: ${ARGS[@]}" -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -read -p "---> helm parameter ok [y/N] " answer -echo "" -echo "--------------------------------------------------------------------------------" -echo "" - -if [[ ! -f ${CHART} ]] ; then - - ARGS+=("--version") - ARGS+=("${VERSION}") +diff() { + echo "Request diff from last revision, please wait ..." + echo "" + helm diff upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" +} + +tryRun(){ + echo "Dry-run, please wait ..." + echo "" + helm upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" --dry-run --debug +} + +execute(){ + echo "Execute, please wait ..." + echo "" + helm upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" --timeout=30m +} + + +runAsWizard() { + if [ "$SKIP" = false ] ; then + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + echo "cluster: ${CONTEXT}" + echo "namespace: ${NAMESPACE}" + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + read -p "---> kubectl context ok [y/N] " answer + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + case ${answer:0:1} in + y | Y) + echo "Request existing releases, please wait ..." + echo "" + helm repo update >/dev/null + helm ls -a + ;; + *) + exit 0 + ;; + esac + + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + echo "release: ${RELEASE}" + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + read -p "---> helm release ok [y/N] " answer + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + + case ${answer:0:1} in + y | Y) + echo "Request existing revisions, please wait ..." + echo "" + helm history ${RELEASE} 2>/dev/null || echo "skipped ..." + ;; + *) + exit 0 + ;; + esac + + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + echo "chart: ${CHART}" + echo "version: ${VERSION}" + echo "options: ${ARGS[*]}" + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + read -p "---> helm parameter ok [y/N] " answer + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + + if [[ ! -f ${CHART} ]] ; then + + ARGS+=("--version") + ARGS+=("${VERSION}") + + fi + + case ${answer:0:1} in + y | Y) + diff + ;; + *) + exit 0 + ;; + esac + + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + read -p "---> perform test [y/N] " answer + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + + case ${answer:0:1} in + y | Y) + tryRun + ;; + *) + echo "skipped ..." + ;; + esac + + fi + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + read -p "---> perform deployment [y/N] " answer + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + + case ${answer:0:1} in + y | Y) + execute + ;; + *) + echo "skipped ..." + ;; + esac + + echo "" + echo "--------------------------------------------------------------------------------" + echo "" + echo "done" + echo "" +} -fi -case ${answer:0:1} in - y | Y) - echo "Request diff from last revision, please wait ..." - echo "" - helm diff upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" - ;; - *) - exit 0 - ;; -esac - -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -read -p "---> perform test [y/N] " answer -echo "" -echo "--------------------------------------------------------------------------------" -echo "" - -case ${answer:0:1} in - y | Y) - echo "Dry-run, please wait ..." - echo "" - helm upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" --dry-run --debug - ;; - *) - echo "skipped ..." - ;; -esac +if [[ $WIZARD == "true" ]] ; then + runAsWizard +else + [[ $DIFF == "true" ]] && { + diff + } + [[ $TRY_RUN == "true" ]] && { + tryRun + } + [[ $DEPLOY == "true" ]] && { + execute + } fi -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -read -p "---> perform deployment [y/N] " answer -echo "" -echo "--------------------------------------------------------------------------------" -echo "" - -case ${answer:0:1} in - y | Y) - echo "Run, please wait ..." - echo "" - helm upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" --timeout=30m - ;; - *) - echo "skipped ..." - ;; -esac - -echo "" -echo "--------------------------------------------------------------------------------" -echo "" -echo "done" -echo "" From 16b35fb554f4bcb4177e51e27b4b692cdbbbd0fc Mon Sep 17 00:00:00 2001 From: Sebastian Wollner Date: Wed, 28 Aug 2024 12:06:38 +0200 Subject: [PATCH 4/7] fix: options not cleared --- .../helm/src/main/resources/archetype-resources/deploy.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh index 7ac4cef5..e3cb6bc9 100755 --- a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh +++ b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +set -ex set -o pipefail if [[ -z $1 ]] ; then @@ -36,10 +36,13 @@ while getopts sdte opt; do WIZARD=false DEPLOY=true ;; - *);; + *) + ;; esac done +shift $(( "$OPTIND" - 1)) + RELEASE=${1?"release required"} CHART=${2?"chart required"} VERSION=${3:-"":->=0.0.0-0} From e5f9906c0db416623bf03321d2826b0cc446a50e Mon Sep 17 00:00:00 2001 From: Sebastian Wollner Date: Wed, 28 Aug 2024 12:07:00 +0200 Subject: [PATCH 5/7] fix: remove debugging option --- .../helm/src/main/resources/archetype-resources/deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh index e3cb6bc9..a348a4fb 100755 --- a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh +++ b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -ex +set -e set -o pipefail if [[ -z $1 ]] ; then From c9d1b98cc424d7f3d8a0fc7910458a4293c6b65d Mon Sep 17 00:00:00 2001 From: Sebastian Wollner Date: Thu, 29 Aug 2024 13:58:46 +0200 Subject: [PATCH 6/7] fix: missing template folder in webapp --- .../helm/src/main/resources/archetype-resources/deploy.sh | 3 +++ .../repository/webapp/src/main/templates/.gitkeep | 0 2 files changed, 3 insertions(+) create mode 100644 archetypes/project/src/main/resources/archetype-resources/repository/webapp/src/main/templates/.gitkeep diff --git a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh index a348a4fb..5f8a8a80 100755 --- a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh +++ b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh @@ -121,7 +121,10 @@ popd >/dev/null || exit diff() { echo "Request diff from last revision, please wait ..." echo "" + # temporarily disable the script from exiting on a non-zero status code + set +e helm diff upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" + set -e } tryRun(){ diff --git a/archetypes/project/src/main/resources/archetype-resources/repository/webapp/src/main/templates/.gitkeep b/archetypes/project/src/main/resources/archetype-resources/repository/webapp/src/main/templates/.gitkeep new file mode 100644 index 00000000..e69de29b From 430e78d3c265ac3b1570b7fb567f1205c27886d8 Mon Sep 17 00:00:00 2001 From: Sebastian Wollner Date: Fri, 30 Aug 2024 09:21:26 +0200 Subject: [PATCH 7/7] fix: shell exit code --- .../resources/archetype-resources/deploy.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh index a348a4fb..e4f72ae3 100755 --- a/archetypes/helm/src/main/resources/archetype-resources/deploy.sh +++ b/archetypes/helm/src/main/resources/archetype-resources/deploy.sh @@ -121,7 +121,10 @@ popd >/dev/null || exit diff() { echo "Request diff from last revision, please wait ..." echo "" + # temporarily disable the script from exiting on a non-zero status code + set +e helm diff upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" + set -e } tryRun(){ @@ -262,14 +265,16 @@ runAsWizard() { if [[ $WIZARD == "true" ]] ; then runAsWizard else - [[ $DIFF == "true" ]] && { + if [[ $DIFF == "true" ]] ; then diff - } - [[ $TRY_RUN == "true" ]] && { + fi + + if [[ $TRY_RUN == "true" ]] ; then tryRun - } + fi - [[ $DEPLOY == "true" ]] && { + if [[ $DEPLOY == "true" ]] ; then execute - } + fi + fi