mirror of
https://github.com/truenas/charts.git
synced 2026-10-26 15:59:51 +00:00
add postgres job and update questions
This commit is contained in:
@@ -184,6 +184,28 @@ questions:
|
||||
$ref:
|
||||
- "definitions/certificate"
|
||||
|
||||
- variable: logsearchapi
|
||||
label: Log Search API Configuration
|
||||
description: Log Search API Configuration
|
||||
group: Minio Configuration
|
||||
schema:
|
||||
type: dict
|
||||
additional_attrs: true
|
||||
attrs:
|
||||
- variable: enabled
|
||||
label: Enable Log Search API
|
||||
description: Enables Log Search API and configures MinIO to use it. It also deploys a postgres DB for it.
|
||||
schema:
|
||||
type: boolean
|
||||
default: false
|
||||
- variable: diskCapacityGB
|
||||
label: Disk Capacity in GB
|
||||
description: Capacity in GB that logs are allowed to occupy.
|
||||
schema:
|
||||
type: int
|
||||
show_if: [["enabled", "=", true]]
|
||||
default: 5
|
||||
|
||||
- variable: appVolumeMounts
|
||||
label: "Minio Storage"
|
||||
group: "Storage"
|
||||
@@ -252,6 +274,85 @@ questions:
|
||||
type: hostpath
|
||||
required: true
|
||||
|
||||
- variable: postgresAppVolumeMounts
|
||||
label: Postgres Storage
|
||||
group: Storage
|
||||
schema:
|
||||
type: dict
|
||||
attrs:
|
||||
- variable: postgres-data
|
||||
label: Postgres Data Volume
|
||||
schema:
|
||||
type: dict
|
||||
attrs:
|
||||
- variable: datasetName
|
||||
label: Postgres Data Volume Name
|
||||
schema:
|
||||
type: string
|
||||
hidden: true
|
||||
$ref:
|
||||
- normalize/ixVolume
|
||||
default: ix-postgres_data
|
||||
show_if: [["hostPathEnabled", "=", false]]
|
||||
editable: false
|
||||
|
||||
- variable: mountPath
|
||||
label: Postgresql Data Mount Path
|
||||
description: Path where the volume will be mounted inside the pod
|
||||
schema:
|
||||
type: path
|
||||
hidden: true
|
||||
editable: false
|
||||
default: /var/lib/postgresql/data
|
||||
- variable: hostPathEnabled
|
||||
label: Enable Host Path for Postgres Data Volume
|
||||
schema:
|
||||
type: boolean
|
||||
default: false
|
||||
show_subquestions_if: true
|
||||
subquestions:
|
||||
- variable: hostPath
|
||||
label: Host Path for Postgres Data Volume
|
||||
schema:
|
||||
type: hostpath
|
||||
required: true
|
||||
|
||||
- variable: postgres-backup
|
||||
label: Postgres Backup Volume
|
||||
schema:
|
||||
type: dict
|
||||
attrs:
|
||||
- variable: datasetName
|
||||
label: Postgres Backup Volume Name
|
||||
schema:
|
||||
type: string
|
||||
hidden: true
|
||||
$ref:
|
||||
- normalize/ixVolume
|
||||
default: ix-postgres_backups
|
||||
show_if: [["hostPathEnabled", "=", false]]
|
||||
editable: false
|
||||
- variable: mountPath
|
||||
label: Postgresql Backup Mount Path
|
||||
description: Path where the volume will be mounted inside the pod
|
||||
schema:
|
||||
type: path
|
||||
hidden: true
|
||||
editable: false
|
||||
default: /postgres_backups
|
||||
- variable: hostPathEnabled
|
||||
label: Enable Host Path for Postgres Backup Volume
|
||||
schema:
|
||||
type: boolean
|
||||
default: false
|
||||
show_subquestions_if: true
|
||||
subquestions:
|
||||
- variable: hostPath
|
||||
label: Host Path for Postgres Backup Volume
|
||||
schema:
|
||||
type: hostpath
|
||||
required: true
|
||||
|
||||
- variable: enableResourceLimits
|
||||
label: "Enable Pod resource limits"
|
||||
group: "Resource Limits"
|
||||
|
||||
@@ -18,6 +18,15 @@
|
||||
{{- print "logsearchapi" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Retrieve postgres backup name
|
||||
This will return a unique name based on revision and chart numbers specified.
|
||||
*/}}
|
||||
{{- define "postgres.backupName" -}}
|
||||
{{- $upgradeDict := .Values.ixChartContext.upgradeMetadata -}}
|
||||
{{- printf "postgres-backup-from-%s-to-%s-revision-%d" $upgradeDict.oldChartVersion $upgradeDict.newChartVersion (int64 $upgradeDict.preUpgradeRevision) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "postgres.envVariableConfiguration" -}}
|
||||
{{- $envList := list -}}
|
||||
{{- $secretName := (include "postgres.secretName" .) -}}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: postgres-backup-hook-config-map
|
||||
annotations:
|
||||
rollme: {{ randAlphaNum 5 | quote }}
|
||||
data:
|
||||
entrypoint.sh: |-
|
||||
#!/bin/sh
|
||||
cmd="/docker-entrypoint.sh postgres"
|
||||
eval "${cmd}" & disown;
|
||||
until pg_isready; do
|
||||
sleep 5;
|
||||
done;
|
||||
pg_dump -U $POSTGRES_USER -d {{ include "postgres.dbName" . }} > /postgres_backups/$BACKUP_NAME;
|
||||
@@ -0,0 +1,38 @@
|
||||
{{- if .Values.ixChartContext.isUpgrade -}}
|
||||
{{ $values := (. | mustDeepCopy) }}
|
||||
{{ $_ := set $values "common" (dict "nameSuffix" (include "postgres.nameSuffix" .)) }}
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: pre-upgrade-hook
|
||||
annotations:
|
||||
"helm.sh/hook": pre-upgrade
|
||||
"helm.sh/hook-weight": "1"
|
||||
"helm.sh/hook-delete-policy": hook-succeeded
|
||||
rollme: {{ randAlphaNum 5 | quote }}
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
name: pre-upgrade-hook
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}-postgres-backup
|
||||
image: {{ include "postgres.imageName" . }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
env: {{ include "postgres.envVariableConfiguration" $values | nindent 10 }}
|
||||
- name: BACKUP_NAME
|
||||
value: {{ include "postgres.backupName" . }}
|
||||
volumeMounts: {{ include "postgres.volumeMountsConfiguration" $values | nindent 10 }}
|
||||
- name: backup-script-configmap
|
||||
mountPath: /bin/backup_entrypoint.sh
|
||||
readOnly: true
|
||||
subPath: entrypoint.sh
|
||||
command:
|
||||
- /bin/backup_entrypoint.sh
|
||||
volumes: {{ include "postgres.volumeConfiguration" $values | nindent 8 }}
|
||||
- name: backup-script-configmap
|
||||
configMap:
|
||||
defaultMode: 0700
|
||||
name: postgres-backup-hook-config-map
|
||||
{{- end -}}
|
||||
@@ -16,6 +16,7 @@ postgresql:
|
||||
dataVolume:
|
||||
datasetName: ix-postgres_data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
ixChartContext: {}
|
||||
distributedIps: []
|
||||
distributedMode: false
|
||||
dnsConfig:
|
||||
|
||||
Reference in New Issue
Block a user