Skip to content

Commit c95d8be

Browse files
author
Keiji Hokamura
committed
feat: make the entrypoint of pgBackRest image configurable
1 parent da682a2 commit c95d8be

File tree

6 files changed

+39
-1
lines changed

6 files changed

+39
-1
lines changed

config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ spec:
4343
pgbackrest:
4444
description: pgBackRest archive configuration
4545
properties:
46+
command:
47+
description: The command for pgBackRest containers. The default
48+
is "/opt/crunchy/bin/pgbackrest".
49+
items:
50+
type: string
51+
type: array
4652
configuration:
4753
description: 'Projected volumes containing custom pgBackRest
4854
configuration. These files are mounted under "/etc/pgbackrest/conf.d"

docs/content/references/crd.md

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/postgrescluster/pgbackrest.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,6 @@ func generateBackupJobSpecIntent(postgresCluster *v1beta1.PostgresCluster,
679679
cmdOpts = append(cmdOpts, opts...)
680680

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

696+
if postgresCluster.Spec.Backups.PGBackRest.Command != nil {
697+
container.Command = postgresCluster.Spec.Backups.PGBackRest.Command
698+
} else {
699+
container.Command = []string{"/opt/crunchy/bin/pgbackrest"}
700+
}
701+
697702
if postgresCluster.Spec.Backups.PGBackRest.Jobs != nil {
698703
container.Resources = postgresCluster.Spec.Backups.PGBackRest.Jobs.Resources
699704
}

internal/controller/postgrescluster/pgbackrest_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,19 @@ volumes:
27152715
}
27162716
})
27172717
})
2718+
2719+
t.Run("Command", func(t *testing.T) {
2720+
cmd := []string{"cmd", "blah"}
2721+
cluster := &v1beta1.PostgresCluster{}
2722+
cluster.Spec.Backups.PGBackRest.Command = cmd
2723+
job, err := generateBackupJobSpecIntent(
2724+
cluster, v1beta1.PGBackRestRepo{},
2725+
"",
2726+
nil, nil,
2727+
)
2728+
assert.NilError(t, err)
2729+
assert.DeepEqual(t, job.Template.Spec.Containers[0].Command, cmd)
2730+
})
27182731
}
27192732

27202733
func TestGenerateRepoHostIntent(t *testing.T) {

pkg/apis/postgres-operator.crunchydata.com/v1beta1/pgbackrest_types.go

+4
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ type PGBackRestArchive struct {
120120
// +optional
121121
Image string `json:"image,omitempty"`
122122

123+
// The command for pgBackRest containers. The default is "/opt/crunchy/bin/pgbackrest".
124+
// +optional
125+
Command []string `json:"command,omitempty"`
126+
123127
// Jobs field allows configuration for all backup jobs
124128
// +optional
125129
Jobs *BackupJobs `json:"jobs,omitempty"`

pkg/apis/postgres-operator.crunchydata.com/v1beta1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)