Skip to content

Commit 86c8552

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

File tree

6 files changed

+41
-1
lines changed

6 files changed

+41
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ spec:
4343
pgbackrest:
4444
description: pgBackRest archive configuration
4545
properties:
46+
command:
47+
description: The command for pgBackRest containers. If it's
48+
ommit, "/opt/crunchy/bin/pgbackrest" is used as the default
49+
one.
50+
items:
51+
type: string
52+
type: array
4653
configuration:
4754
description: 'Projected volumes containing custom pgBackRest
4855
configuration. These files are mounted under "/etc/pgbackrest/conf.d"

docs/content/references/crd.md

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/postgrescluster/pgbackrest.go

Lines changed: 6 additions & 1 deletion
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

Lines changed: 13 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ type PGBackRestArchive struct {
120120
// +optional
121121
Image string `json:"image,omitempty"`
122122

123+
// The command for pgBackRest containers. If it's ommit, "/opt/crunchy/bin/pgbackrest" is
124+
// used as the default one.
125+
// +optional
126+
Command []string `json:"command,omitempty"`
127+
123128
// Jobs field allows configuration for all backup jobs
124129
// +optional
125130
Jobs *BackupJobs `json:"jobs,omitempty"`

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

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)