Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions operator/documentdb-helm-chart/crds/documentdb.io_backups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,34 @@ spec:
required:
- name
type: object
method:
default: volumeSnapshot
description: |-
Method defines with method should be used to create a backup

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: reads a little odd. Do we need to reward or break sentences?

can either be 'volumeSnapshot' or 'plugin'
defaults to 'volumeSnapshot'
enum:
- volumeSnapshot
- plugin
type: string
pluginConfiguration:
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: |-
RetentionDays specifies how many days the backup should be retained.
Expand Down Expand Up @@ -196,6 +224,34 @@ 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'
enum:
- volumeSnapshot
- plugin
type: string
pluginConfiguration:
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: |-
RetentionDays specifies how many days the backup should be retained.
Expand Down
62 changes: 62 additions & 0 deletions operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1316,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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting config. A clear message would be helpful.

// Additional lists extra CloudNativePG plugins to load on the cluster, alongside
// the built-in sidecar injector, for example the Barman Cloud plugin for WAL
// archiving and object-store backups. Names must be unique and must not match
// the built-in plugins.
// +listType=map
// +listMapKey=name

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
Expand Down Expand Up @@ -3005,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ 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'
enum:
- volumeSnapshot
- plugin
type: string
pluginConfiguration:
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: |-
RetentionDays specifies how many days the backups should be retained.
Expand Down Expand Up @@ -144,6 +172,34 @@ 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'
enum:
- volumeSnapshot
- plugin
type: string
pluginConfiguration:
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: |-
RetentionDays specifies how many days the backups should be retained.
Expand Down
20 changes: 20 additions & 0 deletions operator/src/api/preview/backup_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions operator/src/api/preview/documentdb_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions operator/src/api/preview/scheduledbackup_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 22 additions & 5 deletions operator/src/api/preview/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions operator/src/api/v1/backup_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,29 @@ 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) {
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.BackupMethodVolumeSnapshot,
Method: cnpgv1.BackupMethod(backupMethod),
Cluster: cnpgv1.LocalObjectReference{
Name: clusterName,
},
PluginConfiguration: spec.PluginConfiguration,
},
}
// Set owner reference for garbage collection
Expand Down
2 changes: 1 addition & 1 deletion operator/src/api/v1/backup_funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
Loading
Loading