Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (icm): added possibility to empty database and site folder (#317) #320

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions charts/icm-as/templates/_environments.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,7 @@ env:
fieldRef:
fieldPath: status.hostIP
{{- end }}
{{- if .Values.mssql.enabled }}
- name: INTERSHOP_DATABASETYPE
value: mssql
- name: INTERSHOP_JDBC_URL
value: {{ printf "jdbc:sqlserver://%s-mssql-service:1433;database=%s" (include "icm-as.fullname" .) .Values.mssql.databaseName }}
- name: INTERSHOP_JDBC_USER
value: "{{ .Values.mssql.user }}"
- name: INTERSHOP_JDBC_PASSWORD
value: "{{ .Values.mssql.password }}"
{{- else }}
- name: INTERSHOP_DATABASETYPE
value: "{{ .Values.database.type }}"
- name: INTERSHOP_JDBC_URL
value: "{{ .Values.database.jdbcURL }}"
- name: INTERSHOP_JDBC_USER
value: "{{ .Values.database.jdbcUser }}"
- name: INTERSHOP_JDBC_PASSWORD
value: "{{ .Values.database.jdbcPassword }}"
{{- end }}
{{ include "icm-as.envDatabase" . }}
{{- if .Values.replication.enabled }}
- name: STAGING_SYSTEM_TYPE
{{- if eq .Values.replication.role "source" }}
Expand Down
25 changes: 25 additions & 0 deletions charts/icm-as/templates/_environmentsDatabase.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Creates the database environment section
*/}}
{{- define "icm-as.envDatabase" -}}
{{- if .Values.mssql.enabled -}}
- name: INTERSHOP_DATABASETYPE
value: mssql
- name: INTERSHOP_JDBC_URL
value: {{ printf "jdbc:sqlserver://%s-mssql-service:1433;database=%s" (include "icm-as.fullname" .) .Values.mssql.databaseName }}
- name: INTERSHOP_JDBC_USER
value: "{{ .Values.mssql.user }}"
- name: INTERSHOP_JDBC_PASSWORD
value: "{{ .Values.mssql.password }}"
{{- else -}}
- name: INTERSHOP_DATABASETYPE
value: "{{ .Values.database.type }}"
- name: INTERSHOP_JDBC_URL
value: "{{ .Values.database.jdbcURL }}"
- name: INTERSHOP_JDBC_USER
value: "{{ .Values.database.jdbcUser }}"
- name: INTERSHOP_JDBC_PASSWORD
value: "{{ .Values.database.jdbcPassword }}"
{{- end -}}
{{- end -}}
7 changes: 6 additions & 1 deletion charts/icm-as/templates/as-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "icm-as.fullname" . }}
annotations:
{{- if .Values.deploymentAnnotations }}
annotations: {{- toYaml .Values.deploymentAnnotations | nindent 4 }}
{{- toYaml .Values.deploymentAnnotations | nindent 4 }}
{{- end }}
# Restarting the ICM-AS pods after clean-up
{{- if .Values.cleanup.enabled }}
rollme: {{ tpl (toYaml .Values) . | sha256sum | trunc 50 }}{{ randAlphaNum 5 }}
{{- end }}
labels:
app: {{ include "icm-as.fullname" . }}
Expand Down
47 changes: 47 additions & 0 deletions charts/icm-as/templates/cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- if .Values.cleanup.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "icm-as.fullname" . }}-cleanup
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
app: {{ template "icm-as.fullname" . }}-cleanup
annotations:
# Only include "pre-install" if the site type is "existingClaim" since the
# volume does not exist otherwise.
{{- if eq .Values.persistence.sites.type "existingClaim" }}
"helm.sh/hook": pre-upgrade,pre-install
{{- else }}
"helm.sh/hook": pre-upgrade
{{- end }}
"helm.sh/hook-weight": "-1"
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
spec:
ttlSecondsAfterFinished: 100
backoffLimit: 10
template:
spec:
restartPolicy: Never
{{- if include "icm-as.imagePullSecrets" . }}
{{- include "icm-as.imagePullSecrets" . | nindent 6 }}
{{- end }}
containers:
- name: {{ template "icm-as.fullname" . }}-cleanup
{{- include "icm-as.image" . | nindent 8 }}
{{- include "icm-as.volumeMounts" . | nindent 8 }}
{{- include "icm-as.resources" . | nindent 8 }}
env:
{{- include "icm-as.envDatabase" . | nindent 8 }}
- name: IS_DBPREPARE
value: "true"
- name: ADDITIONAL_PARAMETERS
value: "-classic --clean=only"
{{- if include "icm-as.podSecurityContext" . }}
{{- include "icm-as.podSecurityContext" . | nindent 6 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds | default 30 }}
{{- include "icm-as.volumes" . | nindent 6 }}
{{- end }}
5 changes: 5 additions & 0 deletions charts/icm-as/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,8 @@ replication:

# the name of the (source) database to be used at the target-system to read data from e.g. intershop_edit
sourceDatabaseName: <databaseName>

# Configuration for the cleanup Task
cleanup:
# Enable or disable the Cleanup Task. If set to true, the database and the sites folder will be cleaned up before deployment.
enabled: false