feat(cnpg): allow for backup revisions and setting serverName (#724)

**Description**
recovery and backup need seperate serverNames.
We make this easy using a user-setable revision, but also will allow for
custom servernames

**⚙️ Type of change**

- [x] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ 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:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [ ] ⚖️ My code follows the style guidelines of this project
- [ ] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [ ] ⬆️ 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.

- [ ] 🖼️ 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._
This commit is contained in:
Kjeld Schouten
2024-03-05 22:03:04 +01:00
committed by GitHub
parent 8ef498412b
commit 80435d9747
6 changed files with 57 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ appVersion: ""
dependencies:
- name: common
repository: file://../common
version: ~18.1.0
version: ~18.2.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

View File

@@ -15,7 +15,7 @@ maintainers:
name: common
sources: null
type: library
version: 18.1.8
version: 18.2.0
annotations:
artifacthub.io/category: "integration-delivery"
artifacthub.io/license: "BUSL-1.1"

View File

@@ -6,6 +6,7 @@
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $rootCtx -}}
{{- $secretName := (printf "%s-cnpg-%s-provider-%s-azure-creds" $fullname $objectData.shortName $type) -}}
{{- $serverName := $objectData.clusterName -}}
{{- $endpointURL := "" -}}
{{- $destinationPath := "" -}}
@@ -14,10 +15,22 @@
{{- $endpointURL = $objectData.recovery.endpointURL -}}
{{- $destinationPath = $objectData.recovery.destinationPath -}}
{{- $k = "recovery" -}}
{{- if $objectData.recovery.serverName -}}
{{- $serverName = $objectData.recovery.serverName -}}
{{- end -}}
{{- if $objectData.recovery.revision -}}
{{- $serverName = printf "%s-%s" $serverName $objectData.recovery.revision -}}
{{- end -}}
{{- else if eq $type "backup" -}}
{{- $endpointURL = $objectData.backups.endpointURL -}}
{{- $destinationPath = $objectData.backups.destinationPath -}}
{{- $k = "backups" -}}
{{- if $objectData.backups.serverName -}}
{{- $serverName = $objectData.backups.serverName -}}
{{- end -}}
{{- if $objectData.backups.revision -}}
{{- $serverName = printf "%s-%s" $serverName $objectData.backups.revision -}}
{{- end -}}
{{- end -}}
{{- if not $destinationPath -}}
{{- if not $data.storageAccount -}}
@@ -33,6 +46,7 @@
{{- end }}
endpointURL: {{ $endpointURL }}
destinationPath: {{ $destinationPath }}
serverName: {{ $serverName }}
azureCredentials:
connectionString:
name: {{ $secretName }}

View File

@@ -6,6 +6,7 @@
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $rootCtx -}}
{{- $secretName := (printf "%s-cnpg-%s-provider-%s-google-creds" $fullname $objectData.shortName $type) -}}
{{- $serverName := $objectData.clusterName -}}
{{- $gkeEnv := false -}}
{{- if (kindIs "bool" $data.gkeEnvionment) -}}
@@ -19,10 +20,22 @@
{{- $endpointURL = $objectData.recovery.endpointURL -}}
{{- $destinationPath = $objectData.recovery.destinationPath -}}
{{- $k = "recovery" -}}
{{- if $objectData.recovery.serverName -}}
{{- $serverName = $objectData.recovery.serverName -}}
{{- end -}}
{{- if $objectData.recovery.revision -}}
{{- $serverName = printf "%s-%s" $serverName $objectData.recovery.revision -}}
{{- end -}}
{{- else if eq $type "backup" -}}
{{- $endpointURL = $objectData.backups.endpointURL -}}
{{- $destinationPath = $objectData.backups.destinationPath -}}
{{- $k = "backups" -}}
{{- if $objectData.backups.serverName -}}
{{- $serverName = $objectData.backups.serverName -}}
{{- end -}}
{{- if $objectData.backups.revision -}}
{{- $serverName = printf "%s-%s" $serverName $objectData.backups.revision -}}
{{- end -}}
{{- end -}}
{{- if not $destinationPath -}}
{{- if not $data.bucket -}}
@@ -32,6 +45,7 @@
{{- end }}
endpointURL: {{ $endpointURL }}
destinationPath: {{ $destinationPath }}
serverName: {{ $serverName }}
googleCredentials:
gkeEnvironment: {{ $gkeEnv }}
applicationCredentials:

View File

@@ -6,6 +6,7 @@
{{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $rootCtx -}}
{{- $secretName := (printf "%s-cnpg-%s-provider-%s-s3-creds" $fullname $objectData.shortName $type) -}}
{{- $serverName := $objectData.clusterName -}}
{{- $endpointURL := "" -}}
{{- $destinationPath := "" -}}
@@ -14,10 +15,22 @@
{{- $endpointURL = $objectData.recovery.endpointURL -}}
{{- $destinationPath = $objectData.recovery.destinationPath -}}
{{- $k = "recovery" -}}
{{- if $objectData.recovery.serverName -}}
{{- $serverName = $objectData.recovery.serverName -}}
{{- end -}}
{{- if $objectData.recovery.revision -}}
{{- $serverName = printf "%s-%s" $serverName $objectData.recovery.revision -}}
{{- end -}}
{{- else if eq $type "backup" -}}
{{- $endpointURL = $objectData.backups.endpointURL -}}
{{- $destinationPath = $objectData.backups.destinationPath -}}
{{- $k = "backups" -}}
{{- if $objectData.backups.serverName -}}
{{- $serverName = $objectData.backups.serverName -}}
{{- end -}}
{{- if $objectData.backups.revision -}}
{{- $serverName = printf "%s-%s" $serverName $objectData.backups.revision -}}
{{- end -}}
{{- end -}}
{{- if not $destinationPath -}}
{{- if not $data.bucket -}}
@@ -31,8 +44,10 @@
{{- end -}}
{{- $endpointURL = (printf "https://s3.%s.amazonaws.com" $data.region) -}}
{{- end }}
endpointURL: {{ $endpointURL }}
destinationPath: {{ $destinationPath }}
serverName: {{ $serverName }}
s3Credentials:
accessKeyId:
name: {{ $secretName }}

View File

@@ -1155,6 +1155,11 @@ cnpg:
# * `pg_basebackup` - Recovers a CNPG cluster viaa streaming replication protocol. Useful if you want to
# migrate databases to CloudNativePG, even from outside Kubernetes. # TODO
method: object_store
## set a revision to append to the serverName to ensure restore and backup dont target the same thing
# revision: 1
# override serverName in recovery obkect
servername: ""
## Point in time recovery target. Specify one of the following:
pitrTarget:
@@ -1203,6 +1208,13 @@ cnpg:
# S3: https://s3.<region>.amazonaws.com"
endpointURL: "" # Leave empty if using the default S3 endpoint
## set a revision to append to the serverName to ensure restore and backup dont target the same thing
# revision: 1
# override serverName in recovery obkect
servername: ""
# Overrides the provider specific default path. Defaults to:
# S3: s3://<bucket><path>
# Azure: https://<storageAccount>.<serviceName>.core.windows.net/<clusterName><path>