Skip to content

Commit 6854650

Browse files
committed
change API spec
1 parent 1ed14e1 commit 6854650

File tree

5 files changed

+141
-106
lines changed

5 files changed

+141
-106
lines changed

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

Lines changed: 98 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -12833,50 +12833,6 @@ spec:
1283312833
pgBouncer:
1283412834
description: Defines a PgBouncer proxy and connection pooler.
1283512835
properties:
12836-
additional:
12837-
description: Additional pre-existing volumes to add to the
12838-
pod.
12839-
items:
12840-
properties:
12841-
claimName:
12842-
description: A reference to a preexisting PVC.
12843-
maxLength: 253
12844-
minLength: 1
12845-
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?([.][a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
12846-
type: string
12847-
containers:
12848-
description: |-
12849-
The containers to attach this volume to.
12850-
An omitted `Containers` field matches all containers.
12851-
An empty `Containers` field matches no containers.
12852-
items:
12853-
type: string
12854-
maxItems: 10
12855-
type: array
12856-
x-kubernetes-list-type: atomic
12857-
name:
12858-
allOf:
12859-
- maxLength: 63
12860-
- maxLength: 55
12861-
description: |-
12862-
The name of the volume used for mounting path.
12863-
Volumes are mounted in the pods at `volumes/<NAME>`
12864-
Must be unique.
12865-
minLength: 1
12866-
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
12867-
type: string
12868-
readOnly:
12869-
description: Sets the write/read mode of the volume
12870-
type: boolean
12871-
required:
12872-
- claimName
12873-
- name
12874-
type: object
12875-
maxItems: 10
12876-
type: array
12877-
x-kubernetes-list-map-keys:
12878-
- name
12879-
x-kubernetes-list-type: map
1288012836
affinity:
1288112837
description: |-
1288212838
Scheduling constraints of a PgBouncer pod. Changing this value causes
@@ -16138,6 +16094,55 @@ spec:
1613816094
- whenUnsatisfiable
1613916095
type: object
1614016096
type: array
16097+
volumes:
16098+
description: PGBouncerVolumesSpec defines the configuration
16099+
for pgBouncer additional volumes
16100+
properties:
16101+
additional:
16102+
description: Additional pre-existing volumes to add to
16103+
the pod.
16104+
items:
16105+
properties:
16106+
claimName:
16107+
description: A reference to a preexisting PVC.
16108+
maxLength: 253
16109+
minLength: 1
16110+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?([.][a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
16111+
type: string
16112+
containers:
16113+
description: |-
16114+
The containers to attach this volume to.
16115+
An omitted `Containers` field matches all containers.
16116+
An empty `Containers` field matches no containers.
16117+
items:
16118+
type: string
16119+
maxItems: 10
16120+
type: array
16121+
x-kubernetes-list-type: atomic
16122+
name:
16123+
allOf:
16124+
- maxLength: 63
16125+
- maxLength: 55
16126+
description: |-
16127+
The name of the volume used for mounting path.
16128+
Volumes are mounted in the pods at `volumes/<NAME>`
16129+
Must be unique.
16130+
minLength: 1
16131+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
16132+
type: string
16133+
readOnly:
16134+
description: Sets the write/read mode of the volume
16135+
type: boolean
16136+
required:
16137+
- claimName
16138+
- name
16139+
type: object
16140+
maxItems: 10
16141+
type: array
16142+
x-kubernetes-list-map-keys:
16143+
- name
16144+
x-kubernetes-list-type: map
16145+
type: object
1614116146
type: object
1614216147
required:
1614316148
- pgBouncer
@@ -31492,50 +31497,6 @@ spec:
3149231497
pgBouncer:
3149331498
description: Defines a PgBouncer proxy and connection pooler.
3149431499
properties:
31495-
additional:
31496-
description: Additional pre-existing volumes to add to the
31497-
pod.
31498-
items:
31499-
properties:
31500-
claimName:
31501-
description: A reference to a preexisting PVC.
31502-
maxLength: 253
31503-
minLength: 1
31504-
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?([.][a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
31505-
type: string
31506-
containers:
31507-
description: |-
31508-
The containers to attach this volume to.
31509-
An omitted `Containers` field matches all containers.
31510-
An empty `Containers` field matches no containers.
31511-
items:
31512-
type: string
31513-
maxItems: 10
31514-
type: array
31515-
x-kubernetes-list-type: atomic
31516-
name:
31517-
allOf:
31518-
- maxLength: 63
31519-
- maxLength: 55
31520-
description: |-
31521-
The name of the volume used for mounting path.
31522-
Volumes are mounted in the pods at `volumes/<NAME>`
31523-
Must be unique.
31524-
minLength: 1
31525-
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
31526-
type: string
31527-
readOnly:
31528-
description: Sets the write/read mode of the volume
31529-
type: boolean
31530-
required:
31531-
- claimName
31532-
- name
31533-
type: object
31534-
maxItems: 10
31535-
type: array
31536-
x-kubernetes-list-map-keys:
31537-
- name
31538-
x-kubernetes-list-type: map
3153931500
affinity:
3154031501
description: |-
3154131502
Scheduling constraints of a PgBouncer pod. Changing this value causes
@@ -34797,6 +34758,55 @@ spec:
3479734758
- whenUnsatisfiable
3479834759
type: object
3479934760
type: array
34761+
volumes:
34762+
description: PGBouncerVolumesSpec defines the configuration
34763+
for pgBouncer additional volumes
34764+
properties:
34765+
additional:
34766+
description: Additional pre-existing volumes to add to
34767+
the pod.
34768+
items:
34769+
properties:
34770+
claimName:
34771+
description: A reference to a preexisting PVC.
34772+
maxLength: 253
34773+
minLength: 1
34774+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?([.][a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
34775+
type: string
34776+
containers:
34777+
description: |-
34778+
The containers to attach this volume to.
34779+
An omitted `Containers` field matches all containers.
34780+
An empty `Containers` field matches no containers.
34781+
items:
34782+
type: string
34783+
maxItems: 10
34784+
type: array
34785+
x-kubernetes-list-type: atomic
34786+
name:
34787+
allOf:
34788+
- maxLength: 63
34789+
- maxLength: 55
34790+
description: |-
34791+
The name of the volume used for mounting path.
34792+
Volumes are mounted in the pods at `volumes/<NAME>`
34793+
Must be unique.
34794+
minLength: 1
34795+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
34796+
type: string
34797+
readOnly:
34798+
description: Sets the write/read mode of the volume
34799+
type: boolean
34800+
required:
34801+
- claimName
34802+
- name
34803+
type: object
34804+
maxItems: 10
34805+
type: array
34806+
x-kubernetes-list-map-keys:
34807+
- name
34808+
x-kubernetes-list-type: map
34809+
type: object
3480034810
type: object
3480134811
required:
3480234812
- pgBouncer

internal/controller/postgrescluster/pgbouncer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ func (r *Reconciler) generatePGBouncerDeployment(
476476
AddTMPEmptyDir(&deploy.Spec.Template)
477477

478478
// mount additional volumes to the pgbouncer containers
479-
if err == nil && cluster.Spec.Proxy.PGBouncer.Additional != nil && len(cluster.Spec.Proxy.PGBouncer.Additional) > 0 {
480-
missingContainers := addAdditionalVolumesToSpecifiedContainers(&deploy.Spec.Template, cluster.Spec.Proxy.PGBouncer.Additional)
479+
if err == nil && cluster.Spec.Proxy.PGBouncer.Volumes != nil && len(cluster.Spec.Proxy.PGBouncer.Volumes.Additional) > 0 {
480+
missingContainers := addAdditionalVolumesToSpecifiedContainers(&deploy.Spec.Template, cluster.Spec.Proxy.PGBouncer.Volumes.Additional)
481481

482482
if len(missingContainers) > 0 {
483483
r.Recorder.Eventf(cluster, corev1.EventTypeWarning, "SpecifiedContainerNotFound",

internal/controller/postgrescluster/pgbouncer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ topologySpreadConstraints:
514514
assert.Assert(t, false)
515515

516516
cluster := cluster.DeepCopy()
517-
cluster.Spec.Proxy.PGBouncer.Additional = []v1beta1.AdditionalVolume{{
517+
cluster.Spec.Proxy.PGBouncer.Volumes.Additional = []v1beta1.AdditionalVolume{{
518518
ClaimName: "required",
519519
Name: "required",
520520
}}

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ type PGBouncerPodSpec struct {
4949
// +optional
5050
Metadata *Metadata `json:"metadata,omitempty"`
5151

52-
// Additional pre-existing volumes to add to the pod.
53-
// ---
54-
// +optional
55-
// +listType=map
56-
// +listMapKey=name
57-
// +kubebuilder:validation:MaxItems=10
58-
Additional []AdditionalVolume `json:"additional,omitempty"`
59-
6052
// Scheduling constraints of a PgBouncer pod. Changing this value causes
6153
// PgBouncer to restart.
6254
// More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node
@@ -139,6 +131,19 @@ type PGBouncerPodSpec struct {
139131
// More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
140132
// +optional
141133
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
134+
135+
Volumes *PGBouncerVolumesSpec `json:"volumes,omitempty"`
136+
}
137+
138+
// PGBouncerVolumesSpec defines the configuration for pgBouncer additional volumes
139+
type PGBouncerVolumesSpec struct {
140+
// Additional pre-existing volumes to add to the pod.
141+
// ---
142+
// +optional
143+
// +listType=map
144+
// +listMapKey=name
145+
// +kubebuilder:validation:MaxItems=10
146+
Additional []AdditionalVolume `json:"additional,omitempty"`
142147
}
143148

144149
// PGBouncerSidecars defines the configuration for pgBouncer sidecar containers

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

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

0 commit comments

Comments
 (0)