mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-03 01:04:18 -03:00
feat(cnpg): cnpg version tracking and imageselection
This commit is contained in:
@@ -3,7 +3,7 @@ appVersion: ""
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: file://../common
|
||||
version: ~19.0.0
|
||||
version: ~19.1.0
|
||||
deprecated: false
|
||||
description: Helper chart to test different use cases of the common library
|
||||
home: https://github.com/truecharts/apps/tree/master/charts/library/common-test
|
||||
|
||||
@@ -15,7 +15,7 @@ maintainers:
|
||||
name: common
|
||||
sources: null
|
||||
type: library
|
||||
version: 19.0.0
|
||||
version: 19.1.0
|
||||
annotations:
|
||||
artifacthub.io/category: "integration-delivery"
|
||||
artifacthub.io/license: "BUSL-1.1"
|
||||
|
||||
@@ -132,6 +132,17 @@
|
||||
{{- $walAccessModes = . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Ensure version and container tracking */}}
|
||||
{{- $imageType := camelcase ( $objectData.type | default "postgres" ) }}
|
||||
{{- if eq $imageType "Postgres" }}
|
||||
{{- $imageType = "" }}
|
||||
{{- end }}
|
||||
{{- $imageKey := printf "postgres%v%vImage" $imageType $objectData.pgversion }}
|
||||
{{- $imageValue := fromJson (include "tc.v1.common.lib.container.imageSelector" (dict "rootCtx" $rootCtx "objectData" (dict "imageSelector" $imageKey))) }}
|
||||
{{- $formatImage := printf "%s:%s" $imageValue.repository $imageValue.tag }}
|
||||
|
||||
{{- $imageName := $objectData.cluster.imageName | default $formatImage }}
|
||||
|
||||
{{- include "tc.v1.common.lib.util.verifycrd" (dict "rootCtx" $rootCtx "crd" "clusters.postgresql.cnpg.io" "missing" "CloudNative-PG") }}
|
||||
|
||||
---
|
||||
@@ -154,6 +165,7 @@ metadata:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
imageName: {{ $imageName }}
|
||||
enableSuperuserAccess: {{ $enableSuperUser }}
|
||||
primaryUpdateStrategy: {{ $primaryUpdateStrategy }}
|
||||
primaryUpdateMethod: {{ $primaryUpdateMethod }}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{{- define "tc.v1.common.lib.cnpg.clusterName" -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- if not $objectData.version -}}
|
||||
{{- $_ := set $objectData "version" "legacy" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $clusterName := $objectData.name -}}
|
||||
{{/* Append version to the cluster name if available */}}
|
||||
{{- if ne $objectData.version "legacy" -}}
|
||||
{{- $clusterName = printf "%s-%v" $objectData.name $objectData.version -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Append the recovery string to the cluster name if available */}}
|
||||
{{- if $objectData.recValue -}}
|
||||
{{- $clusterName = printf "%s-%s" $clusterName $objectData.recValue -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $clusterName -}}
|
||||
{{- end -}}
|
||||
6
library/common/templates/lib/cnpg/_pgVersion.tpl
Normal file
6
library/common/templates/lib/cnpg/_pgVersion.tpl
Normal file
@@ -0,0 +1,6 @@
|
||||
{{- define "tc.v1.common.lib.cnpg.configmap.pgversion" -}}
|
||||
{{- $major := .major -}}
|
||||
enabled: true
|
||||
data:
|
||||
major: {{ $major }}
|
||||
{{- end -}}
|
||||
@@ -1,7 +0,0 @@
|
||||
{{- define "tc.v1.common.lib.cnpg.configmap.recoverystring" -}}
|
||||
{{- $recoveryString := .recoveryString -}}
|
||||
{{- $recoveryKey := .recoveryKey -}}
|
||||
enabled: true
|
||||
data:
|
||||
{{ $recoveryKey }}: {{ $recoveryString }}
|
||||
{{- end -}}
|
||||
@@ -9,8 +9,8 @@
|
||||
{{- end -}}
|
||||
|
||||
{{- if (hasKey $objectData "version") -}}
|
||||
{{- $validVersions := (list "legacy") -}}
|
||||
{{- if not (mustHas $objectData.version $validVersions) -}}
|
||||
{{- $validVersions := (list "15" "16") -}}
|
||||
{{- if not (mustHas ( toString $objectData.version ) $validVersions) -}}
|
||||
{{- fail (printf "CNPG - Expected [version] to be one of [%s], but got [%s]" (join ", " $validVersions) $objectData.version) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -35,7 +35,7 @@
|
||||
{{- end -}}
|
||||
|
||||
{{- if (hasKey $objectData "type") -}}
|
||||
{{- $validTypes := (list "postgresql" "postgis" "timescaledb") -}}
|
||||
{{- $validTypes := (list "postgres" "postgis" "timescaledb") -}}
|
||||
{{- if not (mustHas $objectData.type $validTypes) -}}
|
||||
{{- fail (printf "CNPG Cluster - Expected [type] to be one of [%s], but got [%s]" (join ", " $validTypes) $objectData.type) -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -19,32 +19,31 @@
|
||||
{{/* Short name is the one that defined on the chart*/}}
|
||||
{{- $_ := set $objectData "shortName" $name -}}
|
||||
{{/* Set the cluster name */}}
|
||||
{{- $_ := set $objectData "clusterName" (include "tc.v1.common.lib.cnpg.clusterName" (dict "objectData" $objectData)) -}}
|
||||
|
||||
{{/* Handle recovery string */}}
|
||||
{{- $recoveryValue := "" -}}
|
||||
{{- $recoveryKey := "recovery-string" -}}
|
||||
{{- $recoveryConfigMapName := printf "cnpg-%s-%s" $objectData.shortName $recoveryKey -}}
|
||||
|
||||
{{/* If there are previous configmap, fetch value */}}
|
||||
{{- with (lookup "v1" "ConfigMap" $.Release.Namespace $recoveryConfigMapName) -}}
|
||||
{{- $recoveryValue = (index .data $recoveryKey) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* If forced recovery is requested... */}}
|
||||
{{- if $objectData.forceRecovery -}}
|
||||
{{- $recoveryValue = randAlphaNum 5 -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Recreate the configmap if there is a recovery value */}}
|
||||
{{- if $recoveryValue -}}
|
||||
{{- $_ := set $objectData "recoveryValue" $recoveryValue -}}
|
||||
{{- $recConfig := include "tc.v1.common.lib.cnpg.configmap.recoverystring" (dict "recoveryString" $recoveryValue "recoveryKey" $recoveryKey) | fromYaml -}}
|
||||
{{- $_ := set $.Values.configmap $recoveryConfigMapName $recConfig -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $objectData "clusterName" $objectData.name -}}
|
||||
|
||||
{{- if eq $enabled "true" -}}
|
||||
|
||||
{{/* Handle version string */}}
|
||||
{{- $pgversion := toString ( $objectData.version | default $.Values.global.fallbackDefaults.pgversion ) -}}
|
||||
{{- $versionConfigMapName := printf "cnpg-%s-pgversion" $objectData.shortName -}}
|
||||
|
||||
{{/* If there are previous configmap, fetch value */}}
|
||||
{{- with (lookup "v1" "ConfigMap" $.Release.Namespace $versionConfigMapName) -}}
|
||||
{{/* If a new major is set and upgrade is enabled, upgrade */}}
|
||||
{{- if and ( ne $pgversion .data.major ) $objectData.upgradeMajor -}}
|
||||
{{/* TODO handle postgresql major updates here */}}
|
||||
{{- else if .data.major -}}
|
||||
{{- $pgversion = ( toString .data.major ) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* append the pg (major) version to objectData */}}
|
||||
{{- $_ := set $objectData "pgversion" $pgversion -}}
|
||||
|
||||
{{/* ensure configmap with pg version is updated */}}
|
||||
{{- $verConfig := include "tc.v1.common.lib.cnpg.configmap.pgversion" (dict "major" $pgversion ) | fromYaml -}}
|
||||
{{- $_ := set $.Values.configmap $versionConfigMapName $verConfig -}}
|
||||
|
||||
{{- include "tc.v1.common.lib.util.metaListToDict" (dict "objectData" $objectData) -}}
|
||||
|
||||
{{/* Handle Backups/ScheduledBackups */}}
|
||||
|
||||
@@ -7,6 +7,11 @@ global:
|
||||
# -- Set a global namespace
|
||||
# TODO: Currently some objects do not support this
|
||||
namespace: ""
|
||||
fallbackDefaults:
|
||||
# -- Define a postgresql version for CNPG
|
||||
# will be used for all CNPG objects
|
||||
# Can be overruled per CNPG objects
|
||||
pgversion: 16
|
||||
metallb:
|
||||
# -- Adds metalLB annotations to services
|
||||
addServiceAnnotations: true
|
||||
@@ -504,6 +509,36 @@ mongodbClientImage:
|
||||
tag: v1.1.0@sha256:9268e23927c4abd9bd031ef62a8a36c58e15361cf3f617906029fa4b6f25c71c
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
postgres15Image:
|
||||
repository: ghcr.io/cloudnative-pg/postgresql
|
||||
tag: '15.6'
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
postgres16Image:
|
||||
repository: ghcr.io/cloudnative-pg/postgresql
|
||||
tag: '16.2'
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
postgresPostgis15Image:
|
||||
repository: ghcr.io/cloudnative-pg/postgis
|
||||
tag: "15-3.4"
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
postgresPostgis16Image:
|
||||
repository: ghcr.io/cloudnative-pg/postgis
|
||||
tag: "16-3.4"
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
postgresVectors15Image:
|
||||
repository: ghcr.io/tensorchord/cloudnative-pgvecto.rs
|
||||
tag: "15.6-v0.2.1"
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
postgresVectors16Image:
|
||||
repository: ghcr.io/tensorchord/cloudnative-pgvecto.rs
|
||||
tag: "16.2-v0.2.1"
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
# -- OpenVPN specific configuration
|
||||
# @default -- See below
|
||||
openvpnImage:
|
||||
@@ -1043,20 +1078,17 @@ cnpg:
|
||||
labels: {}
|
||||
annotations: {}
|
||||
|
||||
# -- Destroys the current cluster to forge a new cluster or recovery operation
|
||||
# ABSOLUTELY DESTRUCTIVE
|
||||
forceRecovery: false
|
||||
|
||||
# Type of the CNPG database. Available types:
|
||||
# * `postgresql`
|
||||
# * `postgres`
|
||||
# * `postgis`
|
||||
# * `timescaledb`
|
||||
type: postgresql
|
||||
# * `vectors`
|
||||
type: postgres
|
||||
|
||||
# Version of Postgresql to use, changes cluster naming scheme
|
||||
# * `legacy`
|
||||
# TODO: allow for selecting other versions
|
||||
version: legacy
|
||||
# * `15`
|
||||
# * `16`
|
||||
version: 16
|
||||
|
||||
# Cluster mode of operation. Available modes:
|
||||
# * `standalone` - default mode. Creates new or updates an existing CNPG cluster.
|
||||
|
||||
Reference in New Issue
Block a user