Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make the entrypoint of pgBackRest image configurable #3486

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ spec:
pgbackrest:
description: pgBackRest archive configuration
properties:
command:
description: The command for pgBackRest containers. The default
is "/opt/crunchy/bin/pgbackrest".
items:
type: string
type: array
configuration:
description: 'Projected volumes containing custom pgBackRest
configuration. These files are mounted under "/etc/pgbackrest/conf.d"
Expand Down
5 changes: 5 additions & 0 deletions docs/content/references/crd.md

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

7 changes: 6 additions & 1 deletion internal/controller/postgrescluster/pgbackrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ func generateBackupJobSpecIntent(postgresCluster *v1beta1.PostgresCluster,
cmdOpts = append(cmdOpts, opts...)

container := corev1.Container{
Command: []string{"/opt/crunchy/bin/pgbackrest"},
Env: []corev1.EnvVar{
{Name: "COMMAND", Value: "backup"},
{Name: "COMMAND_OPTS", Value: strings.Join(cmdOpts, " ")},
Expand All @@ -694,6 +693,12 @@ func generateBackupJobSpecIntent(postgresCluster *v1beta1.PostgresCluster,
SecurityContext: initialize.RestrictedSecurityContext(),
}

if postgresCluster.Spec.Backups.PGBackRest.Command != nil {
container.Command = postgresCluster.Spec.Backups.PGBackRest.Command
} else {
container.Command = []string{"/opt/crunchy/bin/pgbackrest"}
}

if postgresCluster.Spec.Backups.PGBackRest.Jobs != nil {
container.Resources = postgresCluster.Spec.Backups.PGBackRest.Jobs.Resources
}
Expand Down
13 changes: 13 additions & 0 deletions internal/controller/postgrescluster/pgbackrest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2715,6 +2715,19 @@ volumes:
}
})
})

t.Run("Command", func(t *testing.T) {
cmd := []string{"cmd", "blah"}
cluster := &v1beta1.PostgresCluster{}
cluster.Spec.Backups.PGBackRest.Command = cmd
job, err := generateBackupJobSpecIntent(
cluster, v1beta1.PGBackRestRepo{},
"",
nil, nil,
)
assert.NilError(t, err)
assert.DeepEqual(t, job.Template.Spec.Containers[0].Command, cmd)
})
}

func TestGenerateRepoHostIntent(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ type PGBackRestArchive struct {
// +optional
Image string `json:"image,omitempty"`

// The command for pgBackRest containers. The default is "/opt/crunchy/bin/pgbackrest".
// +optional
Command []string `json:"command,omitempty"`

// Jobs field allows configuration for all backup jobs
// +optional
Jobs *BackupJobs `json:"jobs,omitempty"`
Expand Down

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