chore(helm): Adding opereplay config map for

Installation agnostic version access. This is useful for db migration,
especially when we install using argo, or other means
precedence to the autogenereated prev version.
Set migration is true if its argo deployment
fix the forceMigration override
This commit is contained in:
rjshrjndrn 2024-11-06 14:54:44 +01:00
parent 7f5c342a64
commit fdc281a406
4 changed files with 57 additions and 2 deletions

View file

@ -5,9 +5,25 @@ cd $(dirname $0)
is_migrate=$1 is_migrate=$1
# Check if the openreplay version is set.
# This will take precedence over the .Values.fromVersion variable
# Because its created by installation programatically.
if [[ -n $OPENREPLAY_VERSION ]]; then
is_migrate=true
PREVIOUS_APP_VERSION=$OPENREPLAY_VERSION
echo "$OPENREPLAY_VERSION set"
fi
if [[ $FORCE_MIGRATION == "true" ]]; then
is_migrate=true
fi
# Passed from env # Passed from env
# PREVIOUS_APP_VERSION # PREVIOUS_APP_VERSION
# CHART_APP_VERSION # CHART_APP_VERSION
# Converting alphaneumeric to number.
PREVIOUS_APP_VERSION=$(echo $PREVIOUS_APP_VERSION | cut -d "v" -f2)
CHART_APP_VERSION=$(echo $CHART_APP_VERSION | cut -d "v" -f2)
function migration() { function migration() {
ls -la /opt/openreplay/openreplay ls -la /opt/openreplay/openreplay

View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: openreplay-version
namespace: "{{ .Release.Namespace }}"
annotations:
"helm.sh/hook": post-install, post-upgrade
"helm.sh/hook-weight": "-6" # Higher precidence, so the first the config map will get created.
data:
version: {{ .Chart.AppVersion }}

View file

@ -3,8 +3,8 @@ Don't have to trigger migration if there is no version change
Don't have to trigger migration if skipMigration is set Don't have to trigger migration if skipMigration is set
Have to trigger migration if forceMigration is set Have to trigger migration if forceMigration is set
*/}} */}}
{{- $versionChange := and (eq .Values.fromVersion .Chart.AppVersion) (.Release.IsUpgrade) }} {{- $versionChange := (or .Values.deployment.argo (and (not (eq .Values.fromVersion .Chart.AppVersion)) .Release.IsUpgrade)) }}
{{- if or (not (or .Values.skipMigration $versionChange)) .Values.forceMigration }} {{- if or .Values.forceMigration (and (not .Values.skipMigration) $versionChange) }}
--- ---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
@ -187,6 +187,12 @@ spec:
containers: containers:
- name: postgres - name: postgres
env: env:
- name: OPENREPLAY_VERSION
valueFrom:
configMapKeyRef:
name: openreplay-version
key: version
optional: true
- name: FORCE_MIGRATION - name: FORCE_MIGRATION
value: "{{ .Values.forceMigration }}" value: "{{ .Values.forceMigration }}"
- name: PREVIOUS_APP_VERSION - name: PREVIOUS_APP_VERSION
@ -233,6 +239,12 @@ spec:
- name: minio - name: minio
image: bitnami/minio:2023.11.20 image: bitnami/minio:2023.11.20
env: env:
- name: OPENREPLAY_VERSION
valueFrom:
configMapKeyRef:
name: openreplay-version
key: version
optional: true
{{- range $key, $val := .Values.global.env }} {{- range $key, $val := .Values.global.env }}
- name: {{ $key }} - name: {{ $key }}
value: '{{ $val }}' value: '{{ $val }}'
@ -356,6 +368,12 @@ spec:
- name: clickhouse - name: clickhouse
image: clickhouse/clickhouse-server:22.12-alpine image: clickhouse/clickhouse-server:22.12-alpine
env: env:
- name: OPENREPLAY_VERSION
valueFrom:
configMapKeyRef:
name: openreplay-version
key: version
optional: true
{{- range $key, $val := .Values.global.env }} {{- range $key, $val := .Values.global.env }}
- name: {{ $key }} - name: {{ $key }}
value: '{{ $val }}' value: '{{ $val }}'
@ -391,6 +409,12 @@ spec:
- name: kafka - name: kafka
image: bitnami/kafka:2.6.0-debian-10-r30 image: bitnami/kafka:2.6.0-debian-10-r30
env: env:
- name: OPENREPLAY_VERSION
valueFrom:
configMapKeyRef:
name: openreplay-version
key: version
optional: true
{{- range $key, $val := .Values.global.env }} {{- range $key, $val := .Values.global.env }}
- name: {{ $key }} - name: {{ $key }}
value: '{{ $val }}' value: '{{ $val }}'

View file

@ -5,6 +5,11 @@ migrationJob:
migration: migration:
env: {} env: {}
deployment:
argo: false
forceMigration: false
skipMigration: false
redis: &redis redis: &redis
tls: tls:
enabled: false enabled: false