feat(plugins): allow plugin defintion#680
Conversation
ef1fe69 to
fff1e84
Compare
…ugin Signed-off-by: Philipp Hamann <84906475+pha91@users.noreply.github.com>
fff1e84 to
3118f67
Compare
| limits: | ||
| cpu: 100m | ||
| memory: 256Mi | ||
| memory: 256Mi |
There was a problem hiding this comment.
trailing spaces after memory: 256Mi
Signed-off-by: Philipp Hamann <84906475+pha91@users.noreply.github.com>
Signed-off-by: Philipp Hamann <84906475+pha91@users.noreply.github.com>
|
As far as I can see, the new |
|
Added the retentionPolicy to the ObjectStore. Thanks @Const-antine for the reminder |
Signed-off-by: Philipp Hamann <84906475+pha91@users.noreply.github.com>
5a84d88 to
0289e16
Compare
|
@itay-grudev Is there anything pending on this PR? |
|
I tried out the PR with such a values file: It worked. One thing though, I was not able to use (but that's not so important). To make it work I had to use together with It seems (I used Regarding the software design: I haven't really thought it through yet, but maybe it would be better to store the S3 configurations under under |
|
Hi @eriksjolund, As a parameter in the plugin definiton section or in the barmanObjectStore config? The idea was to use that config in the BarmanObjectStore CRD and reference this object in the plugin like documented here: Defining ObjectStore |
|
I have one configuration that is working fine: The cluster, scheduledbackup and the backup are created just fine. As a test I wanted to see if there is a way to modify to My idea was to add: % diff -U6 -u ~/values.yaml ~/values2.yaml
--- /Users/myuser/values.yaml 2025-11-03 16:58:22
+++ /Users/myuser/values2.yaml 2025-11-24 15:16:12
@@ -37,17 +37,20 @@
backups:
enabled: true
endpointURL: "https://s3.example.com"
destinationPath: "s3://mybucket/testcnpg"
provider: s3
+ s3:
+ accessKey: "AWS_ACCESS_KEY_ID"
+ secretKey: "AWS_SECRET_ACCESS_KEY"
secret:
# -- Whether to create a secret for the backup credentials
create: false
# -- Name of the backup credentials secret
name: netapp-s3-creds
scheduledBackups:
- name: daily-backup
schedule: "0 2 14 * * *"
# -- Retention policy for backupsWhen I tried it out, the backup failed with the error message For details, see this command (I don't know if it should be possible change the names in the secret) |
|
@itay-grudev do you need any other features or informations to merge this PR? |
…same namespace Signed-off-by: Philipp Hamann <84906475+pha91@users.noreply.github.com>
|
Hello maintainers, |
|
thanks @tamcore for pointing me to this, I somehow didn't see it when checking for existing PRs. I personally feel like this chart would be better served by keeping it simpler. Instead of trying to manage every object and property in detail, a few more general options (list of plugins, list of externalClusters, ...) would be simpler to use, maintain and extend. Some charts have *Spec properties to simply passthrough underlying resources, if the helm chart would otherwise just duplicate it (e.g. prometheus or rook). Umbrella charts are a nice way to introduce additional resources like the ObjectStore here. #775 I think is the minimal change to get at least backups going via cnpg-i. I have that running in a cluster of mine. |
|
@itay-grudev Could we please get this merged and released? This would enable us to complete the migration to the Barman Cloud Plugin and would be really appreciated. |
|
I'll put it on my task list for next week. There are tests so it would make the job easier. |
|
Hi @itay-grudev when can we expect this PR to be merged? This is quite critical for us at the moment, as we’re currently unable to use the backup plugin. |
|
Greetings, cluster:
env:
- name: AWS_REQUEST_CHECKSUM_CALCULATION
value: when_required
- name: AWS_RESPONSE_CHECKSUM_VALIDATION
value: when_requiredIn the current chart with legacy barman object store, this can be achieved by setting them under apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
...
spec:
instanceSidecarConfiguration:
env:
- name: AWS_REQUEST_CHECKSUM_CALCULATION
value: when_required
- name: AWS_RESPONSE_CHECKSUM_VALIDATION
value: when_requiredThank you! |
ProbstDJakob
left a comment
There was a problem hiding this comment.
I've looked through the PR (except for the files not containing a comment) and have some suggestions with the most important being the way the ObjectStore CR receives its name. This has also pointed out by @eriksjolund but seems to have been somewhat lost in the review comments.
| {{- $hasPlugin := false }} | ||
| {{- if .Values.cluster.plugins }} | ||
| {{- range .Values.cluster.plugins }} | ||
| {{- if and (eq .name "barman-cloud.cloudnative-pg.io") .enabled }} |
There was a problem hiding this comment.
In the CRD enabled is set to true by default, thus this may be changed to something like this:
| {{- if and (eq .name "barman-cloud.cloudnative-pg.io") .enabled }} | |
| {{- if and (eq .name "barman-cloud.cloudnative-pg.io") (ne .enabled false) }} |
Furthermore I guess this should also check if isWALArchiver is true (but I am not sure):
| {{- if and (eq .name "barman-cloud.cloudnative-pg.io") .enabled }} | |
| {{- if and (eq .name "barman-cloud.cloudnative-pg.io") (ne .enabled false) .isWALArchiver }} |
There was a problem hiding this comment.
Depending whether the first or no suggestion gets applied, the suggestion in #680 (comment) needs to get adapted (twice; in both nested template definitions).
| {{/* | ||
| Check if barman-cloud plugin exists and is enabled | ||
| */}} | ||
| {{- define "cluster.useBarmanCloudPlugin" -}} | ||
| {{- $hasPlugin := false }} | ||
| {{- if .Values.cluster.plugins }} | ||
| {{- range .Values.cluster.plugins }} | ||
| {{- if and (eq .name "barman-cloud.cloudnative-pg.io") .enabled }} | ||
| {{- $hasPlugin = true }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- $hasPlugin }} | ||
| {{- end }} |
There was a problem hiding this comment.
If the suggestion with the ObjectStore name will be accepted the following could be helpful:
| {{/* | |
| Check if barman-cloud plugin exists and is enabled | |
| */}} | |
| {{- define "cluster.useBarmanCloudPlugin" -}} | |
| {{- $hasPlugin := false }} | |
| {{- if .Values.cluster.plugins }} | |
| {{- range .Values.cluster.plugins }} | |
| {{- if and (eq .name "barman-cloud.cloudnative-pg.io") .enabled }} | |
| {{- $hasPlugin = true }} | |
| {{- end }} | |
| {{- end }} | |
| {{- end }} | |
| {{- $hasPlugin }} | |
| {{- end }} | |
| {{/* | |
| Patch the plugins list to contain auto generated information and return it formatted as JSON | |
| */}} | |
| {{- define "cluster.patchPlugins" -}} | |
| {{- $plugins := list }} | |
| {{- range default list (deepCopy .Values.cluster.plugins) }} | |
| {{- if and (eq .name "barman-cloud.cloudnative-pg.io") (ne .enabled false) .isWALArchiver }} | |
| {{- $_ := set . "parameters" (merge (default dict .parameters) (dict "barmanObjectName" (printf "%s-object-store" (include "cluster.fullname" .)))) }} | |
| {{- end }} | |
| {{- $plugins = append $plugins . }} | |
| {{- end }} | |
| {{- toJson $plugins }} | |
| {{- end }} | |
| {{/* | |
| Check if barman-cloud plugin exists, is enabled, is WAL archiver, and return the plugin parameters (or null) formatted as JSON | |
| */}} | |
| {{- define "cluster.findBarmanCloudPlugin" -}} | |
| {{- range include "cluster.patchPlugins" . | fromJsonArray }} | |
| {{- if and (eq .name "barman-cloud.cloudnative-pg.io") (ne .enabled false) .isWALArchiver }} | |
| {{- toJson .parameters }} | |
| {{- break }} | |
| {{- end }} | |
| {{- end }} | |
| {{- end }} |
Usage would then be as follows:
{{ if include "cluster.findBarmanCloudPlugin" . | fromJson }}or:
{{ include "cluster.findBarmanCloudPlugin" . | fromJson | .barmanObjectName | quote }}| {{- with .Values.cluster.plugins }} | ||
| plugins: | ||
| {{- toYaml . | nindent 4}} | ||
| {{- end }} |
There was a problem hiding this comment.
If the suggestion with the ObjectStore name and the corresponding change within the _helpers.tpl will be accepted this must be changed to:
| {{- with .Values.cluster.plugins }} | |
| plugins: | |
| {{- toYaml . | nindent 4}} | |
| {{- end }} | |
| plugins: {{ include "cluster.patchPlugins" . }} |
| apiVersion: barmancloud.cnpg.io/v1 | ||
| kind: ObjectStore | ||
| metadata: | ||
| name: {{ include "cluster.fullname" $ }}-object-store |
There was a problem hiding this comment.
The name is currently "hardcoded" but must also be specified within the plugin declaration. This creates the problem, that the user must know/predict the name to be used and if that ever changes (either by changing what cluster.fullname renders, the suffix/prefix, the "full" name), one must adapt their values even though they should not need to. Within the _helpers.tpl and cluster.yaml are suggestions which would fix this and set a default barmanObjectName plugin parameter if non is given. If this change is accepted, the name should be change to:
| name: {{ include "cluster.fullname" $ }}-object-store | |
| name: {{ include "cluster.findBarmanCloudPlugin" . | fromJson | .barmanObjectName | quote }} |
Possibly save the output of include "cluster.findBarmanCloudPlugin" . | fromJson in a variable so that it must not be computed twice (for the name and the if in line one).
| {{- if (eq (include "cluster.useBarmanCloudPlugin" $context ) "true") }} | ||
| pluginConfiguration: | ||
| name: barman-cloud.cloudnative-pg.io | ||
| method: plugin | ||
| {{ else }} | ||
| method: {{ .method }} | ||
| {{- end }} |
There was a problem hiding this comment.
I am not sure if this should be "hardcoded" in case the barman cloud plugin is enabled. In case it is possible to still use volumeSnapshot as method even though the barman cloud plugin is enabled (I do not know if this is possible) the following may be better:
| {{- if (eq (include "cluster.useBarmanCloudPlugin" $context ) "true") }} | |
| pluginConfiguration: | |
| name: barman-cloud.cloudnative-pg.io | |
| method: plugin | |
| {{ else }} | |
| method: {{ .method }} | |
| {{- end }} | |
| {{- $barmanCloudPluginParameters := include "cluster.findBarmanCloudPlugin" . | fromJson }} | |
| {{- if or (eq .method "plugin") (and (eq .method "") (or .pluginConfiguration $barmanCloudPluginParameters)) }} | |
| method: plugin | |
| {{- $pluginConfiguration := default dict (deepCopy .pluginConfiguration) }} | |
| {{- if $barmanCloudPluginParameters }} | |
| {{- $_ := set $pluginConfiguration "name" (default "barman-cloud.cloudnative-pg.io" $pluginConfiguration.name) }} | |
| {{- end }} | |
| pluginConfiguration: {{ toJson $pluginConfiguration }} | |
| {{ else }} | |
| method: {{ default "barmanObjectStore" .method | quote }} | |
| {{- end }} |
| }, | ||
| "method": { | ||
| "type": "string" | ||
| }, |
There was a problem hiding this comment.
In case the suggestion within the scheduled-backups.yaml will be accepted, the following property should be added:
| }, | |
| "pluginConfiguration": { | |
| "type": "object", | |
| "properties": { | |
| "name": { | |
| "type": "string" | |
| }, | |
| "parameters": { | |
| "type": "object" | |
| "additionalProperties": { | |
| "type": "string" | |
| } | |
| } | |
| } | |
| }, |
| # -- Backup owner reference | ||
| backupOwnerReference: self | ||
| # -- Backup method, can be `barmanObjectStore` (default) or `volumeSnapshot` | ||
| method: barmanObjectStore |
There was a problem hiding this comment.
In case the suggestion within the scheduled-backups.yaml will be accepted, this should be changed to the following:
| method: "" | |
| pluginConfiguration: | |
| name: "" | |
| parameters: {} |
| | backups.s3.region | string | `""` | | | ||
| | backups.s3.secretKey | string | `""` | | | ||
| | backups.scheduledBackups[0].backupOwnerReference | string | `"self"` | Backup owner reference | | ||
| | backups.scheduledBackups[0].method | string | `"barmanObjectStore"` | Backup method, can be `barmanObjectStore` (default) or `volumeSnapshot` | |
There was a problem hiding this comment.
In case the suggestion within the scheduled-backups.yaml will be accepted, this should be changed to the following (possibly also sort the table entries):
| | backups.scheduledBackups[0].method | string | `"plugin"` if `backups.scheduledBackups[0].pluginConfiguration.name` is not empty or the barman cloud plugin is added to `cluster.plugins`, otherwise ``"barmanObjectStore"` | Backup method, can be `barmanObjectStore` (conditional default), `plugin` (conditional default) or `volumeSnapshot` | | |
| | backups.scheduledBackups[0].pluginConfiguration.name | string | `"barman-cloud.cloudnative-pg.io"` if the barman cloud plugin is added to `cluster.plugins` and `backups.scheduledBackups[0].method` defaults to/equals `"plugin"` | The name of the plugin to use for the backup schedule | | |
| | backups.scheduledBackups[0].pluginConfiguration.parameters | object | `{}` | Parameters to pass to the plugin | |
Allow to add plugins to the Cluster definition fixes #634
Prepare migration to the new Barman Cloud Plugin including the ObjectStore.