mirror of
https://github.com/truenas/charts.git
synced 2026-02-03 02:23:49 +08:00
Create psql templates to reduce boilerplace (#1668)
* bump versions and format before applying changes * add persistence template * add service template * explicitly set the default values * apply new templates to a chart * bump
This commit is contained in:
@@ -12,7 +12,7 @@ icon: https://localhost/icon
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: file://../common
|
||||
version: ~1.1.0
|
||||
version: ~1.2.0
|
||||
maintainers:
|
||||
- name: truenas
|
||||
url: https://www.truenas.com/
|
||||
|
||||
@@ -2,7 +2,7 @@ apiVersion: v2
|
||||
name: common
|
||||
description: A library chart for iX Official Catalog
|
||||
type: library
|
||||
version: 1.1.1
|
||||
version: 1.2.0
|
||||
appVersion: v1
|
||||
annotations:
|
||||
title: Common Library Chart
|
||||
|
||||
@@ -18,6 +18,7 @@ backupChownMode (optional): Whether to chown the backup directory or
|
||||
{{- $backupChownMode := .backupChownMode | default "check" -}}
|
||||
{{- $ixChartContext := .ixChartContext -}}
|
||||
{{- $resources := (required "Postgres - Resources are required" .resources) }}
|
||||
|
||||
{{ $name }}:
|
||||
enabled: true
|
||||
type: Deployment
|
||||
@@ -61,20 +62,25 @@ backupChownMode (optional): Whether to chown the backup directory or
|
||||
- -c
|
||||
- "until pg_isready -U ${POSTGRES_USER} -h localhost; do sleep 2; done"
|
||||
initContainers:
|
||||
{{- include "ix.v1.common.app.permissions" (dict "UID" 999 "GID" 999) | nindent 6 }}
|
||||
{{- $enableBackupJob := false -}}
|
||||
{{- if hasKey $ixChartContext "isUpgrade" -}}
|
||||
{{- if $ixChartContext.isUpgrade -}}
|
||||
{{- include "ix.v1.common.app.permissions"
|
||||
(dict
|
||||
"UID" 999
|
||||
"GID" 999
|
||||
"type" "install"
|
||||
"containerName" "permissions"
|
||||
) | nindent 6 }}
|
||||
|
||||
{{- $enableBackupJob := false -}}
|
||||
{{- if hasKey $ixChartContext "isUpgrade" -}}
|
||||
{{- if $ixChartContext.isUpgrade -}}
|
||||
{{- $enableBackupJob = true -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{/* If the key is not present in ixChartContext, means we
|
||||
are outside SCALE (Probably CI), let upgrade job run */}}
|
||||
{{- $enableBackupJob = true -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{/*
|
||||
If the key is not present in ixChartContext,
|
||||
means we are outside SCALE (Probably CI),
|
||||
let upgrade job run
|
||||
*/}}
|
||||
{{- $enableBackupJob = true -}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
postgresbackup:
|
||||
enabled: {{ $enableBackupJob }}
|
||||
type: Job
|
||||
@@ -116,7 +122,14 @@ postgresbackup:
|
||||
pg_dump --dbname=${POSTGRES_URL} --file {{ $backupPath }}/${POSTGRES_DB}_$(date +%Y-%m-%d_%H-%M-%S).sql || echo "Failed to create backup"
|
||||
echo "Backup finished"
|
||||
initContainers:
|
||||
{{- include "ix.v1.common.app.permissions" (dict "UID" 999 "GID" 999 "type" "init" "mode" $backupChownMode) | nindent 6 }}
|
||||
{{- include "ix.v1.common.app.permissions"
|
||||
(dict
|
||||
"UID" 999
|
||||
"GID" 999
|
||||
"type" "init"
|
||||
"mode" $backupChownMode
|
||||
"containerName" "permissions"
|
||||
) | nindent 6 }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Returns a postgres-wait container for waiting for postgres to be ready */}}
|
||||
@@ -130,6 +143,7 @@ secretName (required): Name of the secret containing the postgres credentials
|
||||
{{- define "ix.v1.common.app.postgresWait" -}}
|
||||
{{- $name := .name | default "postgres-wait" -}}
|
||||
{{- $secretName := (required "Postgres-Wait - Secret Name is required" .secretName) }}
|
||||
|
||||
{{ $name }}:
|
||||
enabled: true
|
||||
type: init
|
||||
@@ -150,3 +164,65 @@ secretName (required): Name of the secret containing the postgres credentials
|
||||
sleep 2
|
||||
done
|
||||
{{- end -}}
|
||||
|
||||
{{/* Returns persistence entries for postgres */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.app.postgresPersistence" (dict "pgData" .Values.storage.pgData "pgBackup" .Values.storage.pgBackup) }}
|
||||
|
||||
pgData (required): Data persistence configuration
|
||||
pgBackup (required): Data persistence configuration for backup
|
||||
*/}}
|
||||
|
||||
{{- define "ix.v1.common.app.postgresPersistence" -}}
|
||||
{{- $data := .pgData -}}
|
||||
{{- $backup := .pgBackup }}
|
||||
|
||||
{{- if not $data -}}
|
||||
{{- fail "Postgres - Data persistence configuration is required" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not $backup -}}
|
||||
{{- fail "Postgres - Backup persistence configuration is required" -}}
|
||||
{{- end -}}
|
||||
|
||||
postgresdata:
|
||||
enabled: true
|
||||
type: {{ $data.type }}
|
||||
datasetName: {{ $data.datasetName | default "" }}
|
||||
hostPath: {{ $data.hostPath | default "" }}
|
||||
targetSelector:
|
||||
postgres:
|
||||
postgres:
|
||||
mountPath: /var/lib/postgresql/data
|
||||
permissions:
|
||||
mountPath: /mnt/directories/postgres_data
|
||||
postgresbackup:
|
||||
enabled: true
|
||||
type: {{ $backup.type }}
|
||||
datasetName: {{ $backup.datasetName | default "" }}
|
||||
hostPath: {{ $backup.hostPath | default "" }}
|
||||
targetSelector:
|
||||
postgresbackup:
|
||||
postgresbackup:
|
||||
mountPath: /postgres_backup
|
||||
permissions:
|
||||
mountPath: /mnt/directories/postgres_backup
|
||||
{{- end -}}
|
||||
|
||||
{{/* Returns service entry for postgres */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.app.postgresService" . }}
|
||||
*/}}
|
||||
{{- define "ix.v1.common.app.postgresService" -}}
|
||||
postgres:
|
||||
enabled: true
|
||||
type: ClusterIP
|
||||
targetSelector: postgres
|
||||
ports:
|
||||
postgres:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 5432
|
||||
targetPort: 5432
|
||||
targetSelector: postgres
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: file://../../../common
|
||||
version: 1.1.1
|
||||
digest: sha256:a7dbe3e4d42dbcd4325776e5e01a1d630c7f185f79e7ebf22b1b9cc80f56eed7
|
||||
generated: "2023-09-21T17:36:42.077526429+03:00"
|
||||
version: 1.2.0
|
||||
digest: sha256:a87a6988cedfc3f8a90eb308dffaaeaa1cbd0cad31c20e15b1147084360b9ec1
|
||||
generated: "2023-10-25T19:30:16.729964915+03:00"
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Briefkasten is a self hosted bookmarking app
|
||||
annotations:
|
||||
title: Briefkasten
|
||||
type: application
|
||||
version: 1.1.1
|
||||
version: 1.1.2
|
||||
apiVersion: v2
|
||||
appVersion: latest
|
||||
kubeVersion: '>=1.16.0-0'
|
||||
@@ -14,7 +14,7 @@ maintainers:
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: file://../../../common
|
||||
version: 1.1.1
|
||||
version: 1.2.0
|
||||
home: https://github.com/ndom91/briefkasten
|
||||
icon: https://media.sys.truenas.net/apps/briefkasten/icons/icon.svg
|
||||
sources:
|
||||
|
||||
Binary file not shown.
BIN
library/ix-dev/community/briefkasten/charts/common-1.2.0.tgz
Normal file
BIN
library/ix-dev/community/briefkasten/charts/common-1.2.0.tgz
Normal file
Binary file not shown.
@@ -31,37 +31,10 @@ persistence:
|
||||
briefkasten:
|
||||
briefkasten:
|
||||
mountPath: {{ $storage.mountPath }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Database */}}
|
||||
postgresdata:
|
||||
enabled: true
|
||||
type: {{ .Values.briefkastenStorage.pgData.type }}
|
||||
datasetName: {{ .Values.briefkastenStorage.pgData.datasetName | default "" }}
|
||||
hostPath: {{ .Values.briefkastenStorage.pgData.hostPath | default "" }}
|
||||
targetSelector:
|
||||
# Postgres pod
|
||||
postgres:
|
||||
# Postgres container
|
||||
postgres:
|
||||
mountPath: /var/lib/postgresql/data
|
||||
# Postgres - Permissions container
|
||||
# Different than the 01-permissions
|
||||
permissions:
|
||||
mountPath: /mnt/directories/postgres_data
|
||||
postgresbackup:
|
||||
enabled: true
|
||||
type: {{ .Values.briefkastenStorage.pgBackup.type }}
|
||||
datasetName: {{ .Values.briefkastenStorage.pgBackup.datasetName | default "" }}
|
||||
hostPath: {{ .Values.briefkastenStorage.pgBackup.hostPath | default "" }}
|
||||
targetSelector:
|
||||
# Postgres backup pod
|
||||
postgresbackup:
|
||||
# Postgres backup container
|
||||
postgresbackup:
|
||||
mountPath: /postgres_backup
|
||||
# Postgres - Permissions container
|
||||
# Different than the 01-permissions
|
||||
permissions:
|
||||
mountPath: /mnt/directories/postgres_backup
|
||||
{{- include "ix.v1.common.app.postgresPersistence"
|
||||
(dict "pgData" .Values.briefkastenStorage.pgData
|
||||
"pgBackup" .Values.briefkastenStorage.pgBackup
|
||||
) | nindent 2 }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -12,15 +12,6 @@ service:
|
||||
port: {{ .Values.briefkastenNetwork.webPort }}
|
||||
nodePort: {{ .Values.briefkastenNetwork.webPort }}
|
||||
targetSelector: briefkasten
|
||||
postgres:
|
||||
enabled: true
|
||||
type: ClusterIP
|
||||
targetSelector: postgres
|
||||
ports:
|
||||
postgres:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 5432
|
||||
targetPort: 5432
|
||||
targetSelector: postgres
|
||||
{{- include "ix.v1.common.app.postgresService" $ | nindent 2 }}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user