Skip to content
Merged
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 @@ -649,6 +649,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -8885,6 +8887,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -11718,6 +11722,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -8690,6 +8692,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -10151,6 +10155,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/pgv2.percona.com_perconapgclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -9097,6 +9099,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -10558,6 +10562,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -8840,6 +8842,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -11660,6 +11664,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down
12 changes: 12 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -9394,6 +9396,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -10855,6 +10859,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down Expand Up @@ -27149,6 +27155,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -35348,6 +35356,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -38168,6 +38178,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down
12 changes: 12 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -9394,6 +9396,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -10855,6 +10859,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down Expand Up @@ -27149,6 +27155,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -35348,6 +35356,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -38168,6 +38178,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down
12 changes: 12 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -9394,6 +9396,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -10855,6 +10859,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down Expand Up @@ -27149,6 +27155,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
jobs:
description: Jobs field allows configuration for all backup
Expand Down Expand Up @@ -35348,6 +35356,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
instances:
description: |-
Expand Down Expand Up @@ -38168,6 +38178,8 @@ spec:
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
required:
- image
type: object
initContainers:
description: |-
Expand Down
1 change: 1 addition & 0 deletions internal/controller/postgrescluster/pgbackrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ func generateBackupJobSpecIntent(ctx context.Context, postgresCluster *v1beta1.P
}
initContainers = []corev1.Container{
k8s.InitContainer(
postgresCluster,
naming.PGBackRestRepoContainerName,
initImage,
postgresCluster.Spec.ImagePullPolicy,
Expand Down
1 change: 1 addition & 0 deletions internal/patroni/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func InstancePod(ctx context.Context,
// K8SPG-708 instanceInitContainer adds the instance init container
func instanceInitContainer(cluster *v1beta1.PostgresCluster, container *corev1.Container, instancePod *corev1.PodTemplateSpec, inInstanceSpec *v1beta1.PostgresInstanceSetSpec, initImage string) {
instancePod.Spec.InitContainers = append(instancePod.Spec.InitContainers, k8s.InitContainer(
cluster,
naming.ContainerDatabase,
initImage,
cluster.Spec.ImagePullPolicy,
Expand Down
6 changes: 5 additions & 1 deletion percona/k8s/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,21 @@ func GetWatchNamespace() (string, error) {
return ns, nil
}

func InitContainer(componentName, image string,
func InitContainer(cluster *v1beta1.PostgresCluster, componentName, image string,
pullPolicy corev1.PullPolicy,
secCtx *corev1.SecurityContext,
resources corev1.ResourceRequirements,
component ComponentWithInit,
) corev1.Container {
if component != nil && component.GetInitContainer() != nil && component.GetInitContainer().Resources != nil {
resources = *component.GetInitContainer().Resources
} else if ic := cluster.Spec.InitContainer; ic != nil && ic.Resources != nil {
resources = *ic.Resources
}
if component != nil && component.GetInitContainer() != nil && component.GetInitContainer().ContainerSecurityContext != nil {
secCtx = component.GetInitContainer().ContainerSecurityContext
} else if ic := cluster.Spec.InitContainer; ic != nil && ic.ContainerSecurityContext != nil {
secCtx = ic.ContainerSecurityContext
}

volumeMounts := []corev1.VolumeMount{
Expand Down
2 changes: 1 addition & 1 deletion percona/k8s/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ volumeMounts:
t.Setenv("OPERATOR_NAMESPACE", cr.Namespace)
cr := tt.getCluster().DeepCopy()

container := InitContainer(tt.component, tt.image, tt.pullPolicy, tt.secCtx, tt.resources, tt.getComponent(cr))
container := InitContainer(tt.getCluster(), tt.component, tt.image, tt.pullPolicy, tt.secCtx, tt.resources, tt.getComponent(cr))
data, err := yaml.Marshal(container)
if err != nil {
t.Fatal(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ type PostgresClusterSpec struct {
}

type InitContainerSpec struct {
// +kubebuilder:validation:Required
Image string `json:"image,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
Expand Down
Loading