diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f7601439afe056e8595956fe411c33555d51d1b..bf62d753124497c7cc3ef0cb71378dd21b0f90f2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,9 @@ stages: variables: npm_config_cache: ${CI_PROJECT_DIR}/.npm - image_name: ubleipzig/dacap + production_repo: ubleipzig/dacap + staging_repo: services.ub.uni-leipzig.de:11443/bdd_dev/dacap + alpha_repo: services.ub.uni-leipzig.de:11443/bdd_dev/dacap npm_install: stage: prepare @@ -67,14 +69,14 @@ npm_pack: docker_build: stage: build_image - image: ubleipzig/deployer:1.0.0 + image: ubleipzig/deployer:1.1.1 services: - docker:dind script: | deployer build \ --build-arg HTTP_PROXY="${HTTP_PROXY}" \ - --build-arg HTTPS_PROXY=${HTTPS_PROXY}" \ - --build-arg NO_PROXY=${NO_PROXY}" \ + --build-arg HTTPS_PROXY="${HTTPS_PROXY}" \ + --build-arg NO_PROXY="${NO_PROXY}" \ --output image.tar.gz dependencies: - npm_pack @@ -104,15 +106,15 @@ npm_publish: docker_publish_alpha: stage: publish - image: ubleipzig/deployer:1.0.0 + image: ubleipzig/deployer:1.1.1 services: - docker:dind script: | deployer publish \ --input image.tar.gz \ - --docker-config "${DOCKER_AUTH_CONFIG}" \ - --name ${image_name} \ - --tag ${CI_COMMIT_REF_NAME} + --docker-config "${DOCKER_ALPHA_AUTH_CONFIG}" \ + --name ${alpha_repo} \ + --tag ${CI_COMMIT_REF_SLUG} dependencies: - docker_build tags: @@ -124,14 +126,14 @@ docker_publish_alpha: docker_publish_staging: stage: publish - image: ubleipzig/deployer:1.0.0 + image: ubleipzig/deployer:1.1.1 services: - docker:dind script: | deployer publish \ --input image.tar.gz \ - --docker-config "$DOCKER_AUTH_CONFIG" \ - --name ${image_name} \ + --docker-config "${DOCKER_STAGING_AUTH_CONFIG}" \ + --name ${staging_repo} \ --tag staging dependencies: - docker_build @@ -142,20 +144,21 @@ docker_publish_staging: docker_publish_production: stage: publish - image: ubleipzig/deployer:1.0.0 + image: ubleipzig/deployer:1.1.1 services: - docker:dind script: | - version=`expr ${CI_COMMIT_TAG} ':' 'release/\(.\+\)'` + export version=$(expr ${CI_COMMIT_TAG} ':' 'release/\(.\+\)') + export major_version=$(expr ${version} ':' '\([^.]\+\)') + export minor_version=$(expr ${version} ':' '[^.]\+\.\([^.]\+\)') deployer publish \ --input image.tar.gz - --docker-config "$DOCKER_AUTH_CONFIG" \ - --name ${image_name} \ + --docker-config "$DOCKER_LIVE_AUTH_CONFIG" \ + --name ${production_repo} \ --tag latest \ --tag ${version} \ - --tag $(expr ${version} ':' '\([^.]\+\)') \ - --tag $(expr ${version} ':' '[^.]\+\.\([^.]\+\)') \ - --tag $(expr ${version} ':' '[^.]\+\.[^.]\+\.\(.\+\))` + --tag "${major_version}.${minor_version}" \ + --tag "${major_version}" dependencies: - docker_build tags: @@ -167,14 +170,14 @@ docker_publish_production: deploy_alpha: stage: deploy - image: ubleipzig/deployer:1.0.0 + image: ubleipzig/deployer:1.1.1 variables: url_schema: https:// ingress_host: alpha.ub.uni-leipzig.de ingress_path: /dacap environment: - name: alpha/${CI_COMMIT_REF_NAME} - url: https://alpha.ub.uni-leipzig.de/dacap/${CI_COMMIT_REF_NAME}/admin + name: alpha/${CI_COMMIT_REF_SLUG} + url: https://alpha.ub.uni-leipzig.de/dacap/${CI_COMMIT_REF_SLUG}/admin script: | deployer deploy \ --cluster-url "${K8S_ALPHA_CLUSTER_URL}" \ @@ -182,14 +185,16 @@ deploy_alpha: --token "${K8S_ALPHA_DEPLOY_TOKEN}" \ --namespace "${K8S_ALPHA_CLUSTER_NAMESPACE}" \ --service-account "${K8S_ALPHA_DEPLOY_USER}" \ - --name issue-${CI_COMMIT_REF_NAME} \ - --set-string environment.proxy_url=${url_schema}${ingress_host}${ingress_path}/${CI_COMMIT_REF_NAME}/ \ + --name issue-${CI_COMMIT_REF_SLUG} \ + --set-string environment.proxy_url=${url_schema}${ingress_host}${ingress_path}/${CI_COMMIT_REF_SLUG}/ \ --set-string environment.http_proxy=http://proxy.uni-leipzig.de:3128 \ - --set-string ingress.path=${ingress_path}/${CI_COMMIT_REF_NAME} \ + --set-string ingress.path=${ingress_path}/${CI_COMMIT_REF_SLUG} \ --set-string ingress.hosts[0]=${ingress_host} \ - --set-string image.tag=alpha-${CI_COMMIT_REF_NAME} \ + --set-string image.repository=${alpha_repo} \ + --set-string image.tag=${CI_COMMIT_REF_SLUG} \ --set-string pullPolicy=Always \ - --charts ./helmcharts + --set-string dockerconfigjson=$(echo $(echo "${DOCKER_ALPHA_AUTH_CONFIG}"|base64)|tr -d " ") \ + --charts ./helmchart dependencies: - docker_publish_alpha tags: @@ -199,9 +204,28 @@ deploy_alpha: except: - master +undeploy_alpha: + stage: deploy + image: ubleipzig/deployer:1.1.1 + script: | + deployer undeploy \ + --cluster-url "${K8S_ALPHA_CLUSTER_URL}" \ + --certificate-authority "${K8S_ALPHA_CLUSTER_CA}" \ + --token "${K8S_ALPHA_DEPLOY_TOKEN}" \ + --namespace "${K8S_ALPHA_CLUSTER_NAMESPACE}" \ + --service-account "${K8S_ALPHA_DEPLOY_USER}" \ + --name issue-${CI_COMMIT_REF_SLUG} + tags: + - docker + only: + - branches + except: + - master + when: manual + deploy_staging: stage: deploy - image: ubleipzig/deployer:1.0.0 + image: ubleipzig/deployer:1.1.1 variables: url_schema: https:// ingress_host: staging.ub.uni-leipzig.de @@ -221,9 +245,11 @@ deploy_staging: --set-string environment.http_proxy=http://proxy.uni-leipzig.de:3128 \ --set-string ingress.path=${ingress_path} \ --set-string ingress.hosts[0]=${ingress_host} \ + --set-string image.repository=${alpha_repo} \ --set-string image.tag=staging \ --set-string pullPolicy=Always \ - --charts ./helmcharts + --set-string dockerconfigjson=$(echo $(echo "${DOCKER_STAGING_AUTH_CONFIG}"|base64)|tr -d " ") \ + --charts ./helmchart dependencies: - docker_publish_staging @@ -234,7 +260,7 @@ deploy_staging: deploy_production: stage: deploy - image: ubleipzig/deployer:1.0.0 + image: ubleipzig/deployer:1.1.1 variables: url_schema: https:// ingress_host: api.ub.uni-leipzig.de @@ -257,7 +283,7 @@ deploy_production: --set-string ingress.hosts[0]=${ingress_host} \ --set-string image.tag=${version} \ --set-string pullPolicy=Always \ - --charts ./helmcharts + --charts ./helmchart dependencies: - docker_publish_production tags: diff --git a/helmcharts/.helmignore b/helmchart/.helmignore similarity index 100% rename from helmcharts/.helmignore rename to helmchart/.helmignore diff --git a/helmcharts/Chart.yaml b/helmchart/Chart.yaml similarity index 100% rename from helmcharts/Chart.yaml rename to helmchart/Chart.yaml diff --git a/helmcharts/templates/NOTES.txt b/helmchart/templates/NOTES.txt similarity index 100% rename from helmcharts/templates/NOTES.txt rename to helmchart/templates/NOTES.txt diff --git a/helmcharts/templates/_helpers.tpl b/helmchart/templates/_helpers.tpl similarity index 100% rename from helmcharts/templates/_helpers.tpl rename to helmchart/templates/_helpers.tpl diff --git a/helmchart/templates/configmap.yaml b/helmchart/templates/configmap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8b7c01eecd408c00d5c3f8e80c8169ac92c51f54 --- /dev/null +++ b/helmchart/templates/configmap.yaml @@ -0,0 +1,8 @@ +{{- if .Values.createConfigMap -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-environment +data: +{{ toYaml .Values.environment | indent 2 }} +{{- end }} diff --git a/helmcharts/templates/deployment.yaml b/helmchart/templates/deployment.yaml similarity index 94% rename from helmcharts/templates/deployment.yaml rename to helmchart/templates/deployment.yaml index 6caea916aa7c5c9fd833bbe5d190e9865e80c4ef..a14e63272c380dc07c006db77b6bc978f0113cec 100644 --- a/helmcharts/templates/deployment.yaml +++ b/helmchart/templates/deployment.yaml @@ -19,6 +19,10 @@ spec: app: {{ template "dacap.name" . }} release: {{ .Release.Name }} spec: +{{- if .Values.dockerconfigjson }} + imagePullSecrets: + - name: registrypullsecret +{{- end }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" diff --git a/helmcharts/templates/ingress.yaml b/helmchart/templates/ingress.yaml similarity index 100% rename from helmcharts/templates/ingress.yaml rename to helmchart/templates/ingress.yaml diff --git a/helmcharts/templates/pvc.yml b/helmchart/templates/pvc.yml similarity index 100% rename from helmcharts/templates/pvc.yml rename to helmchart/templates/pvc.yml diff --git a/helmchart/templates/secret.yaml b/helmchart/templates/secret.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e81bf0f16034bb686e0c3432ea3d545cd8737b0e --- /dev/null +++ b/helmchart/templates/secret.yaml @@ -0,0 +1,9 @@ +{{- if .Values.dockerconfigjson -}} +apiVersion: v1 +kind: Secret +metadata: + name: registrypullsecret +data: + .dockerconfigjson: {{ .Values.dockerconfigjson }} +type: kubernetes.io/dockerconfigjson +{{- end -}} \ No newline at end of file diff --git a/helmcharts/templates/service.yaml b/helmchart/templates/service.yaml similarity index 100% rename from helmcharts/templates/service.yaml rename to helmchart/templates/service.yaml diff --git a/helmcharts/values.yaml b/helmchart/values.yaml similarity index 98% rename from helmcharts/values.yaml rename to helmchart/values.yaml index 5c42aa8c857e8d01f416fb56397ecdf3f333460e..9cfe1d8541c4fb623672c2c4ba36d349bd65e3c7 100644 --- a/helmcharts/values.yaml +++ b/helmchart/values.yaml @@ -9,6 +9,8 @@ image: tag: 1.0.5 pullPolicy: IfNotPresent +createConfigMap: true + environment: autosave_interval: "60" cache_ttl: "600" diff --git a/helmcharts/templates/configmap.yaml b/helmcharts/templates/configmap.yaml deleted file mode 100644 index 36cb9c8a8f8099556113e19053b79fd3f7a1404d..0000000000000000000000000000000000000000 --- a/helmcharts/templates/configmap.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Release.Name }}-environment -data: -{{ toYaml .Values.environment | indent 2 }} \ No newline at end of file