diff --git a/deploy/helm/cnpgstac/.helmignore b/deploy/helm/cnpgstac/.helmignore new file mode 100644 index 0000000..109f7e0 --- /dev/null +++ b/deploy/helm/cnpgstac/.helmignore @@ -0,0 +1,40 @@ +# Copyright 2025 CS Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ + +# dependencies +.tgz \ No newline at end of file diff --git a/deploy/helm/cnpgstac/Chart.yaml b/deploy/helm/cnpgstac/Chart.yaml new file mode 100644 index 0000000..726510b --- /dev/null +++ b/deploy/helm/cnpgstac/Chart.yaml @@ -0,0 +1,30 @@ +# Copyright 2025 CS Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v2 +dependencies: + - name: common + repository: oci://registry-1.docker.io/bitnamicharts + tags: + - bitnami-common + version: 2.x +description: A CS Group STAC backend based on CloudNativePG PostGIS and PgSTAC. +home: https://github.com/csgroup-oss/eo-catalogue +icon: https://github.com/csgroup-oss/eo-catalog/raw/refs/heads/main/docs/static/eo-catalogue-logo-1080.webp +name: eo-cnpgstac +sources: + - https://github.com/csgroup-oss/eo-catalogue +type: application +version: 1.0.0-alpha +appVersion: 0.9.8 diff --git a/deploy/helm/cnpgstac/templates/_helpers.tpl b/deploy/helm/cnpgstac/templates/_helpers.tpl new file mode 100644 index 0000000..228b859 --- /dev/null +++ b/deploy/helm/cnpgstac/templates/_helpers.tpl @@ -0,0 +1,110 @@ +{{/* +Copyright 2025 CS Group + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +{{/* +Return the proper Docker Image Registry Secret Names +*/}} +{{- define "cnpgstac.imagePullSecrets" -}} +{{- include "common.images.pullSecrets" (dict "images" (list .Values.cnpgstac.image) "global" .Values.global) -}} +{{- end -}} + +{{/* +Render imageCatalogRef block inside spec +*/}} +{{- define "cnpgstac.imageCatalogRef" -}} +apiGroup: postgresql.cnpg.io +kind: ClusterImageCatalog +name: {{ default "cnpgstac" .Values.cnpgstac.imageCatalog.name }} +major: {{ default 17 .Values.cnpgstac.imageCatalog.major }} +{{- end -}} + +{{/* +Render only the images list for ClusterImageCatalog, with inline image values +*/}} +{{- define "cnpgstac.clusterImageCatalogList" -}} +{{- range .Values.cnpgstac.imageCatalog.images }} + - major: {{ .major }} + image: "{{- $registry := trimSuffix "/" (default "ghcr.io" .registry) -}} + {{- $repository := trimPrefix "/" (default "csgroup-oss/eo-catalog-cnpgstac" .repository) -}} + {{- $tag := default "latest" .tag -}} + {{- $digest := .digest -}} + {{- if $digest -}} + {{- printf "%s/%s@%s" $registry $repository $digest -}} + {{- else -}} + {{- printf "%s/%s:%v" $registry $repository $tag -}} + {{- end }}" +{{- end }} +{{- end }} + +{{/* +Calculate the memory settings +*/}} + +{{/* +Convert suffix to PostgreSQL valid memory units : +https://www.postgresql.org/docs/current/config-setting.html#CONFIG-SETTING-NAMES-VALUES +*/}} +{{- define "limit_suffix_bytes" -}} +{{- $limit_suffix := .Values.cnpgstac.resources.limits.memory | toString | regexFind "[^0-9.]+" -}} + {{- if eq "G" $limit_suffix -}} + GB + {{- else if eq "Gi" $limit_suffix -}} + GB + {{- else if eq "M" $limit_suffix -}} + MB + {{- else if eq "Mi" $limit_suffix -}} + MB + {{- else if eq "k" $limit_suffix -}} + KB + {{- else if eq "Ki" $limit_suffix -}} + KB + {{- else if eq "T" $limit_suffix -}} + TB + {{- else if eq "Ti" $limit_suffix -}} + TB + {{- else if eq "P" $limit_suffix -}} + PB + {{- else if eq "Pi" $limit_suffix -}} + PB + {{- else if eq "E" $limit_suffix -}} + EB + {{- else if eq "Ei" $limit_suffix -}} + EB + {{- else if eq "" $limit_suffix -}} + {{- /* Check for empty suffix, meaning bytes */ -}} + B + {{- else -}} + {{- /* Unknown suffix case, assume GB */ -}} + GB {{- printf " # Warning: Unknown suffix '%s' Defaulting to GB." . -}} + {{- end -}} +{{- end -}} + +{{/* +Calculate shared_buffers: should be 1/4 of the total RAM +*/}} +{{- define "shared_buffers" -}} +{{- $limit_value := .Values.cnpgstac.resources.limits.memory | toString | regexFind "[0-9.]+" -}} +{{ mulf $limit_value 0.25 }} +{{- end -}} + +{{/* +Calculate effective_cache_size: should be 3/4 of the total RAM +*/}} +{{- define "effective_cache_size" -}} +{{- $limit_value := .Values.cnpgstac.resources.limits.memory | toString | regexFind "[0-9.]+" -}} +{{ mulf $limit_value 0.75 }} +{{- end -}} + diff --git a/deploy/helm/cnpgstac/templates/cnpgstac/Cluster.yaml b/deploy/helm/cnpgstac/templates/cnpgstac/Cluster.yaml new file mode 100644 index 0000000..c243233 --- /dev/null +++ b/deploy/helm/cnpgstac/templates/cnpgstac/Cluster.yaml @@ -0,0 +1,139 @@ +# Copyright 2025 CS Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: {{ .Values.cnpgstac.clusterName }} + namespace: {{ include "common.names.namespace" . | quote }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + app.kubernetes.io/component: cnpgstac + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.cnpgstac.clusterLabels }} + {{- include "common.tplvalues.render" (dict "value" .Values.cnpgstac.clusterLabels "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }} + {{- end }} +spec: + {{- if .Values.cnpgstac.imageCatalog.enabled }} + imageCatalogRef: + apiGroup: postgresql.cnpg.io + kind: ClusterImageCatalog + name: {{ .Values.cnpgstac.imageCatalog.name }} + major: {{ .Values.cnpgstac.imageCatalog.major }} + {{- else if or (and .Values.cnpgstac.image.repository .Values.cnpgstac.image.registry) .Values.global.imageRegistry }} + {{- $image := include "common.images.image" (dict "imageRoot" .Values.cnpgstac.image "global" .Values.global) | trim }} + imageName: {{ $image }} + {{- else }} + imageCatalogRef: + apiGroup: postgresql.cnpg.io + kind: ClusterImageCatalog + name: postgis-standard-trixie + major: 17 + {{- end }} + {{- if .Values.cnpgstac.imagePullPolicy }} + imagePullPolicy: {{ .Values.cnpgstac.image.pullPolicy }} + {{- end }} + {{- include "cnpgstac.imagePullSecrets" . | nindent 2 }} + instances: {{ .Values.cnpgstac.instances | default "3" }} + {{- if .Values.cnpgstac.startDelay }} + startDelay: {{ .Values.cnpgstac.startDelay }} + {{- end }} + {{- if .Values.cnpgstac.stopDelay }} + stopDelay: {{ .Values.cnpgstac.stopDelay }} + {{- end }} + {{- if .Values.cnpgstac.primaryUpdateStrategy }} + primaryUpdateStrategy: {{ .Values.cnpgstac.primaryUpdateStrategy }} + {{- end }} + {{- with .Values.cnpgstac.bootstrap }} + bootstrap: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- if .Values.cnpgstac.superUserAccess.enabled }} + enableSuperuserAccess: true + {{- end }} + {{- if .Values.cnpgstac.backup.barman.enabled }} + plugins: + - name: barman-cloud.cloudnative-pg.io + isWALArchiver: {{ .Values.cnpgstac.backup.barman.isWALArchiver }} + parameters: + barmanObjectName: {{ .Values.cnpgstac.backup.barman.barmanObjectStore.name }} + {{- end }} + {{- if .Values.cnpgstac.superUserAccess.existingSecret }} + superuserSecret: + name: {{- .Values.cnpgstac.superUserAccess.existingSecret }} + {{- end }} + postgresql: + parameters: + {{- with .Values.cnpgstac.postgresql.parameters }} + {{- toYaml . | nindent 6 }} + {{- end }} + # shared_buffers: should be 1/4 of the total RAM + shared_buffers: {{ include "shared_buffers" . }}{{ include "limit_suffix_bytes" . }} + # effective_cache_size: should be 3/4 of the total RAM + effective_cache_size: {{ include "effective_cache_size" . }}{{ include "limit_suffix_bytes" . }} + {{- with .Values.cnpgstac.postgresql.shared_preload_libraries }} + shared_preload_libraries: + {{- toYaml . | nindent 6 }} + {{- end }} + {{- with .Values.cnpgstac.postgresql.pg_hba }} + pg_hba: + {{- toYaml . | nindent 6 }} + {{- end }} + {{- with .Values.cnpgstac.postgresql.pg_ident }} + pg_ident: + {{- toYaml . | nindent 6 }} + {{- end }} + {{- with .Values.cnpgstac.postgresql.synchronous }} + synchronous: + {{- toYaml . | nindent 6 }} + {{ end }} + {{- if .Values.cnpgstac.resources }} + resources: {{- toYaml .Values.cnpgstac.resources | nindent 4 }} + {{- end }} + {{- if .Values.cnpgstac.persistence.enabled }} + storage: + pvcTemplate: + accessModes: + {{- range .Values.cnpgstac.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.cnpgstac.persistence.size | quote }} + volumeMode: Filesystem + {{- include "common.storage.class" (dict "persistence" .Values.cnpgstac.persistence "global" .Values.global) | nindent 6 }} + {{- end }} + {{- if .Values.cnpgstac.affinity }} + affinity: {{- include "common.tplvalues.render" (dict "value" .Values.cnpgstac.affinity "context" $) | nindent 4 }} + {{- else if or .Values.cnpgstac.podAffinityPreset .Values.cnpgstac.podAntiAffinityPreset .Values.cnpgstac.nodeAffinityPreset }} + affinity: + # https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-AffinityConfiguration + enablePodAntiAffinity: false + topologyKey: '' + podAntiAffinityType: '' + # tolerations: '' + additionalPodAffinity: {{- include "common.affinities.pods" (dict "type" .Values.cnpgstac.podAffinityPreset "instance" .Chart.Name "context" $) | nindent 6}} + additionalPodAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.cnpgstac.podAntiAffinityPreset "instance" .Chart.Name "context" $) | nindent 8 }} + nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.cnpgstac.nodeAffinityPreset.type "key" .Values.cnpgstac.nodeAffinityPreset.key "values" .Values.cnpgstac.nodeAffinityPreset.values) | nindent 6 }} + {{- end }} + {{- if .Values.cnpgstac.nodeSelector }} + nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.cnpgstac.nodeSelector "context" $) | nindent 6 }} + {{- end }} + {{- if .Values.cnpgstac.tolerations }} + tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.cnpgstac.tolerations "context" .) | nindent 6 }} + {{- end }} diff --git a/deploy/helm/cnpgstac/templates/cnpgstac/ClusterImageCatalog.yaml b/deploy/helm/cnpgstac/templates/cnpgstac/ClusterImageCatalog.yaml new file mode 100644 index 0000000..b167764 --- /dev/null +++ b/deploy/helm/cnpgstac/templates/cnpgstac/ClusterImageCatalog.yaml @@ -0,0 +1,32 @@ +# Copyright 2025 CS Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if .Values.cnpgstac.imageCatalog.enabled }} +apiVersion: postgresql.cnpg.io/v1 +kind: ClusterImageCatalog +metadata: + name: {{ .Values.cnpgstac.imageCatalog.name }} + namespace: {{ include "common.names.namespace" . | quote }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + app.kubernetes.io/component: cnpgstac + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }} + {{- end }} +spec: + images: +{{- include "cnpgstac.clusterImageCatalogList" . | indent 4 }} +{{- end }} \ No newline at end of file diff --git a/deploy/helm/cnpgstac/templates/cnpgstac/ClusterImageCatalogPostgis.yaml b/deploy/helm/cnpgstac/templates/cnpgstac/ClusterImageCatalogPostgis.yaml new file mode 100644 index 0000000..12c14aa --- /dev/null +++ b/deploy/helm/cnpgstac/templates/cnpgstac/ClusterImageCatalogPostgis.yaml @@ -0,0 +1,46 @@ +# Copyright 2025 CS Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: postgresql.cnpg.io/v1 +kind: ClusterImageCatalog +metadata: + name: postgis-standard-trixie + namespace: {{ include "common.names.namespace" . | quote }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + app.kubernetes.io/component: cnpgstac + images.cnpg.io/family: postgis + images.cnpg.io/type: standard + images.cnpg.io/os: trixie + images.cnpg.io/date: '20251006' + images.cnpg.io/publisher: cnpg.io + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }} + {{- end }} +spec: + images: + - major: 13 + image: ghcr.io/cloudnative-pg/postgis:13-3-standard-trixie + - major: 14 + image: ghcr.io/cloudnative-pg/postgis:14-3-standard-trixie + - major: 15 + image: ghcr.io/cloudnative-pg/postgis:15-3-standard-trixie + - major: 16 + image: ghcr.io/cloudnative-pg/postgis:16-3-standard-trixie + - major: 17 + image: ghcr.io/cloudnative-pg/postgis:17-3-standard-trixie + - major: 18 + image: ghcr.io/cloudnative-pg/postgis:18-3-standard-trixie \ No newline at end of file diff --git a/deploy/helm/cnpgstac/templates/cnpgstac/Configmap-extensions.yaml b/deploy/helm/cnpgstac/templates/cnpgstac/Configmap-extensions.yaml new file mode 100644 index 0000000..628e93a --- /dev/null +++ b/deploy/helm/cnpgstac/templates/cnpgstac/Configmap-extensions.yaml @@ -0,0 +1,102 @@ +# Copyright 2025 CS Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{- if .Values.cnpgstac.custom.enabled }} +{{- if or .Values.cnpgstac.custom.extensions .Values.cnpgstac.custom.queryables }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-patch-post-action + namespace: {{ include "common.names.namespace" . | quote }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + app.kubernetes.io/component: cnpgstac + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }} + {{- end }} +data: + pgstac_extensions_queryables.sh: |- + psql -X -q -v ON_ERROR_STOP=1 {{ .Values.cnpgstac.bootstrap.initdb.database }} <