From 29c534f5c22e6491e5859b6b9a61ff97c1750ff4 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 12 Nov 2026 20:04:40 +0100 Subject: [PATCH 01/13] Update CRDs Signed-off-by: Michael Rittmeister --- .../crd/bases/documentdb.io_backups.yaml | 26 +++++++++++++++ .../config/crd/bases/documentdb.io_dbs.yaml | 32 +++++++++++++++++++ .../bases/documentdb.io_scheduledbackups.yaml | 26 +++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/operator/src/config/crd/bases/documentdb.io_backups.yaml b/operator/src/config/crd/bases/documentdb.io_backups.yaml index 7b3517644..94b3eaa2f 100644 --- a/operator/src/config/crd/bases/documentdb.io_backups.yaml +++ b/operator/src/config/crd/bases/documentdb.io_backups.yaml @@ -196,6 +196,32 @@ spec: required: - name type: object + method: + default: volumeSnapshot + description: |- + The backup method to be used, possible options are + `volumeSnapshot` or `plugin`. Defaults to: `volumeSnapshot`. + enum: + - volumeSnapshot + - plugin + type: string + pluginConfiguration: + description: Configuration parameters passed to the plugin managing + this backup + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name + type: object retentionDays: description: |- RetentionDays specifies how many days the backup should be retained. diff --git a/operator/src/config/crd/bases/documentdb.io_dbs.yaml b/operator/src/config/crd/bases/documentdb.io_dbs.yaml index 6c611e6f9..afcbb6a04 100644 --- a/operator/src/config/crd/bases/documentdb.io_dbs.yaml +++ b/operator/src/config/crd/bases/documentdb.io_dbs.yaml @@ -1311,6 +1311,38 @@ spec: maximum: 1 minimum: 1 type: integer + additionalCNPGPlugins: + description: |- + The plugins configuration, containing + any additional plugin to be loaded at the underlying CNPG cluster + with the corresponding configuration + items: + description: |- + PluginConfiguration specifies a plugin that need to be loaded for this + cluster to be reconciled + properties: + enabled: + default: true + description: Enabled is true if this plugin will be used + type: boolean + isWALArchiver: + default: false + description: |- + Marks the plugin as the WAL archiver. At most one plugin can be + designated as a WAL archiver. + type: boolean + name: + description: Name is the plugin name + type: string + parameters: + additionalProperties: + type: string + description: Parameters is the configuration of the plugin + type: object + required: + - name + type: object + type: array plugins: description: |- Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). diff --git a/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml b/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml index b1d63e946..8e9ef1295 100644 --- a/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml +++ b/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml @@ -63,6 +63,32 @@ spec: required: - name type: object + method: + default: volumeSnapshot + description: |- + The backup method to be used, possible options are + `volumeSnapshot` or `plugin`. Defaults to: `volumeSnapshot`. + enum: + - volumeSnapshot + - plugin + type: string + pluginConfiguration: + description: Configuration parameters passed to the plugin managing + this backup + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name + type: object retentionDays: description: |- RetentionDays specifies how many days the backups should be retained. From 59578a7e066ec326ca74b567cd88cde029bbd008 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 12 Nov 2026 20:45:39 +0100 Subject: [PATCH 02/13] Define CRD types via kubebuilder Signed-off-by: Michael Rittmeister --- .../crds/documentdb.io_backups.yaml | 30 +++++++ .../crds/documentdb.io_dbs.yaml | 48 +++++++++++ .../crds/documentdb.io_scheduledbackups.yaml | 30 +++++++ operator/src/api/preview/backup_types.go | 20 +++++ operator/src/api/preview/documentdb_types.go | 18 +++++ .../src/api/preview/scheduledbackup_types.go | 11 +++ operator/src/api/v1/backup_types.go | 20 +++++ operator/src/api/v1/documentdb_types.go | 18 +++++ operator/src/api/v1/scheduledbackup_types.go | 11 +++ .../crd/bases/documentdb.io_backups.yaml | 44 +++++----- .../config/crd/bases/documentdb.io_dbs.yaml | 80 +++++++++++-------- .../bases/documentdb.io_scheduledbackups.yaml | 44 +++++----- 12 files changed, 302 insertions(+), 72 deletions(-) diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml index 7b3517644..7ffcd2732 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml @@ -82,6 +82,20 @@ spec: required: - name type: object + method: + default: volumeSnapshot + description: |- + Method defines with method should be used to create a backup + can either be 'volumeSnapshot' or 'plugin' + defaults to 'volumeSnapshot' + type: string + pluginConfiguration: + additionalProperties: + type: string + description: |- + PluginConfiguration defines additional parameters passed to the plugin + only relevant if method=plugin + type: object retentionDays: description: |- RetentionDays specifies how many days the backup should be retained. @@ -89,6 +103,7 @@ spec: type: integer required: - cluster + - method type: object x-kubernetes-validations: - message: BackupSpec is immutable once set @@ -196,6 +211,20 @@ spec: required: - name type: object + method: + default: volumeSnapshot + description: |- + Method defines with method should be used to create a backup + can either be 'volumeSnapshot' or 'plugin' + defaults to 'volumeSnapshot' + type: string + pluginConfiguration: + additionalProperties: + type: string + description: |- + PluginConfiguration defines additional parameters passed to the plugin + only relevant if method=plugin + type: object retentionDays: description: |- RetentionDays specifies how many days the backup should be retained. @@ -203,6 +232,7 @@ spec: type: integer required: - cluster + - method type: object x-kubernetes-validations: - message: BackupSpec is immutable once set diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml index 6c611e6f9..55fbb4c87 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml @@ -54,6 +54,30 @@ spec: spec: description: DocumentDBSpec defines the desired state of DocumentDB. properties: + additionalCNPGPlugins: + description: AdditionalCNPGPlugins defines which additional CNPG plugins + should be loaded + items: + description: AdditionalPluginSpec defines how to install an additional + plugin. + properties: + enabled: + default: true + description: Enabled marks this plugin is enabled or not, + type: boolean + isWalArchiver: + default: false + description: |- + IsWalArchiver ,arks the plugin as a WAL archiver + at most one plugin can be designated as a WAL archiver. + type: boolean + parameters: + additionalProperties: + type: string + description: Parameters is the configuration of the plugin + type: object + type: object + type: array affinity: description: Affinity/Anti-affinity rules for Pods (cnpg passthrough) properties: @@ -1743,6 +1767,30 @@ spec: spec: description: DocumentDBSpec defines the desired state of DocumentDB. properties: + additionalCNPGPlugins: + description: AdditionalCNPGPlugins defines which additional CNPG plugins + should be loaded + items: + description: AdditionalPluginSpec defines how to install an additional + plugin. + properties: + enabled: + default: true + description: Enabled marks this plugin is enabled or not, + type: boolean + isWalArchiver: + default: false + description: |- + IsWalArchiver ,arks the plugin as a WAL archiver + at most one plugin can be designated as a WAL archiver. + type: boolean + parameters: + additionalProperties: + type: string + description: Parameters is the configuration of the plugin + type: object + type: object + type: array affinity: description: Affinity/Anti-affinity rules for Pods (cnpg passthrough) properties: diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml index b1d63e946..909b4b235 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml @@ -63,6 +63,20 @@ spec: required: - name type: object + method: + default: volumeSnapshot + description: |- + Method defines with method should be used to create a backup + can either be 'volumeSnapshot' or 'plugin' + defaults to 'volumeSnapshot' + type: string + pluginConfiguration: + additionalProperties: + type: string + description: |- + PluginConfiguration defines additional parameters passed to the plugin + only relevant if method=plugin + type: object retentionDays: description: |- RetentionDays specifies how many days the backups should be retained. @@ -75,6 +89,7 @@ spec: type: string required: - cluster + - method - schedule type: object status: @@ -144,6 +159,20 @@ spec: required: - name type: object + method: + default: volumeSnapshot + description: |- + Method defines with method should be used to create a backup + can either be 'volumeSnapshot' or 'plugin' + defaults to 'volumeSnapshot' + type: string + pluginConfiguration: + additionalProperties: + type: string + description: |- + PluginConfiguration defines additional parameters passed to the plugin + only relevant if method=plugin + type: object retentionDays: description: |- RetentionDays specifies how many days the backups should be retained. @@ -156,6 +185,7 @@ spec: type: string required: - cluster + - method - schedule type: object status: diff --git a/operator/src/api/preview/backup_types.go b/operator/src/api/preview/backup_types.go index 44928c4be..285216079 100644 --- a/operator/src/api/preview/backup_types.go +++ b/operator/src/api/preview/backup_types.go @@ -10,6 +10,15 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// BackupMethod defines how a backup should be created, can be 'volumeSnapshot' or 'plugin' +// +kubebuiilder:validation:Enum=volumeSnapshot;plugin +type BackupMethod cnpgv1.BackupMethod + +const ( + BackupMethodVolumeSnapshot = "volumeSnapshot" + BackupMethodPlugin = "plugin" +) + // BackupSpec defines the desired state of Backup. // +kubebuilder:validation:XValidation:rule="oldSelf == self",message="BackupSpec is immutable once set" type BackupSpec struct { @@ -18,6 +27,17 @@ type BackupSpec struct { // +kubebuilder:validation:Required Cluster cnpgv1.LocalObjectReference `json:"cluster"` + // Method defines with method should be used to create a backup + // can either be 'volumeSnapshot' or 'plugin' + // defaults to 'volumeSnapshot' + // +kubebuilder:default=volumeSnapshot + Method BackupMethod `json:"method"` + + // PluginConfiguration defines additional parameters passed to the plugin + // only relevant if method=plugin + // +optional + PluginConfiguration map[string]string `json:"pluginConfiguration,omitempty"` + // RetentionDays specifies how many days the backup should be retained. // If not specified, the default retention period from the cluster's backup retention policy will be used. // +optional diff --git a/operator/src/api/preview/documentdb_types.go b/operator/src/api/preview/documentdb_types.go index 75fef30e7..9806a4b53 100644 --- a/operator/src/api/preview/documentdb_types.go +++ b/operator/src/api/preview/documentdb_types.go @@ -73,6 +73,9 @@ type DocumentDBSpec struct { // +optional Postgres *PostgresSpec `json:"postgres,omitempty"` + // AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded + // +optional + AdditionalCNPGPlugins []AdditionalPluginSpec `json:"additionalCNPGPlugins,omitempty"` // Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). // All fields are optional; defaults are preserved when omitted. // +optional @@ -219,6 +222,21 @@ type PostgresSpec struct { Parameters map[string]string `json:"parameters,omitempty"` } +// AdditionalPluginSpec defines how to install an additional plugin. +type AdditionalPluginSpec struct { + // Enabled marks this plugin is enabled or not, + // +kubebuilder:default:=true + Enabled bool `json:"enabled,omitempty"` + // IsWalArchiver ,arks the plugin as a WAL archiver + // at most one plugin can be designated as a WAL archiver. + // +kubebuilder:default:=false + IsWalArchiver bool `json:"isWalArchiver,omitempty"` + + // Parameters is the configuration of the plugin + // +optional + Parameters map[string]string `json:"parameters,omitempty"` +} + // PluginsSpec groups CNPG plugin configuration. type PluginsSpec struct { // SidecarInjectorName is the name of the CNPG sidecar injector plugin diff --git a/operator/src/api/preview/scheduledbackup_types.go b/operator/src/api/preview/scheduledbackup_types.go index 792af043e..e5ec09a0f 100644 --- a/operator/src/api/preview/scheduledbackup_types.go +++ b/operator/src/api/preview/scheduledbackup_types.go @@ -17,6 +17,17 @@ type ScheduledBackupSpec struct { // +kubebuilder:validation:Required Cluster cnpgv1.LocalObjectReference `json:"cluster"` + // Method defines with method should be used to create a backup + // can either be 'volumeSnapshot' or 'plugin' + // defaults to 'volumeSnapshot' + // +kubebuilder:default=volumeSnapshot + Method BackupMethod `json:"method"` + + // PluginConfiguration defines additional parameters passed to the plugin + // only relevant if method=plugin + // +optional + PluginConfiguration map[string]string `json:"pluginConfiguration,omitempty"` + // Schedule defines when backups should be created using cron expression format. // See https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format // +kubebuilder:validation:Required diff --git a/operator/src/api/v1/backup_types.go b/operator/src/api/v1/backup_types.go index 65af0d05c..3d4025b0e 100644 --- a/operator/src/api/v1/backup_types.go +++ b/operator/src/api/v1/backup_types.go @@ -8,6 +8,15 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// BackupMethod defines how a backup should be created, can be 'volumeSnapshot' or 'plugin' +// +kubebuiilder:validation:Enum=volumeSnapshot;plugin +type BackupMethod cnpgv1.BackupMethod + +const ( + BackupMethodVolumeSnapshot = "volumeSnapshot" + BackupMethodPlugin = "plugin" +) + // BackupSpec defines the desired state of Backup. // +kubebuilder:validation:XValidation:rule="oldSelf == self",message="BackupSpec is immutable once set" type BackupSpec struct { @@ -16,6 +25,17 @@ type BackupSpec struct { // +kubebuilder:validation:Required Cluster cnpgv1.LocalObjectReference `json:"cluster"` + // Method defines with method should be used to create a backup + // can either be 'volumeSnapshot' or 'plugin' + // defaults to 'volumeSnapshot' + // +kubebuilder:default=volumeSnapshot + Method BackupMethod `json:"method"` + + // PluginConfiguration defines additional parameters passed to the plugin + // only relevant if method=plugin + // +optional + PluginConfiguration map[string]string `json:"pluginConfiguration,omitempty"` + // RetentionDays specifies how many days the backup should be retained. // If not specified, the default retention period from the cluster's backup retention policy will be used. // +optional diff --git a/operator/src/api/v1/documentdb_types.go b/operator/src/api/v1/documentdb_types.go index 40a3fbf78..eddde7b8c 100644 --- a/operator/src/api/v1/documentdb_types.go +++ b/operator/src/api/v1/documentdb_types.go @@ -71,6 +71,9 @@ type DocumentDBSpec struct { // +optional Postgres *PostgresSpec `json:"postgres,omitempty"` + // AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded + // +optional + AdditionalCNPGPlugins []AdditionalPluginSpec `json:"additionalCNPGPlugins,omitempty"` // Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). // All fields are optional; defaults are preserved when omitted. // +optional @@ -217,6 +220,21 @@ type PostgresSpec struct { Parameters map[string]string `json:"parameters,omitempty"` } +// AdditionalPluginSpec defines how to install an additional plugin. +type AdditionalPluginSpec struct { + // Enabled marks this plugin is enabled or not, + // +kubebuilder:default:=true + Enabled bool `json:"enabled,omitempty"` + // IsWalArchiver ,arks the plugin as a WAL archiver + // at most one plugin can be designated as a WAL archiver. + // +kubebuilder:default:=false + IsWalArchiver bool `json:"isWalArchiver,omitempty"` + + // Parameters is the configuration of the plugin + // +optional + Parameters map[string]string `json:"parameters,omitempty"` +} + // PluginsSpec groups CNPG plugin configuration. type PluginsSpec struct { // SidecarInjectorName is the name of the CNPG sidecar injector plugin diff --git a/operator/src/api/v1/scheduledbackup_types.go b/operator/src/api/v1/scheduledbackup_types.go index 059276b28..7513f70a0 100644 --- a/operator/src/api/v1/scheduledbackup_types.go +++ b/operator/src/api/v1/scheduledbackup_types.go @@ -15,6 +15,17 @@ type ScheduledBackupSpec struct { // +kubebuilder:validation:Required Cluster cnpgv1.LocalObjectReference `json:"cluster"` + // Method defines with method should be used to create a backup + // can either be 'volumeSnapshot' or 'plugin' + // defaults to 'volumeSnapshot' + // +kubebuilder:default=volumeSnapshot + Method BackupMethod `json:"method"` + + // PluginConfiguration defines additional parameters passed to the plugin + // only relevant if method=plugin + // +optional + PluginConfiguration map[string]string `json:"pluginConfiguration,omitempty"` + // Schedule defines when backups should be created using cron expression format. // See https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format // +kubebuilder:validation:Required diff --git a/operator/src/config/crd/bases/documentdb.io_backups.yaml b/operator/src/config/crd/bases/documentdb.io_backups.yaml index 94b3eaa2f..7ffcd2732 100644 --- a/operator/src/config/crd/bases/documentdb.io_backups.yaml +++ b/operator/src/config/crd/bases/documentdb.io_backups.yaml @@ -82,6 +82,20 @@ spec: required: - name type: object + method: + default: volumeSnapshot + description: |- + Method defines with method should be used to create a backup + can either be 'volumeSnapshot' or 'plugin' + defaults to 'volumeSnapshot' + type: string + pluginConfiguration: + additionalProperties: + type: string + description: |- + PluginConfiguration defines additional parameters passed to the plugin + only relevant if method=plugin + type: object retentionDays: description: |- RetentionDays specifies how many days the backup should be retained. @@ -89,6 +103,7 @@ spec: type: integer required: - cluster + - method type: object x-kubernetes-validations: - message: BackupSpec is immutable once set @@ -199,28 +214,16 @@ spec: method: default: volumeSnapshot description: |- - The backup method to be used, possible options are - `volumeSnapshot` or `plugin`. Defaults to: `volumeSnapshot`. - enum: - - volumeSnapshot - - plugin + Method defines with method should be used to create a backup + can either be 'volumeSnapshot' or 'plugin' + defaults to 'volumeSnapshot' type: string pluginConfiguration: - description: Configuration parameters passed to the plugin managing - this backup - properties: - name: - description: Name is the name of the plugin managing this backup - type: string - parameters: - additionalProperties: - type: string - description: |- - Parameters are the configuration parameters passed to the backup - plugin for this backup - type: object - required: - - name + additionalProperties: + type: string + description: |- + PluginConfiguration defines additional parameters passed to the plugin + only relevant if method=plugin type: object retentionDays: description: |- @@ -229,6 +232,7 @@ spec: type: integer required: - cluster + - method type: object x-kubernetes-validations: - message: BackupSpec is immutable once set diff --git a/operator/src/config/crd/bases/documentdb.io_dbs.yaml b/operator/src/config/crd/bases/documentdb.io_dbs.yaml index afcbb6a04..55fbb4c87 100644 --- a/operator/src/config/crd/bases/documentdb.io_dbs.yaml +++ b/operator/src/config/crd/bases/documentdb.io_dbs.yaml @@ -54,6 +54,30 @@ spec: spec: description: DocumentDBSpec defines the desired state of DocumentDB. properties: + additionalCNPGPlugins: + description: AdditionalCNPGPlugins defines which additional CNPG plugins + should be loaded + items: + description: AdditionalPluginSpec defines how to install an additional + plugin. + properties: + enabled: + default: true + description: Enabled marks this plugin is enabled or not, + type: boolean + isWalArchiver: + default: false + description: |- + IsWalArchiver ,arks the plugin as a WAL archiver + at most one plugin can be designated as a WAL archiver. + type: boolean + parameters: + additionalProperties: + type: string + description: Parameters is the configuration of the plugin + type: object + type: object + type: array affinity: description: Affinity/Anti-affinity rules for Pods (cnpg passthrough) properties: @@ -1311,38 +1335,6 @@ spec: maximum: 1 minimum: 1 type: integer - additionalCNPGPlugins: - description: |- - The plugins configuration, containing - any additional plugin to be loaded at the underlying CNPG cluster - with the corresponding configuration - items: - description: |- - PluginConfiguration specifies a plugin that need to be loaded for this - cluster to be reconciled - properties: - enabled: - default: true - description: Enabled is true if this plugin will be used - type: boolean - isWALArchiver: - default: false - description: |- - Marks the plugin as the WAL archiver. At most one plugin can be - designated as a WAL archiver. - type: boolean - name: - description: Name is the plugin name - type: string - parameters: - additionalProperties: - type: string - description: Parameters is the configuration of the plugin - type: object - required: - - name - type: object - type: array plugins: description: |- Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). @@ -1775,6 +1767,30 @@ spec: spec: description: DocumentDBSpec defines the desired state of DocumentDB. properties: + additionalCNPGPlugins: + description: AdditionalCNPGPlugins defines which additional CNPG plugins + should be loaded + items: + description: AdditionalPluginSpec defines how to install an additional + plugin. + properties: + enabled: + default: true + description: Enabled marks this plugin is enabled or not, + type: boolean + isWalArchiver: + default: false + description: |- + IsWalArchiver ,arks the plugin as a WAL archiver + at most one plugin can be designated as a WAL archiver. + type: boolean + parameters: + additionalProperties: + type: string + description: Parameters is the configuration of the plugin + type: object + type: object + type: array affinity: description: Affinity/Anti-affinity rules for Pods (cnpg passthrough) properties: diff --git a/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml b/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml index 8e9ef1295..909b4b235 100644 --- a/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml +++ b/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml @@ -66,28 +66,16 @@ spec: method: default: volumeSnapshot description: |- - The backup method to be used, possible options are - `volumeSnapshot` or `plugin`. Defaults to: `volumeSnapshot`. - enum: - - volumeSnapshot - - plugin + Method defines with method should be used to create a backup + can either be 'volumeSnapshot' or 'plugin' + defaults to 'volumeSnapshot' type: string pluginConfiguration: - description: Configuration parameters passed to the plugin managing - this backup - properties: - name: - description: Name is the name of the plugin managing this backup - type: string - parameters: - additionalProperties: - type: string - description: |- - Parameters are the configuration parameters passed to the backup - plugin for this backup - type: object - required: - - name + additionalProperties: + type: string + description: |- + PluginConfiguration defines additional parameters passed to the plugin + only relevant if method=plugin type: object retentionDays: description: |- @@ -101,6 +89,7 @@ spec: type: string required: - cluster + - method - schedule type: object status: @@ -170,6 +159,20 @@ spec: required: - name type: object + method: + default: volumeSnapshot + description: |- + Method defines with method should be used to create a backup + can either be 'volumeSnapshot' or 'plugin' + defaults to 'volumeSnapshot' + type: string + pluginConfiguration: + additionalProperties: + type: string + description: |- + PluginConfiguration defines additional parameters passed to the plugin + only relevant if method=plugin + type: object retentionDays: description: |- RetentionDays specifies how many days the backups should be retained. @@ -182,6 +185,7 @@ spec: type: string required: - cluster + - method - schedule type: object status: From 4725b3454ec3d13e70d2d8fc316cbde4bc76c565 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 12 Nov 2026 20:57:01 +0100 Subject: [PATCH 03/13] Use cnpg plugin types Signed-off-by: Michael Rittmeister --- .../crds/documentdb.io_dbs.yaml | 38 +++++++++++++------ operator/src/api/preview/documentdb_types.go | 17 +-------- operator/src/api/v1/documentdb_types.go | 17 +-------- .../config/crd/bases/documentdb.io_dbs.yaml | 38 +++++++++++++------ 4 files changed, 54 insertions(+), 56 deletions(-) diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml index 55fbb4c87..e19192fa8 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml @@ -58,24 +58,31 @@ spec: description: AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded items: - description: AdditionalPluginSpec defines how to install an additional - plugin. + description: |- + PluginConfiguration specifies a plugin that need to be loaded for this + cluster to be reconciled properties: enabled: default: true - description: Enabled marks this plugin is enabled or not, + description: Enabled is true if this plugin will be used type: boolean - isWalArchiver: + isWALArchiver: default: false description: |- - IsWalArchiver ,arks the plugin as a WAL archiver - at most one plugin can be designated as a WAL archiver. + Marks the plugin as the WAL archiver. At most one plugin can be + designated as a WAL archiver. This cannot be enabled if the + `.spec.backup.barmanObjectStore` configuration is present. type: boolean + name: + description: Name is the plugin name + type: string parameters: additionalProperties: type: string description: Parameters is the configuration of the plugin type: object + required: + - name type: object type: array affinity: @@ -1771,24 +1778,31 @@ spec: description: AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded items: - description: AdditionalPluginSpec defines how to install an additional - plugin. + description: |- + PluginConfiguration specifies a plugin that need to be loaded for this + cluster to be reconciled properties: enabled: default: true - description: Enabled marks this plugin is enabled or not, + description: Enabled is true if this plugin will be used type: boolean - isWalArchiver: + isWALArchiver: default: false description: |- - IsWalArchiver ,arks the plugin as a WAL archiver - at most one plugin can be designated as a WAL archiver. + Marks the plugin as the WAL archiver. At most one plugin can be + designated as a WAL archiver. This cannot be enabled if the + `.spec.backup.barmanObjectStore` configuration is present. type: boolean + name: + description: Name is the plugin name + type: string parameters: additionalProperties: type: string description: Parameters is the configuration of the plugin type: object + required: + - name type: object type: array affinity: diff --git a/operator/src/api/preview/documentdb_types.go b/operator/src/api/preview/documentdb_types.go index 9806a4b53..8b3da277b 100644 --- a/operator/src/api/preview/documentdb_types.go +++ b/operator/src/api/preview/documentdb_types.go @@ -75,7 +75,7 @@ type DocumentDBSpec struct { // AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded // +optional - AdditionalCNPGPlugins []AdditionalPluginSpec `json:"additionalCNPGPlugins,omitempty"` + AdditionalCNPGPlugins []cnpgv1.PluginConfiguration `json:"additionalCNPGPlugins,omitempty"` // Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). // All fields are optional; defaults are preserved when omitted. // +optional @@ -222,21 +222,6 @@ type PostgresSpec struct { Parameters map[string]string `json:"parameters,omitempty"` } -// AdditionalPluginSpec defines how to install an additional plugin. -type AdditionalPluginSpec struct { - // Enabled marks this plugin is enabled or not, - // +kubebuilder:default:=true - Enabled bool `json:"enabled,omitempty"` - // IsWalArchiver ,arks the plugin as a WAL archiver - // at most one plugin can be designated as a WAL archiver. - // +kubebuilder:default:=false - IsWalArchiver bool `json:"isWalArchiver,omitempty"` - - // Parameters is the configuration of the plugin - // +optional - Parameters map[string]string `json:"parameters,omitempty"` -} - // PluginsSpec groups CNPG plugin configuration. type PluginsSpec struct { // SidecarInjectorName is the name of the CNPG sidecar injector plugin diff --git a/operator/src/api/v1/documentdb_types.go b/operator/src/api/v1/documentdb_types.go index eddde7b8c..f869772f5 100644 --- a/operator/src/api/v1/documentdb_types.go +++ b/operator/src/api/v1/documentdb_types.go @@ -73,7 +73,7 @@ type DocumentDBSpec struct { // AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded // +optional - AdditionalCNPGPlugins []AdditionalPluginSpec `json:"additionalCNPGPlugins,omitempty"` + AdditionalCNPGPlugins []cnpgv1.PluginConfiguration `json:"additionalCNPGPlugins,omitempty"` // Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). // All fields are optional; defaults are preserved when omitted. // +optional @@ -220,21 +220,6 @@ type PostgresSpec struct { Parameters map[string]string `json:"parameters,omitempty"` } -// AdditionalPluginSpec defines how to install an additional plugin. -type AdditionalPluginSpec struct { - // Enabled marks this plugin is enabled or not, - // +kubebuilder:default:=true - Enabled bool `json:"enabled,omitempty"` - // IsWalArchiver ,arks the plugin as a WAL archiver - // at most one plugin can be designated as a WAL archiver. - // +kubebuilder:default:=false - IsWalArchiver bool `json:"isWalArchiver,omitempty"` - - // Parameters is the configuration of the plugin - // +optional - Parameters map[string]string `json:"parameters,omitempty"` -} - // PluginsSpec groups CNPG plugin configuration. type PluginsSpec struct { // SidecarInjectorName is the name of the CNPG sidecar injector plugin diff --git a/operator/src/config/crd/bases/documentdb.io_dbs.yaml b/operator/src/config/crd/bases/documentdb.io_dbs.yaml index 55fbb4c87..e19192fa8 100644 --- a/operator/src/config/crd/bases/documentdb.io_dbs.yaml +++ b/operator/src/config/crd/bases/documentdb.io_dbs.yaml @@ -58,24 +58,31 @@ spec: description: AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded items: - description: AdditionalPluginSpec defines how to install an additional - plugin. + description: |- + PluginConfiguration specifies a plugin that need to be loaded for this + cluster to be reconciled properties: enabled: default: true - description: Enabled marks this plugin is enabled or not, + description: Enabled is true if this plugin will be used type: boolean - isWalArchiver: + isWALArchiver: default: false description: |- - IsWalArchiver ,arks the plugin as a WAL archiver - at most one plugin can be designated as a WAL archiver. + Marks the plugin as the WAL archiver. At most one plugin can be + designated as a WAL archiver. This cannot be enabled if the + `.spec.backup.barmanObjectStore` configuration is present. type: boolean + name: + description: Name is the plugin name + type: string parameters: additionalProperties: type: string description: Parameters is the configuration of the plugin type: object + required: + - name type: object type: array affinity: @@ -1771,24 +1778,31 @@ spec: description: AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded items: - description: AdditionalPluginSpec defines how to install an additional - plugin. + description: |- + PluginConfiguration specifies a plugin that need to be loaded for this + cluster to be reconciled properties: enabled: default: true - description: Enabled marks this plugin is enabled or not, + description: Enabled is true if this plugin will be used type: boolean - isWalArchiver: + isWALArchiver: default: false description: |- - IsWalArchiver ,arks the plugin as a WAL archiver - at most one plugin can be designated as a WAL archiver. + Marks the plugin as the WAL archiver. At most one plugin can be + designated as a WAL archiver. This cannot be enabled if the + `.spec.backup.barmanObjectStore` configuration is present. type: boolean + name: + description: Name is the plugin name + type: string parameters: additionalProperties: type: string description: Parameters is the configuration of the plugin type: object + required: + - name type: object type: array affinity: From a414dda18ec360cc6ae979a29b26cc7c8d0bdd61 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 12 Nov 2026 21:12:21 +0100 Subject: [PATCH 04/13] Fix typo in kubebuilder marker Signed-off-by: Michael Rittmeister --- .../documentdb-helm-chart/crds/documentdb.io_backups.yaml | 6 ++++++ .../crds/documentdb.io_scheduledbackups.yaml | 6 ++++++ operator/src/api/preview/backup_types.go | 2 +- operator/src/api/v1/backup_types.go | 2 +- operator/src/config/crd/bases/documentdb.io_backups.yaml | 6 ++++++ .../config/crd/bases/documentdb.io_scheduledbackups.yaml | 6 ++++++ 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml index 7ffcd2732..0b21678f0 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml @@ -88,6 +88,9 @@ spec: Method defines with method should be used to create a backup can either be 'volumeSnapshot' or 'plugin' defaults to 'volumeSnapshot' + enum: + - volumeSnapshot + - plugin type: string pluginConfiguration: additionalProperties: @@ -217,6 +220,9 @@ spec: Method defines with method should be used to create a backup can either be 'volumeSnapshot' or 'plugin' defaults to 'volumeSnapshot' + enum: + - volumeSnapshot + - plugin type: string pluginConfiguration: additionalProperties: diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml index 909b4b235..727e65118 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml @@ -69,6 +69,9 @@ spec: Method defines with method should be used to create a backup can either be 'volumeSnapshot' or 'plugin' defaults to 'volumeSnapshot' + enum: + - volumeSnapshot + - plugin type: string pluginConfiguration: additionalProperties: @@ -165,6 +168,9 @@ spec: Method defines with method should be used to create a backup can either be 'volumeSnapshot' or 'plugin' defaults to 'volumeSnapshot' + enum: + - volumeSnapshot + - plugin type: string pluginConfiguration: additionalProperties: diff --git a/operator/src/api/preview/backup_types.go b/operator/src/api/preview/backup_types.go index 285216079..6c020a2f4 100644 --- a/operator/src/api/preview/backup_types.go +++ b/operator/src/api/preview/backup_types.go @@ -11,7 +11,7 @@ import ( ) // BackupMethod defines how a backup should be created, can be 'volumeSnapshot' or 'plugin' -// +kubebuiilder:validation:Enum=volumeSnapshot;plugin +// +kubebuilder:validation:Enum=volumeSnapshot;plugin type BackupMethod cnpgv1.BackupMethod const ( diff --git a/operator/src/api/v1/backup_types.go b/operator/src/api/v1/backup_types.go index 3d4025b0e..6d5414b07 100644 --- a/operator/src/api/v1/backup_types.go +++ b/operator/src/api/v1/backup_types.go @@ -9,7 +9,7 @@ import ( ) // BackupMethod defines how a backup should be created, can be 'volumeSnapshot' or 'plugin' -// +kubebuiilder:validation:Enum=volumeSnapshot;plugin +// +kubebuilder:validation:Enum=volumeSnapshot;plugin type BackupMethod cnpgv1.BackupMethod const ( diff --git a/operator/src/config/crd/bases/documentdb.io_backups.yaml b/operator/src/config/crd/bases/documentdb.io_backups.yaml index 7ffcd2732..0b21678f0 100644 --- a/operator/src/config/crd/bases/documentdb.io_backups.yaml +++ b/operator/src/config/crd/bases/documentdb.io_backups.yaml @@ -88,6 +88,9 @@ spec: Method defines with method should be used to create a backup can either be 'volumeSnapshot' or 'plugin' defaults to 'volumeSnapshot' + enum: + - volumeSnapshot + - plugin type: string pluginConfiguration: additionalProperties: @@ -217,6 +220,9 @@ spec: Method defines with method should be used to create a backup can either be 'volumeSnapshot' or 'plugin' defaults to 'volumeSnapshot' + enum: + - volumeSnapshot + - plugin type: string pluginConfiguration: additionalProperties: diff --git a/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml b/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml index 909b4b235..727e65118 100644 --- a/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml +++ b/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml @@ -69,6 +69,9 @@ spec: Method defines with method should be used to create a backup can either be 'volumeSnapshot' or 'plugin' defaults to 'volumeSnapshot' + enum: + - volumeSnapshot + - plugin type: string pluginConfiguration: additionalProperties: @@ -165,6 +168,9 @@ spec: Method defines with method should be used to create a backup can either be 'volumeSnapshot' or 'plugin' defaults to 'volumeSnapshot' + enum: + - volumeSnapshot + - plugin type: string pluginConfiguration: additionalProperties: From b050075d241991a8b56a5463d0595c5ff5c778a0 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 12 Nov 2026 21:13:02 +0100 Subject: [PATCH 05/13] Update deepcopys Signed-off-by: Michael Rittmeister --- .../src/api/preview/zz_generated.deepcopy.go | 21 +++++++++++++++++++ operator/src/api/v1/zz_generated.deepcopy.go | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/operator/src/api/preview/zz_generated.deepcopy.go b/operator/src/api/preview/zz_generated.deepcopy.go index fa01423c8..0cb0772d5 100644 --- a/operator/src/api/preview/zz_generated.deepcopy.go +++ b/operator/src/api/preview/zz_generated.deepcopy.go @@ -91,6 +91,13 @@ func (in *BackupList) DeepCopyObject() runtime.Object { func (in *BackupSpec) DeepCopyInto(out *BackupSpec) { *out = *in in.Cluster.DeepCopyInto(&out.Cluster) + if in.PluginConfiguration != nil { + in, out := &in.PluginConfiguration, &out.PluginConfiguration + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.RetentionDays != nil { in, out := &in.RetentionDays, &out.RetentionDays *out = new(int) @@ -294,6 +301,13 @@ func (in *DocumentDBSpec) DeepCopyInto(out *DocumentDBSpec) { *out = new(PostgresSpec) (*in).DeepCopyInto(*out) } + if in.AdditionalCNPGPlugins != nil { + in, out := &in.AdditionalCNPGPlugins, &out.AdditionalCNPGPlugins + *out = make([]apiv1.PluginConfiguration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.Plugins != nil { in, out := &in.Plugins, &out.Plugins *out = new(PluginsSpec) @@ -733,6 +747,13 @@ func (in *ScheduledBackupList) DeepCopyObject() runtime.Object { func (in *ScheduledBackupSpec) DeepCopyInto(out *ScheduledBackupSpec) { *out = *in in.Cluster.DeepCopyInto(&out.Cluster) + if in.PluginConfiguration != nil { + in, out := &in.PluginConfiguration, &out.PluginConfiguration + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.RetentionDays != nil { in, out := &in.RetentionDays, &out.RetentionDays *out = new(int) diff --git a/operator/src/api/v1/zz_generated.deepcopy.go b/operator/src/api/v1/zz_generated.deepcopy.go index de5c1b8e0..53db5f794 100644 --- a/operator/src/api/v1/zz_generated.deepcopy.go +++ b/operator/src/api/v1/zz_generated.deepcopy.go @@ -91,6 +91,13 @@ func (in *BackupList) DeepCopyObject() runtime.Object { func (in *BackupSpec) DeepCopyInto(out *BackupSpec) { *out = *in in.Cluster.DeepCopyInto(&out.Cluster) + if in.PluginConfiguration != nil { + in, out := &in.PluginConfiguration, &out.PluginConfiguration + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.RetentionDays != nil { in, out := &in.RetentionDays, &out.RetentionDays *out = new(int) @@ -294,6 +301,13 @@ func (in *DocumentDBSpec) DeepCopyInto(out *DocumentDBSpec) { *out = new(PostgresSpec) (*in).DeepCopyInto(*out) } + if in.AdditionalCNPGPlugins != nil { + in, out := &in.AdditionalCNPGPlugins, &out.AdditionalCNPGPlugins + *out = make([]apiv1.PluginConfiguration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.Plugins != nil { in, out := &in.Plugins, &out.Plugins *out = new(PluginsSpec) @@ -733,6 +747,13 @@ func (in *ScheduledBackupList) DeepCopyObject() runtime.Object { func (in *ScheduledBackupSpec) DeepCopyInto(out *ScheduledBackupSpec) { *out = *in in.Cluster.DeepCopyInto(&out.Cluster) + if in.PluginConfiguration != nil { + in, out := &in.PluginConfiguration, &out.PluginConfiguration + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.RetentionDays != nil { in, out := &in.RetentionDays, &out.RetentionDays *out = new(int) From 37dead9ae504ba7b8ca7e9f7de07d7f4bfb300d0 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 12 Nov 2026 21:27:41 +0100 Subject: [PATCH 06/13] Omit backup method if empty Signed-off-by: Michael Rittmeister --- operator/src/api/v1/backup_types.go | 2 +- operator/src/api/v1/scheduledbackup_types.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/operator/src/api/v1/backup_types.go b/operator/src/api/v1/backup_types.go index 6d5414b07..f30cd674d 100644 --- a/operator/src/api/v1/backup_types.go +++ b/operator/src/api/v1/backup_types.go @@ -29,7 +29,7 @@ type BackupSpec struct { // can either be 'volumeSnapshot' or 'plugin' // defaults to 'volumeSnapshot' // +kubebuilder:default=volumeSnapshot - Method BackupMethod `json:"method"` + Method BackupMethod `json:"method,omitempty"` // PluginConfiguration defines additional parameters passed to the plugin // only relevant if method=plugin diff --git a/operator/src/api/v1/scheduledbackup_types.go b/operator/src/api/v1/scheduledbackup_types.go index 7513f70a0..fb5359bc9 100644 --- a/operator/src/api/v1/scheduledbackup_types.go +++ b/operator/src/api/v1/scheduledbackup_types.go @@ -19,7 +19,7 @@ type ScheduledBackupSpec struct { // can either be 'volumeSnapshot' or 'plugin' // defaults to 'volumeSnapshot' // +kubebuilder:default=volumeSnapshot - Method BackupMethod `json:"method"` + Method BackupMethod `json:"method,omitempty"` // PluginConfiguration defines additional parameters passed to the plugin // only relevant if method=plugin From 673169ecbda1c6918383d1316ddb1f4c8175eade Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 16 Nov 2026 20:28:46 +0100 Subject: [PATCH 07/13] move `additionalCNPGPlugins` to `plugins.additional` Signed-off-by: Michael Rittmeister --- operator/src/api/v1/documentdb_types.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/operator/src/api/v1/documentdb_types.go b/operator/src/api/v1/documentdb_types.go index f869772f5..a34e9a932 100644 --- a/operator/src/api/v1/documentdb_types.go +++ b/operator/src/api/v1/documentdb_types.go @@ -71,9 +71,6 @@ type DocumentDBSpec struct { // +optional Postgres *PostgresSpec `json:"postgres,omitempty"` - // AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded - // +optional - AdditionalCNPGPlugins []cnpgv1.PluginConfiguration `json:"additionalCNPGPlugins,omitempty"` // Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). // All fields are optional; defaults are preserved when omitted. // +optional @@ -232,6 +229,10 @@ type PluginsSpec struct { // cross-cluster replication. // +optional WalReplicaName string `json:"walReplicaName,omitempty"` + + // Additional defines which additional CNPG plugins should be loaded + // +optional + Additional []cnpgv1.PluginConfiguration `json:"additional,omitempty"` } // BootstrapConfiguration defines how to bootstrap a DocumentDB cluster. From ef00f0f1021f6797aa6480ce3f73d3614bf042e0 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 16 Nov 2026 20:31:02 +0100 Subject: [PATCH 08/13] Use CNPG's BackupPluginConfiguration when possible Signed-off-by: Michael Rittmeister --- operator/src/api/v1/backup_types.go | 2 +- operator/src/api/v1/scheduledbackup_types.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/operator/src/api/v1/backup_types.go b/operator/src/api/v1/backup_types.go index f30cd674d..fe9e9839b 100644 --- a/operator/src/api/v1/backup_types.go +++ b/operator/src/api/v1/backup_types.go @@ -34,7 +34,7 @@ type BackupSpec struct { // PluginConfiguration defines additional parameters passed to the plugin // only relevant if method=plugin // +optional - PluginConfiguration map[string]string `json:"pluginConfiguration,omitempty"` + PluginConfiguration *cnpgv1.BackupPluginConfiguration `json:"pluginConfiguration,omitempty"` // RetentionDays specifies how many days the backup should be retained. // If not specified, the default retention period from the cluster's backup retention policy will be used. diff --git a/operator/src/api/v1/scheduledbackup_types.go b/operator/src/api/v1/scheduledbackup_types.go index fb5359bc9..b648f4a06 100644 --- a/operator/src/api/v1/scheduledbackup_types.go +++ b/operator/src/api/v1/scheduledbackup_types.go @@ -24,7 +24,7 @@ type ScheduledBackupSpec struct { // PluginConfiguration defines additional parameters passed to the plugin // only relevant if method=plugin // +optional - PluginConfiguration map[string]string `json:"pluginConfiguration,omitempty"` + PluginConfiguration *cnpgv1.BackupPluginConfiguration `json:"pluginConfiguration,omitempty"` // Schedule defines when backups should be created using cron expression format. // See https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format From 8e6557450ea1d633dafd02acd8c139e1d5dfe727 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 16 Nov 2026 20:31:34 +0100 Subject: [PATCH 09/13] Use CNPG's BackupPluginConfiguration when possible Signed-off-by: Michael Rittmeister --- operator/src/api/preview/backup_types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/operator/src/api/preview/backup_types.go b/operator/src/api/preview/backup_types.go index 6c020a2f4..ac31186cc 100644 --- a/operator/src/api/preview/backup_types.go +++ b/operator/src/api/preview/backup_types.go @@ -31,12 +31,12 @@ type BackupSpec struct { // can either be 'volumeSnapshot' or 'plugin' // defaults to 'volumeSnapshot' // +kubebuilder:default=volumeSnapshot - Method BackupMethod `json:"method"` + Method BackupMethod `json:"method,omitempty"` // PluginConfiguration defines additional parameters passed to the plugin // only relevant if method=plugin // +optional - PluginConfiguration map[string]string `json:"pluginConfiguration,omitempty"` + PluginConfiguration *cnpgv1.BackupPluginConfiguration `json:"pluginConfiguration,omitempty"` // RetentionDays specifies how many days the backup should be retained. // If not specified, the default retention period from the cluster's backup retention policy will be used. From 9b6c995db9d6ea3f25d6420cca0ce3826a217f6b Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 16 Nov 2026 20:31:38 +0100 Subject: [PATCH 10/13] Update CRDs Signed-off-by: Michael Rittmeister --- .../crds/documentdb.io_backups.yaml | 32 ++++- .../crds/documentdb.io_dbs.yaml | 124 +++++++++--------- .../crds/documentdb.io_scheduledbackups.yaml | 32 ++++- operator/src/api/preview/documentdb_types.go | 7 +- .../src/api/preview/scheduledbackup_types.go | 4 +- .../src/api/preview/zz_generated.deepcopy.go | 36 +++-- operator/src/api/v1/zz_generated.deepcopy.go | 28 ++-- .../crd/bases/documentdb.io_backups.yaml | 32 ++++- .../config/crd/bases/documentdb.io_dbs.yaml | 124 +++++++++--------- .../bases/documentdb.io_scheduledbackups.yaml | 32 ++++- 10 files changed, 262 insertions(+), 189 deletions(-) diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml index 0b21678f0..46cee0b8d 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml @@ -93,11 +93,22 @@ spec: - plugin type: string pluginConfiguration: - additionalProperties: - type: string description: |- PluginConfiguration defines additional parameters passed to the plugin only relevant if method=plugin + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name type: object retentionDays: description: |- @@ -106,7 +117,6 @@ spec: type: integer required: - cluster - - method type: object x-kubernetes-validations: - message: BackupSpec is immutable once set @@ -225,11 +235,22 @@ spec: - plugin type: string pluginConfiguration: - additionalProperties: - type: string description: |- PluginConfiguration defines additional parameters passed to the plugin only relevant if method=plugin + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name type: object retentionDays: description: |- @@ -238,7 +259,6 @@ spec: type: integer required: - cluster - - method type: object x-kubernetes-validations: - message: BackupSpec is immutable once set diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml index e19192fa8..144facc0e 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml @@ -54,37 +54,6 @@ spec: spec: description: DocumentDBSpec defines the desired state of DocumentDB. properties: - additionalCNPGPlugins: - description: AdditionalCNPGPlugins defines which additional CNPG plugins - should be loaded - items: - description: |- - PluginConfiguration specifies a plugin that need to be loaded for this - cluster to be reconciled - properties: - enabled: - default: true - description: Enabled is true if this plugin will be used - type: boolean - isWALArchiver: - default: false - description: |- - Marks the plugin as the WAL archiver. At most one plugin can be - designated as a WAL archiver. This cannot be enabled if the - `.spec.backup.barmanObjectStore` configuration is present. - type: boolean - name: - description: Name is the plugin name - type: string - parameters: - additionalProperties: - type: string - description: Parameters is the configuration of the plugin - type: object - required: - - name - type: object - type: array affinity: description: Affinity/Anti-affinity rules for Pods (cnpg passthrough) properties: @@ -1347,6 +1316,37 @@ spec: Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). All fields are optional; defaults are preserved when omitted. properties: + additional: + description: Additional defines which additional CNPG plugins + should be loaded + items: + description: |- + PluginConfiguration specifies a plugin that need to be loaded for this + cluster to be reconciled + properties: + enabled: + default: true + description: Enabled is true if this plugin will be used + type: boolean + isWALArchiver: + default: false + description: |- + Marks the plugin as the WAL archiver. At most one plugin can be + designated as a WAL archiver. This cannot be enabled if the + `.spec.backup.barmanObjectStore` configuration is present. + type: boolean + name: + description: Name is the plugin name + type: string + parameters: + additionalProperties: + type: string + description: Parameters is the configuration of the plugin + type: object + required: + - name + type: object + type: array sidecarInjectorName: description: |- SidecarInjectorName is the name of the CNPG sidecar injector plugin @@ -1774,37 +1774,6 @@ spec: spec: description: DocumentDBSpec defines the desired state of DocumentDB. properties: - additionalCNPGPlugins: - description: AdditionalCNPGPlugins defines which additional CNPG plugins - should be loaded - items: - description: |- - PluginConfiguration specifies a plugin that need to be loaded for this - cluster to be reconciled - properties: - enabled: - default: true - description: Enabled is true if this plugin will be used - type: boolean - isWALArchiver: - default: false - description: |- - Marks the plugin as the WAL archiver. At most one plugin can be - designated as a WAL archiver. This cannot be enabled if the - `.spec.backup.barmanObjectStore` configuration is present. - type: boolean - name: - description: Name is the plugin name - type: string - parameters: - additionalProperties: - type: string - description: Parameters is the configuration of the plugin - type: object - required: - - name - type: object - type: array affinity: description: Affinity/Anti-affinity rules for Pods (cnpg passthrough) properties: @@ -3067,6 +3036,37 @@ spec: Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). All fields are optional; defaults are preserved when omitted. properties: + additional: + description: Additional defines which additional CNPG plugins + should be loaded + items: + description: |- + PluginConfiguration specifies a plugin that need to be loaded for this + cluster to be reconciled + properties: + enabled: + default: true + description: Enabled is true if this plugin will be used + type: boolean + isWALArchiver: + default: false + description: |- + Marks the plugin as the WAL archiver. At most one plugin can be + designated as a WAL archiver. This cannot be enabled if the + `.spec.backup.barmanObjectStore` configuration is present. + type: boolean + name: + description: Name is the plugin name + type: string + parameters: + additionalProperties: + type: string + description: Parameters is the configuration of the plugin + type: object + required: + - name + type: object + type: array sidecarInjectorName: description: |- SidecarInjectorName is the name of the CNPG sidecar injector plugin diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml index 727e65118..91bc8f8c9 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_scheduledbackups.yaml @@ -74,11 +74,22 @@ spec: - plugin type: string pluginConfiguration: - additionalProperties: - type: string description: |- PluginConfiguration defines additional parameters passed to the plugin only relevant if method=plugin + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name type: object retentionDays: description: |- @@ -92,7 +103,6 @@ spec: type: string required: - cluster - - method - schedule type: object status: @@ -173,11 +183,22 @@ spec: - plugin type: string pluginConfiguration: - additionalProperties: - type: string description: |- PluginConfiguration defines additional parameters passed to the plugin only relevant if method=plugin + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name type: object retentionDays: description: |- @@ -191,7 +212,6 @@ spec: type: string required: - cluster - - method - schedule type: object status: diff --git a/operator/src/api/preview/documentdb_types.go b/operator/src/api/preview/documentdb_types.go index 8b3da277b..582673503 100644 --- a/operator/src/api/preview/documentdb_types.go +++ b/operator/src/api/preview/documentdb_types.go @@ -73,9 +73,6 @@ type DocumentDBSpec struct { // +optional Postgres *PostgresSpec `json:"postgres,omitempty"` - // AdditionalCNPGPlugins defines which additional CNPG plugins should be loaded - // +optional - AdditionalCNPGPlugins []cnpgv1.PluginConfiguration `json:"additionalCNPGPlugins,omitempty"` // Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). // All fields are optional; defaults are preserved when omitted. // +optional @@ -234,6 +231,10 @@ type PluginsSpec struct { // cross-cluster replication. // +optional WalReplicaName string `json:"walReplicaName,omitempty"` + + // Additional defines which additional CNPG plugins should be loaded + // +optional + Additional []cnpgv1.PluginConfiguration `json:"additional,omitempty"` } // BootstrapConfiguration defines how to bootstrap a DocumentDB cluster. diff --git a/operator/src/api/preview/scheduledbackup_types.go b/operator/src/api/preview/scheduledbackup_types.go index e5ec09a0f..0679c7676 100644 --- a/operator/src/api/preview/scheduledbackup_types.go +++ b/operator/src/api/preview/scheduledbackup_types.go @@ -21,12 +21,12 @@ type ScheduledBackupSpec struct { // can either be 'volumeSnapshot' or 'plugin' // defaults to 'volumeSnapshot' // +kubebuilder:default=volumeSnapshot - Method BackupMethod `json:"method"` + Method BackupMethod `json:"method,omitempty"` // PluginConfiguration defines additional parameters passed to the plugin // only relevant if method=plugin // +optional - PluginConfiguration map[string]string `json:"pluginConfiguration,omitempty"` + PluginConfiguration *cnpgv1.BackupPluginConfiguration `json:"pluginConfiguration,omitempty"` // Schedule defines when backups should be created using cron expression format. // See https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format diff --git a/operator/src/api/preview/zz_generated.deepcopy.go b/operator/src/api/preview/zz_generated.deepcopy.go index 0cb0772d5..cf7771a6b 100644 --- a/operator/src/api/preview/zz_generated.deepcopy.go +++ b/operator/src/api/preview/zz_generated.deepcopy.go @@ -8,8 +8,8 @@ package preview import ( - apiv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1" - "k8s.io/api/core/v1" + "github.com/cloudnative-pg/cloudnative-pg/api/v1" + corev1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -93,10 +93,8 @@ func (in *BackupSpec) DeepCopyInto(out *BackupSpec) { in.Cluster.DeepCopyInto(&out.Cluster) if in.PluginConfiguration != nil { in, out := &in.PluginConfiguration, &out.PluginConfiguration - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } + *out = new(v1.BackupPluginConfiguration) + (*in).DeepCopyInto(*out) } if in.RetentionDays != nil { in, out := &in.RetentionDays, &out.RetentionDays @@ -288,7 +286,7 @@ func (in *DocumentDBSpec) DeepCopyInto(out *DocumentDBSpec) { } if in.ImagePullSecrets != nil { in, out := &in.ImagePullSecrets, &out.ImagePullSecrets - *out = make([]v1.LocalObjectReference, len(*in)) + *out = make([]corev1.LocalObjectReference, len(*in)) copy(*out, *in) } if in.ClusterReplication != nil { @@ -301,17 +299,10 @@ func (in *DocumentDBSpec) DeepCopyInto(out *DocumentDBSpec) { *out = new(PostgresSpec) (*in).DeepCopyInto(*out) } - if in.AdditionalCNPGPlugins != nil { - in, out := &in.AdditionalCNPGPlugins, &out.AdditionalCNPGPlugins - *out = make([]apiv1.PluginConfiguration, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } if in.Plugins != nil { in, out := &in.Plugins, &out.Plugins *out = new(PluginsSpec) - **out = **in + (*in).DeepCopyInto(*out) } out.ExposeViaService = in.ExposeViaService out.Timeouts = in.Timeouts @@ -553,6 +544,13 @@ func (in *PVRecoveryConfiguration) DeepCopy() *PVRecoveryConfiguration { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PluginsSpec) DeepCopyInto(out *PluginsSpec) { *out = *in + if in.Additional != nil { + in, out := &in.Additional, &out.Additional + *out = make([]v1.PluginConfiguration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PluginsSpec. @@ -749,10 +747,8 @@ func (in *ScheduledBackupSpec) DeepCopyInto(out *ScheduledBackupSpec) { in.Cluster.DeepCopyInto(&out.Cluster) if in.PluginConfiguration != nil { in, out := &in.PluginConfiguration, &out.PluginConfiguration - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } + *out = new(v1.BackupPluginConfiguration) + (*in).DeepCopyInto(*out) } if in.RetentionDays != nil { in, out := &in.RetentionDays, &out.RetentionDays @@ -819,7 +815,7 @@ func (in *TLSConfiguration) DeepCopyInto(out *TLSConfiguration) { } if in.Postgres != nil { in, out := &in.Postgres, &out.Postgres - *out = new(apiv1.CertificatesConfiguration) + *out = new(v1.CertificatesConfiguration) (*in).DeepCopyInto(*out) } if in.GlobalEndpoints != nil { diff --git a/operator/src/api/v1/zz_generated.deepcopy.go b/operator/src/api/v1/zz_generated.deepcopy.go index 53db5f794..01b43325a 100644 --- a/operator/src/api/v1/zz_generated.deepcopy.go +++ b/operator/src/api/v1/zz_generated.deepcopy.go @@ -93,10 +93,8 @@ func (in *BackupSpec) DeepCopyInto(out *BackupSpec) { in.Cluster.DeepCopyInto(&out.Cluster) if in.PluginConfiguration != nil { in, out := &in.PluginConfiguration, &out.PluginConfiguration - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } + *out = new(apiv1.BackupPluginConfiguration) + (*in).DeepCopyInto(*out) } if in.RetentionDays != nil { in, out := &in.RetentionDays, &out.RetentionDays @@ -301,17 +299,10 @@ func (in *DocumentDBSpec) DeepCopyInto(out *DocumentDBSpec) { *out = new(PostgresSpec) (*in).DeepCopyInto(*out) } - if in.AdditionalCNPGPlugins != nil { - in, out := &in.AdditionalCNPGPlugins, &out.AdditionalCNPGPlugins - *out = make([]apiv1.PluginConfiguration, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } if in.Plugins != nil { in, out := &in.Plugins, &out.Plugins *out = new(PluginsSpec) - **out = **in + (*in).DeepCopyInto(*out) } out.ExposeViaService = in.ExposeViaService out.Timeouts = in.Timeouts @@ -553,6 +544,13 @@ func (in *PVRecoveryConfiguration) DeepCopy() *PVRecoveryConfiguration { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PluginsSpec) DeepCopyInto(out *PluginsSpec) { *out = *in + if in.Additional != nil { + in, out := &in.Additional, &out.Additional + *out = make([]apiv1.PluginConfiguration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PluginsSpec. @@ -749,10 +747,8 @@ func (in *ScheduledBackupSpec) DeepCopyInto(out *ScheduledBackupSpec) { in.Cluster.DeepCopyInto(&out.Cluster) if in.PluginConfiguration != nil { in, out := &in.PluginConfiguration, &out.PluginConfiguration - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } + *out = new(apiv1.BackupPluginConfiguration) + (*in).DeepCopyInto(*out) } if in.RetentionDays != nil { in, out := &in.RetentionDays, &out.RetentionDays diff --git a/operator/src/config/crd/bases/documentdb.io_backups.yaml b/operator/src/config/crd/bases/documentdb.io_backups.yaml index 0b21678f0..46cee0b8d 100644 --- a/operator/src/config/crd/bases/documentdb.io_backups.yaml +++ b/operator/src/config/crd/bases/documentdb.io_backups.yaml @@ -93,11 +93,22 @@ spec: - plugin type: string pluginConfiguration: - additionalProperties: - type: string description: |- PluginConfiguration defines additional parameters passed to the plugin only relevant if method=plugin + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name type: object retentionDays: description: |- @@ -106,7 +117,6 @@ spec: type: integer required: - cluster - - method type: object x-kubernetes-validations: - message: BackupSpec is immutable once set @@ -225,11 +235,22 @@ spec: - plugin type: string pluginConfiguration: - additionalProperties: - type: string description: |- PluginConfiguration defines additional parameters passed to the plugin only relevant if method=plugin + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name type: object retentionDays: description: |- @@ -238,7 +259,6 @@ spec: type: integer required: - cluster - - method type: object x-kubernetes-validations: - message: BackupSpec is immutable once set diff --git a/operator/src/config/crd/bases/documentdb.io_dbs.yaml b/operator/src/config/crd/bases/documentdb.io_dbs.yaml index e19192fa8..144facc0e 100644 --- a/operator/src/config/crd/bases/documentdb.io_dbs.yaml +++ b/operator/src/config/crd/bases/documentdb.io_dbs.yaml @@ -54,37 +54,6 @@ spec: spec: description: DocumentDBSpec defines the desired state of DocumentDB. properties: - additionalCNPGPlugins: - description: AdditionalCNPGPlugins defines which additional CNPG plugins - should be loaded - items: - description: |- - PluginConfiguration specifies a plugin that need to be loaded for this - cluster to be reconciled - properties: - enabled: - default: true - description: Enabled is true if this plugin will be used - type: boolean - isWALArchiver: - default: false - description: |- - Marks the plugin as the WAL archiver. At most one plugin can be - designated as a WAL archiver. This cannot be enabled if the - `.spec.backup.barmanObjectStore` configuration is present. - type: boolean - name: - description: Name is the plugin name - type: string - parameters: - additionalProperties: - type: string - description: Parameters is the configuration of the plugin - type: object - required: - - name - type: object - type: array affinity: description: Affinity/Anti-affinity rules for Pods (cnpg passthrough) properties: @@ -1347,6 +1316,37 @@ spec: Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). All fields are optional; defaults are preserved when omitted. properties: + additional: + description: Additional defines which additional CNPG plugins + should be loaded + items: + description: |- + PluginConfiguration specifies a plugin that need to be loaded for this + cluster to be reconciled + properties: + enabled: + default: true + description: Enabled is true if this plugin will be used + type: boolean + isWALArchiver: + default: false + description: |- + Marks the plugin as the WAL archiver. At most one plugin can be + designated as a WAL archiver. This cannot be enabled if the + `.spec.backup.barmanObjectStore` configuration is present. + type: boolean + name: + description: Name is the plugin name + type: string + parameters: + additionalProperties: + type: string + description: Parameters is the configuration of the plugin + type: object + required: + - name + type: object + type: array sidecarInjectorName: description: |- SidecarInjectorName is the name of the CNPG sidecar injector plugin @@ -1774,37 +1774,6 @@ spec: spec: description: DocumentDBSpec defines the desired state of DocumentDB. properties: - additionalCNPGPlugins: - description: AdditionalCNPGPlugins defines which additional CNPG plugins - should be loaded - items: - description: |- - PluginConfiguration specifies a plugin that need to be loaded for this - cluster to be reconciled - properties: - enabled: - default: true - description: Enabled is true if this plugin will be used - type: boolean - isWALArchiver: - default: false - description: |- - Marks the plugin as the WAL archiver. At most one plugin can be - designated as a WAL archiver. This cannot be enabled if the - `.spec.backup.barmanObjectStore` configuration is present. - type: boolean - name: - description: Name is the plugin name - type: string - parameters: - additionalProperties: - type: string - description: Parameters is the configuration of the plugin - type: object - required: - - name - type: object - type: array affinity: description: Affinity/Anti-affinity rules for Pods (cnpg passthrough) properties: @@ -3067,6 +3036,37 @@ spec: Plugins groups CNPG plugin configuration (sidecar injector name, WAL replica name). All fields are optional; defaults are preserved when omitted. properties: + additional: + description: Additional defines which additional CNPG plugins + should be loaded + items: + description: |- + PluginConfiguration specifies a plugin that need to be loaded for this + cluster to be reconciled + properties: + enabled: + default: true + description: Enabled is true if this plugin will be used + type: boolean + isWALArchiver: + default: false + description: |- + Marks the plugin as the WAL archiver. At most one plugin can be + designated as a WAL archiver. This cannot be enabled if the + `.spec.backup.barmanObjectStore` configuration is present. + type: boolean + name: + description: Name is the plugin name + type: string + parameters: + additionalProperties: + type: string + description: Parameters is the configuration of the plugin + type: object + required: + - name + type: object + type: array sidecarInjectorName: description: |- SidecarInjectorName is the name of the CNPG sidecar injector plugin diff --git a/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml b/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml index 727e65118..91bc8f8c9 100644 --- a/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml +++ b/operator/src/config/crd/bases/documentdb.io_scheduledbackups.yaml @@ -74,11 +74,22 @@ spec: - plugin type: string pluginConfiguration: - additionalProperties: - type: string description: |- PluginConfiguration defines additional parameters passed to the plugin only relevant if method=plugin + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name type: object retentionDays: description: |- @@ -92,7 +103,6 @@ spec: type: string required: - cluster - - method - schedule type: object status: @@ -173,11 +183,22 @@ spec: - plugin type: string pluginConfiguration: - additionalProperties: - type: string description: |- PluginConfiguration defines additional parameters passed to the plugin only relevant if method=plugin + properties: + name: + description: Name is the name of the plugin managing this backup + type: string + parameters: + additionalProperties: + type: string + description: |- + Parameters are the configuration parameters passed to the backup + plugin for this backup + type: object + required: + - name type: object retentionDays: description: |- @@ -191,7 +212,6 @@ spec: type: string required: - cluster - - method - schedule type: object status: From 5267d7028620468a13eb50f1db323fe8d77d16cd Mon Sep 17 00:00:00 2001 From: skloobi Date: Mon, 30 Nov 2026 22:00:02 +0100 Subject: [PATCH 11/13] Implement reconcilers Signed-off-by: skloobi --- operator/src/api/v1/backup_funcs.go | 9 +++++---- operator/src/api/v1/backup_funcs_test.go | 2 +- operator/src/internal/cnpg/cnpg_cluster.go | 3 +++ operator/src/internal/engine/backup.go | 10 +++++++--- operator/src/internal/engine/scheduledbackup.go | 6 ++++-- operator/src/internal/product/documentdb.go | 1 + operator/src/internal/product/intent.go | 3 +++ 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/operator/src/api/v1/backup_funcs.go b/operator/src/api/v1/backup_funcs.go index e17cec01b..0d7c82578 100644 --- a/operator/src/api/v1/backup_funcs.go +++ b/operator/src/api/v1/backup_funcs.go @@ -14,24 +14,25 @@ import ( ) // CreateCNPGBackup creates a CNPG Backup resource based on the DocumentDB Backup spec. -func (backup *Backup) CreateCNPGBackup(scheme *runtime.Scheme, clusterName string) (*cnpgv1.Backup, error) { - return NewCNPGBackup(scheme, backup, clusterName) +func (backup *Backup) CreateCNPGBackup(scheme *runtime.Scheme, clusterName string, spec *BackupSpec) (*cnpgv1.Backup, error) { + return NewCNPGBackup(scheme, backup, clusterName, spec) } // NewCNPGBackup creates a volume-snapshot CNPG Backup of clusterName with the // same name and namespace as owner, controlled by owner so it is garbage // collected with it. -func NewCNPGBackup(scheme *runtime.Scheme, owner client.Object, clusterName string) (*cnpgv1.Backup, error) { +func NewCNPGBackup(scheme *runtime.Scheme, owner client.Object, clusterName string, spec *BackupSpec) (*cnpgv1.Backup, error) { cnpgBackup := &cnpgv1.Backup{ ObjectMeta: metav1.ObjectMeta{ Name: owner.GetName(), Namespace: owner.GetNamespace(), }, Spec: cnpgv1.BackupSpec{ - Method: cnpgv1.BackupMethodVolumeSnapshot, + Method: cnpgv1.BackupMethod(spec.Method), Cluster: cnpgv1.LocalObjectReference{ Name: clusterName, }, + PluginConfiguration: spec.PluginConfiguration, }, } // Set owner reference for garbage collection diff --git a/operator/src/api/v1/backup_funcs_test.go b/operator/src/api/v1/backup_funcs_test.go index 5da591325..cfcc5467d 100644 --- a/operator/src/api/v1/backup_funcs_test.go +++ b/operator/src/api/v1/backup_funcs_test.go @@ -35,7 +35,7 @@ var _ = Describe("Backup", func() { }, } - cnpg, err := backup.CreateCNPGBackup(scheme, "my-cluster-x") + cnpg, err := backup.CreateCNPGBackup(scheme, "my-cluster-x", &backup.Spec) Expect(err).To(BeNil()) Expect(cnpg).ToNot(BeNil()) diff --git a/operator/src/internal/cnpg/cnpg_cluster.go b/operator/src/internal/cnpg/cnpg_cluster.go index a0cfee393..c0dfd0373 100644 --- a/operator/src/internal/cnpg/cnpg_cluster.go +++ b/operator/src/internal/cnpg/cnpg_cluster.go @@ -157,6 +157,9 @@ func GetCnpgClusterSpecFromIntent(req ctrl.Request, intent product.ClusterIntent Resources: buildResourceRequirements(split.Postgres), } spec.MaxStopDelay = stopDelayOrDefault(intent.Postgres.StopDelay) + if intent.AdditionalCNPGPlugins != nil { + spec.Plugins = append(spec.Plugins, intent.AdditionalCNPGPlugins...) + } applyPostgresProcessIdentity(&spec, intent) applyIOUringSeccomp(&spec, intent) applyOtelMonitorRole(&spec, intent.Monitoring, intent.Product.Postgres.MonitoringPasswordSecret) diff --git a/operator/src/internal/engine/backup.go b/operator/src/internal/engine/backup.go index 452be2301..f06ecbe53 100644 --- a/operator/src/internal/engine/backup.go +++ b/operator/src/internal/engine/backup.go @@ -101,10 +101,13 @@ func (r *BackupReconciler[T, B]) Reconcile(ctx context.Context, req ctrl.Request return r.SetBackupPhaseFailed(ctx, backup, "Failed to get associated "+r.Cluster.Profile().Naming.Kind+" cluster: "+err.Error(), nil) } clusterSpec := r.Cluster.Spec(cluster) + backupSpec := r.Backups.Spec(backup) // Ensure VolumeSnapshotClass exists - if err := r.EnsureVolumeSnapshotClass(ctx, clusterSpec.Environment); err != nil { - return r.SetBackupPhaseFailed(ctx, backup, "Failed to ensure VolumeSnapshotClass: "+err.Error(), clusterSpec.Backup) + if cnpgv1.BackupMethod(backupSpec.Method) == cnpgv1.BackupMethodVolumeSnapshot { + if err := r.EnsureVolumeSnapshotClass(ctx, clusterSpec.Environment); err != nil { + return r.SetBackupPhaseFailed(ctx, backup, "Failed to ensure VolumeSnapshotClass: "+err.Error(), clusterSpec.Backup) + } } // Get or create the CNPG Backup @@ -205,7 +208,8 @@ func BuildVolumeSnapshotClass(environment string) *snapshotv1.VolumeSnapshotClas func (r *BackupReconciler[T, B]) CreateCNPGBackup(ctx context.Context, backup B, backupConfiguration *dbv1.BackupConfiguration, replicationContext *util.ReplicationContext) (ctrl.Result, error) { cnpgClusterName := replicationContext.CNPGClusterName - cnpgBackup, err := dbv1.NewCNPGBackup(r.Scheme, backup, cnpgClusterName) + backupSpec := r.Backups.Spec(backup) + cnpgBackup, err := dbv1.NewCNPGBackup(r.Scheme, backup, cnpgClusterName, backupSpec) if err != nil { return r.SetBackupPhaseFailed(ctx, backup, "Failed to initialize backup: "+err.Error(), backupConfiguration) } diff --git a/operator/src/internal/engine/scheduledbackup.go b/operator/src/internal/engine/scheduledbackup.go index 2ad4ef13d..ba1f47291 100644 --- a/operator/src/internal/engine/scheduledbackup.go +++ b/operator/src/internal/engine/scheduledbackup.go @@ -138,8 +138,10 @@ func (r *ScheduledBackupReconciler[T, S, B]) newBackup(scheduledBackup S, now ti dbv1.ScheduledBackupLabel: scheduledBackup.GetName(), }) *r.Backups.Spec(backup) = dbv1.BackupSpec{ - Cluster: spec.Cluster, - RetentionDays: spec.RetentionDays, + Cluster: spec.Cluster, + RetentionDays: spec.RetentionDays, + Method: spec.Method, + PluginConfiguration: spec.PluginConfiguration, } return backup } diff --git a/operator/src/internal/product/documentdb.go b/operator/src/internal/product/documentdb.go index 021997039..2b8eb47f9 100644 --- a/operator/src/internal/product/documentdb.go +++ b/operator/src/internal/product/documentdb.go @@ -228,6 +228,7 @@ func (a DocumentDBAdapter) ToClusterIntent(db *dbv1.DocumentDB) ClusterIntent { IOUring: dbv1.IsFeatureGateEnabled(db, dbv1.FeatureGateIOUring), }, Bootstrap: bootstrap, + AdditionalCNPGPlugins: db.Spec.Plugins.Additional, CredentialSecret: credentialSecret, SidecarInjectorPlugin: sidecarPlugin, WALReplicaPlugin: p.WALReplicaPlugin, diff --git a/operator/src/internal/product/intent.go b/operator/src/internal/product/intent.go index 1139cdf6f..9e782e538 100644 --- a/operator/src/internal/product/intent.go +++ b/operator/src/internal/product/intent.go @@ -159,6 +159,9 @@ type ClusterIntent struct { // Bootstrap describes how the cluster is initialized. Bootstrap Bootstrap + // AdditionalCNPGPlugins are the resolved CNPG plugin names to wire onto the Cluster. + AdditionalCNPGPlugins []cnpgv1.PluginConfiguration + // CredentialSecret is the resolved credential secret name. CredentialSecret string From 0d560bbec331c6fe4768bc50b0c322a3051adcbc Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Wed, 2 Dec 2026 23:25:11 +0100 Subject: [PATCH 12/13] Fix failing tests Signed-off-by: Michael Rittmeister --- .../crds/documentdb.io_dbs.yaml | 2 ++ operator/src/api/preview/documentdb_types.go | 1 + operator/src/api/v1/backup_funcs.go | 6 +++++- .../src/config/crd/bases/documentdb.io_dbs.yaml | 2 ++ operator/src/internal/engine/backup_test.go | 13 +++++++++++-- .../src/internal/engine/scheduledbackup_test.go | 2 +- operator/src/internal/product/documentdb.go | 8 +++++++- 7 files changed, 29 insertions(+), 5 deletions(-) diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml index 144facc0e..590f617e6 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml @@ -1317,6 +1317,7 @@ spec: All fields are optional; defaults are preserved when omitted. properties: additional: + default: '[]' description: Additional defines which additional CNPG plugins should be loaded items: @@ -3037,6 +3038,7 @@ spec: All fields are optional; defaults are preserved when omitted. properties: additional: + default: '[]' description: Additional defines which additional CNPG plugins should be loaded items: diff --git a/operator/src/api/preview/documentdb_types.go b/operator/src/api/preview/documentdb_types.go index 582673503..d987ecc3a 100644 --- a/operator/src/api/preview/documentdb_types.go +++ b/operator/src/api/preview/documentdb_types.go @@ -234,6 +234,7 @@ type PluginsSpec struct { // Additional defines which additional CNPG plugins should be loaded // +optional + // +kubebuilder:default=[] Additional []cnpgv1.PluginConfiguration `json:"additional,omitempty"` } diff --git a/operator/src/api/v1/backup_funcs.go b/operator/src/api/v1/backup_funcs.go index 0d7c82578..5cd344fc9 100644 --- a/operator/src/api/v1/backup_funcs.go +++ b/operator/src/api/v1/backup_funcs.go @@ -22,13 +22,17 @@ func (backup *Backup) CreateCNPGBackup(scheme *runtime.Scheme, clusterName strin // same name and namespace as owner, controlled by owner so it is garbage // collected with it. func NewCNPGBackup(scheme *runtime.Scheme, owner client.Object, clusterName string, spec *BackupSpec) (*cnpgv1.Backup, error) { + backupMethod := spec.Method + if len(backupMethod) == 0 { + backupMethod = BackupMethod(cnpgv1.BackupMethodVolumeSnapshot) + } cnpgBackup := &cnpgv1.Backup{ ObjectMeta: metav1.ObjectMeta{ Name: owner.GetName(), Namespace: owner.GetNamespace(), }, Spec: cnpgv1.BackupSpec{ - Method: cnpgv1.BackupMethod(spec.Method), + Method: cnpgv1.BackupMethod(backupMethod), Cluster: cnpgv1.LocalObjectReference{ Name: clusterName, }, diff --git a/operator/src/config/crd/bases/documentdb.io_dbs.yaml b/operator/src/config/crd/bases/documentdb.io_dbs.yaml index 144facc0e..590f617e6 100644 --- a/operator/src/config/crd/bases/documentdb.io_dbs.yaml +++ b/operator/src/config/crd/bases/documentdb.io_dbs.yaml @@ -1317,6 +1317,7 @@ spec: All fields are optional; defaults are preserved when omitted. properties: additional: + default: '[]' description: Additional defines which additional CNPG plugins should be loaded items: @@ -3037,6 +3038,7 @@ spec: All fields are optional; defaults are preserved when omitted. properties: additional: + default: '[]' description: Additional defines which additional CNPG plugins should be loaded items: diff --git a/operator/src/internal/engine/backup_test.go b/operator/src/internal/engine/backup_test.go index 558491238..61a51a9ca 100644 --- a/operator/src/internal/engine/backup_test.go +++ b/operator/src/internal/engine/backup_test.go @@ -54,15 +54,24 @@ func defaultSnapshotClass() *snapshotv1.VolumeSnapshotClass { } } -func getBackup(t *testing.T, c client.Client) *dbv1.Backup { +func getBackupWithMethod(t *testing.T, c client.Client, method dbv1.BackupMethod) *dbv1.Backup { t.Helper() - b := &dbv1.Backup{} + backupMethod := method + b := &dbv1.Backup{ + Spec: dbv1.BackupSpec{ + Method: backupMethod, + }, + } if err := c.Get(context.Background(), backupKey.NamespacedName, b); err != nil { t.Fatalf("get backup: %v", err) } return b } +func getBackup(t *testing.T, c client.Client) *dbv1.Backup { + return getBackupWithMethod(t, c, dbv1.BackupMethodVolumeSnapshot) +} + func TestBackupReconcileNotFoundAndGetError(t *testing.T) { s := newTestScheme(t) r := newBackupReconciler(newFakeClient(t, s, nil), s, record.NewFakeRecorder(10)) diff --git a/operator/src/internal/engine/scheduledbackup_test.go b/operator/src/internal/engine/scheduledbackup_test.go index 4576d3352..57522ee26 100644 --- a/operator/src/internal/engine/scheduledbackup_test.go +++ b/operator/src/internal/engine/scheduledbackup_test.go @@ -55,7 +55,7 @@ func testScheduledBackup(schedule string) *dbv1.ScheduledBackup { func testBackupFor(name string, phase cnpgv1.BackupPhase, created time.Time) *dbv1.Backup { return &dbv1.Backup{ ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: testNamespace, CreationTimestamp: metav1.NewTime(created)}, - Spec: dbv1.BackupSpec{Cluster: cnpgv1.LocalObjectReference{Name: "db"}}, + Spec: dbv1.BackupSpec{Cluster: cnpgv1.LocalObjectReference{Name: "db"}, Method: dbv1.BackupMethod(cnpgv1.BackupMethodVolumeSnapshot)}, Status: dbv1.BackupStatus{Phase: phase}, } } diff --git a/operator/src/internal/product/documentdb.go b/operator/src/internal/product/documentdb.go index 2b8eb47f9..7185b390c 100644 --- a/operator/src/internal/product/documentdb.go +++ b/operator/src/internal/product/documentdb.go @@ -6,6 +6,7 @@ package product import ( "os" + cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1" dbv1 "github.com/documentdb/documentdb-operator/api/v1" util "github.com/documentdb/documentdb-operator/internal/utils" ) @@ -196,6 +197,11 @@ func (a DocumentDBAdapter) ToClusterIntent(db *dbv1.DocumentDB) ClusterIntent { bootstrap.Recovery = &r } + var additionalPlugins []cnpgv1.PluginConfiguration + if db.Spec.Plugins != nil && db.Spec.Plugins.Additional != nil { + additionalPlugins = db.Spec.Plugins.Additional + } + return ClusterIntent{ Images: Images{ PostgresExtension: a.ExtensionImage(db), @@ -228,7 +234,7 @@ func (a DocumentDBAdapter) ToClusterIntent(db *dbv1.DocumentDB) ClusterIntent { IOUring: dbv1.IsFeatureGateEnabled(db, dbv1.FeatureGateIOUring), }, Bootstrap: bootstrap, - AdditionalCNPGPlugins: db.Spec.Plugins.Additional, + AdditionalCNPGPlugins: additionalPlugins, CredentialSecret: credentialSecret, SidecarInjectorPlugin: sidecarPlugin, WALReplicaPlugin: p.WALReplicaPlugin, From 1999955e6933b5c47080ca96d2ae87e89140d60c Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 3 Dec 2026 01:01:55 +0100 Subject: [PATCH 13/13] Update CRDs Signed-off-by: Michael Rittmeister --- operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml | 2 -- operator/src/api/preview/documentdb_types.go | 1 - operator/src/config/crd/bases/documentdb.io_dbs.yaml | 2 -- 3 files changed, 5 deletions(-) diff --git a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml index 590f617e6..144facc0e 100644 --- a/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml +++ b/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml @@ -1317,7 +1317,6 @@ spec: All fields are optional; defaults are preserved when omitted. properties: additional: - default: '[]' description: Additional defines which additional CNPG plugins should be loaded items: @@ -3038,7 +3037,6 @@ spec: All fields are optional; defaults are preserved when omitted. properties: additional: - default: '[]' description: Additional defines which additional CNPG plugins should be loaded items: diff --git a/operator/src/api/preview/documentdb_types.go b/operator/src/api/preview/documentdb_types.go index d987ecc3a..582673503 100644 --- a/operator/src/api/preview/documentdb_types.go +++ b/operator/src/api/preview/documentdb_types.go @@ -234,7 +234,6 @@ type PluginsSpec struct { // Additional defines which additional CNPG plugins should be loaded // +optional - // +kubebuilder:default=[] Additional []cnpgv1.PluginConfiguration `json:"additional,omitempty"` } diff --git a/operator/src/config/crd/bases/documentdb.io_dbs.yaml b/operator/src/config/crd/bases/documentdb.io_dbs.yaml index 590f617e6..144facc0e 100644 --- a/operator/src/config/crd/bases/documentdb.io_dbs.yaml +++ b/operator/src/config/crd/bases/documentdb.io_dbs.yaml @@ -1317,7 +1317,6 @@ spec: All fields are optional; defaults are preserved when omitted. properties: additional: - default: '[]' description: Additional defines which additional CNPG plugins should be loaded items: @@ -3038,7 +3037,6 @@ spec: All fields are optional; defaults are preserved when omitted. properties: additional: - default: '[]' description: Additional defines which additional CNPG plugins should be loaded items: