Files
library-charts/library/common/templates/class/_cnpgCluster.tpl
Kjeld Schouten 02be440b56 feat(common): BREAKING CHANGE add support for PVC static provisioning and dataSource (#554)
**Description**
This PR aims to add support for static provisioning of PVC-PV volume
pairs.

THis ensures we're in-line with what iX-Common backend for SCALE
supports and expands on that by allowing users on non-SCALE systems to
create custom PVC-PV bindings

It also adds initial support for dataSource, for either backup/snapshot
or PVC cloning purposses.
In addition it ensure that a randomised hash is used when dataSource is
set, so we can force a recrease when it's changed.

This also merged `.Values.volumeClaimTemplates` with
`.Values.persistence` by setting `.type` to `vct` on any persistence
reference.
This means users with statefull sets, need to move **all** their
`.Values.volumeClaimTemplates` references into `.Values.persistence`
like this:

old:
```
volumeClaimTemplates:
  data:
    enabled: true
    mountPath: "/var/lib/ldap/"
```

New:
```
persistence:
  data:
    enabled: true
    type: "vct"
    mountPath: "/var/lib/ldap/"
```

On top of this, this PR breaks ALL VCT's by improving the naming scheme.
It's important to NOT install this update on statefull sets lightly, as
this might destroy your data.

Fixes: #558 
Fixes: #562

**⚙️ Type of change**

- [x] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [x] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
Technically breaking, as this changes the CNPG storage structure in
values.yaml.
The new structure for CNPG storage is the same as .Values.Persistence
(type is always PVC)

Also Breaking because of VolumeClaimTemplates being merged with
Persistence

**✔️ Checklist:**

- [x] ⚖️ My code follows the style guidelines of this project
- [x] 👀 I have performed a self-review of my own code
- [x] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [x] 📄 I have made corresponding changes to the documentation
- [x] ⚠️ My changes generate no new warnings
- [x] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [x] ⬆️ I increased versions for any altered app according to semantic
versioning

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [x] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [x] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._

---------

Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
Co-authored-by: Stavros kois <s.kois@outlook.com>
2023-11-12 17:18:35 +01:00

70 lines
2.4 KiB
Smarty

{{- define "tc.v1.common.class.cnpg.cluster" -}}
{{- $values := .Values.cnpg -}}
{{- if hasKey . "ObjectValues" -}}
{{- with .ObjectValues.cnpg -}}
{{- $values = . -}}
{{- end -}}
{{- end -}}
{{- $cnpgClusterName := $values.name -}}
{{- $cnpgClusterLabels := $values.labels -}}
{{- $cnpgClusterAnnotations := $values.annotations -}}
{{- $hibernation := "off" -}}
{{- if or $values.hibernate (include "tc.v1.common.lib.util.stopAll" $) -}}
{{- $hibernation = "on" -}}
{{- end }}
---
apiVersion: {{ include "tc.v1.common.capabilities.cnpg.cluster.apiVersion" $ }}
kind: Cluster
metadata:
name: {{ $cnpgClusterName }}
namespace: {{ $.Values.namespace | default $.Values.global.namespace | default $.Release.Namespace }}
{{- $labels := (mustMerge ($cnpgClusterLabels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $ | fromYaml)) }}
labels:
cnpg.io/reload: "on"
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $ "labels" $labels) | trim) }}
{{- . | nindent 4 }}
{{- end }}
{{- $annotations := (mustMerge ($cnpgClusterAnnotations | default dict) (include "tc.v1.common.lib.metadata.allAnnotations" $ | fromYaml)) }}
annotations:
cnpg.io/hibernation: {{ $hibernation | quote }}
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $ "annotations" $annotations) | trim) }}
{{- . | nindent 4 }}
{{- end }}
spec:
instances: {{ $values.instances | default 2 }}
bootstrap:
initdb:
database: {{ $values.database | default "app" }}
owner: {{ $values.user | default "app" }}
secret:
name: {{ $cnpgClusterName }}-user
primaryUpdateStrategy: {{ $values.primaryUpdateStrategy | default "unsupervised" }}
storage:
pvcTemplate:
{{- include "tc.v1.common.lib.storage.pvc.spec" (dict "rootCtx" $ "objectData" $values.storage) | trim | nindent 6 }}
walStorage:
pvcTemplate:
{{- include "tc.v1.common.lib.storage.pvc.spec" (dict "rootCtx" $ "objectData" $values.walStorage) | trim | nindent 6 }}
monitoring:
enablePodMonitor: {{ $values.monitoring.enablePodMonitor | default true }}
nodeMaintenanceWindow:
inProgress: false
reusePVC: true
{{- with (include "tc.v1.common.lib.container.resources" (dict "rootCtx" $ "objectData" $values) | trim) }}
resources:
{{- . | nindent 4 }}
{{- end }}
postgresql:
{{- tpl ( $values.postgresql | toYaml ) $ | nindent 4 }}
{{- end -}}