@@ -33,6 +33,7 @@ import (
3333const (
3434 initContainerCPU string = "100m"
3535 initContainerMemory string = "500Mi"
36+ defaultPVCName string = "persistence"
3637 DeletionMarker string = "skipPreStopChecks"
3738)
3839
@@ -121,6 +122,9 @@ func (builder *StatefulSetBuilder) Update(object client.Object) error {
121122 //Labels
122123 sts .Labels = metadata .GetLabels (builder .Instance .Name , builder .Instance .Labels )
123124
125+ // PVC storage capacity
126+ updatePersistenceStorageCapacity (& sts .Spec .VolumeClaimTemplates , builder .Instance .Spec .Persistence .Storage )
127+
124128 // pod template
125129 sts .Spec .Template = builder .podTemplateSpec (sts .Spec .Template .Annotations )
126130
@@ -141,6 +145,14 @@ func (builder *StatefulSetBuilder) Update(object client.Object) error {
141145 return nil
142146}
143147
148+ func updatePersistenceStorageCapacity (templates * []corev1.PersistentVolumeClaim , capacity * k8sresource.Quantity ) {
149+ for _ , t := range * templates {
150+ if t .Name == defaultPVCName {
151+ t .Spec .Resources .Requests [corev1 .ResourceStorage ] = * capacity
152+ }
153+ }
154+ }
155+
144156func applyStsOverride (sts * appsv1.StatefulSet , stsOverride * rabbitmqv1beta1.StatefulSet ) error {
145157 if stsOverride .EmbeddedLabelsAnnotations != nil {
146158 copyLabelsAnnotations (& sts .ObjectMeta , * stsOverride .EmbeddedLabelsAnnotations )
@@ -178,7 +190,7 @@ func applyStsOverride(sts *appsv1.StatefulSet, stsOverride *rabbitmqv1beta1.Stat
178190func persistentVolumeClaim (instance * rabbitmqv1beta1.RabbitmqCluster , scheme * runtime.Scheme ) ([]corev1.PersistentVolumeClaim , error ) {
179191 pvc := corev1.PersistentVolumeClaim {
180192 ObjectMeta : metav1.ObjectMeta {
181- Name : "persistence" ,
193+ Name : defaultPVCName ,
182194 Namespace : instance .GetNamespace (),
183195 Labels : metadata .Label (instance .Name ),
184196 Annotations : metadata .ReconcileAndFilterAnnotations (map [string ]string {}, instance .Annotations ),
@@ -275,7 +287,7 @@ func sortVolumeMounts(mounts []corev1.VolumeMount) {
275287 mounts [0 ], mounts [i ] = mounts [i ], mounts [0 ]
276288 continue
277289 }
278- if m .Name == "persistence" {
290+ if m .Name == defaultPVCName {
279291 mounts [1 ], mounts [i ] = mounts [i ], mounts [1 ]
280292 }
281293 }
0 commit comments