From 80435d97476a27a754dfed339181a737794fd1b2 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Tue, 5 Mar 2024 22:03:04 +0100 Subject: [PATCH] feat(cnpg): allow for backup revisions and setting serverName (#724) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **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?** **๐Ÿ“ƒ Notes:** **โœ”๏ธ 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._ --- library/common-test/Chart.yaml | 2 +- library/common/Chart.yaml | 2 +- .../lib/cnpg/barmanObjectStore/_azure.tpl | 14 ++++++++++++++ .../lib/cnpg/barmanObjectStore/_google.tpl | 14 ++++++++++++++ .../templates/lib/cnpg/barmanObjectStore/_s3.tpl | 15 +++++++++++++++ library/common/values.yaml | 12 ++++++++++++ 6 files changed, 57 insertions(+), 2 deletions(-) diff --git a/library/common-test/Chart.yaml b/library/common-test/Chart.yaml index 2f2ff45b..a48846ba 100644 --- a/library/common-test/Chart.yaml +++ b/library/common-test/Chart.yaml @@ -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 diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 8961761e..84e9284c 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -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" diff --git a/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl b/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl index 6b19f93e..90cdde34 100644 --- a/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl +++ b/library/common/templates/lib/cnpg/barmanObjectStore/_azure.tpl @@ -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 }} diff --git a/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl b/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl index e70f0694..6a1e0fdf 100644 --- a/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl +++ b/library/common/templates/lib/cnpg/barmanObjectStore/_google.tpl @@ -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: diff --git a/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl b/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl index 2bcb8251..74dbb400 100644 --- a/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl +++ b/library/common/templates/lib/cnpg/barmanObjectStore/_s3.tpl @@ -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 }} diff --git a/library/common/values.yaml b/library/common/values.yaml index ac263832..e8d1f711 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -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..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:// # Azure: https://..core.windows.net/