@@ -549,22 +549,31 @@ type PodSpec struct {
549
549
// Deprecated: Use ServiceExpose.Labels instead
550
550
ReplicasServiceLabels map [string ]string `json:"replicasServiceLabels,omitempty"`
551
551
552
- SchedulerName string `json:"schedulerName,omitempty"`
553
- ReadinessInitialDelaySeconds * int32 `json:"readinessDelaySec,omitempty"`
554
- ReadinessProbes corev1.Probe `json:"readinessProbes,omitempty"`
555
- LivenessInitialDelaySeconds * int32 `json:"livenessDelaySec,omitempty"`
556
- LivenessProbes corev1.Probe `json:"livenessProbes,omitempty"`
557
- PodSecurityContext * corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
558
- ContainerSecurityContext * corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
559
- ServiceAccountName string `json:"serviceAccountName,omitempty"`
560
- ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
561
- Sidecars []corev1.Container `json:"sidecars,omitempty"`
562
- SidecarVolumes []corev1.Volume `json:"sidecarVolumes,omitempty"`
563
- SidecarPVCs []corev1.PersistentVolumeClaim `json:"sidecarPVCs,omitempty"`
564
- RuntimeClassName * string `json:"runtimeClassName,omitempty"`
565
- HookScript string `json:"hookScript,omitempty"`
566
- Lifecycle corev1.Lifecycle `json:"lifecycle,omitempty"`
567
- TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
552
+ SchedulerName string `json:"schedulerName,omitempty"`
553
+ ReadinessInitialDelaySeconds * int32 `json:"readinessDelaySec,omitempty"`
554
+ ReadinessProbes corev1.Probe `json:"readinessProbes,omitempty"`
555
+ LivenessInitialDelaySeconds * int32 `json:"livenessDelaySec,omitempty"`
556
+ LivenessProbes corev1.Probe `json:"livenessProbes,omitempty"`
557
+ PodSecurityContext * corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
558
+ ContainerSecurityContext * corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
559
+ ServiceAccountName string `json:"serviceAccountName,omitempty"`
560
+ ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
561
+ Sidecars []corev1.Container `json:"sidecars,omitempty"`
562
+ SidecarVolumes []corev1.Volume `json:"sidecarVolumes,omitempty"`
563
+ // +kubebuilder:validation:items:XEmbeddedResource
564
+ SidecarPVCs []corev1.PersistentVolumeClaim `json:"sidecarPVCs,omitempty"`
565
+ RuntimeClassName * string `json:"runtimeClassName,omitempty"`
566
+ HookScript string `json:"hookScript,omitempty"`
567
+ Lifecycle corev1.Lifecycle `json:"lifecycle,omitempty"`
568
+ TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
569
+ ExtraPVCs []ExtraPVC `json:"extraPVCs,omitempty"`
570
+ }
571
+
572
+ type ExtraPVC struct {
573
+ // +kubebuilder:validation:EmbeddedResource
574
+ VolumeClaimTemplate corev1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
575
+ MountPath string `json:"mountPath,omitempty"`
576
+ ReadOnly * bool `json:"readOnly,omitempty"`
568
577
}
569
578
570
579
func (spec * PodSpec ) HasSidecarInternalSecret (secret * corev1.Secret ) bool {
@@ -1568,6 +1577,56 @@ func AddSidecarPVCs(log logr.Logger, existing, sidecarPVCs []corev1.PersistentVo
1568
1577
return existing
1569
1578
}
1570
1579
1580
+ func AddExtraVolumeMounts (log logr.Logger , existing []corev1.VolumeMount , extraPVCs []ExtraPVC ) []corev1.VolumeMount {
1581
+ if len (extraPVCs ) == 0 {
1582
+ return existing
1583
+ }
1584
+
1585
+ names := make (map [string ]struct {}, len (existing ))
1586
+ for _ , v := range existing {
1587
+ names [v .Name ] = struct {}{}
1588
+ }
1589
+
1590
+ for _ , v := range extraPVCs {
1591
+ name := v .VolumeClaimTemplate .GetName ()
1592
+ if _ , ok := names [name ]; ok {
1593
+ log .Info ("Volume name already exists, it is skipped" , "volumeName" , name )
1594
+ continue
1595
+ }
1596
+
1597
+ existing = append (existing , corev1.VolumeMount {
1598
+ Name : name ,
1599
+ MountPath : v .MountPath ,
1600
+ ReadOnly : * v .ReadOnly ,
1601
+ })
1602
+ }
1603
+
1604
+ return existing
1605
+ }
1606
+
1607
+ func AddExtraPVCs (log logr.Logger , existing []corev1.PersistentVolumeClaim , extraPVCs []ExtraPVC ) []corev1.PersistentVolumeClaim {
1608
+ if len (extraPVCs ) == 0 {
1609
+ return existing
1610
+ }
1611
+
1612
+ names := make (map [string ]struct {}, len (existing ))
1613
+ for _ , p := range existing {
1614
+ names [p .Name ] = struct {}{}
1615
+ }
1616
+
1617
+ for _ , p := range extraPVCs {
1618
+ name := p .VolumeClaimTemplate .GetName ()
1619
+ if _ , ok := names [name ]; ok {
1620
+ log .Info ("PVC name already exists, it is skipped" , "PVCName" , name )
1621
+ continue
1622
+ }
1623
+
1624
+ existing = append (existing , p .VolumeClaimTemplate )
1625
+ }
1626
+
1627
+ return existing
1628
+ }
1629
+
1571
1630
func (cr * PerconaXtraDBCluster ) ProxySQLUnreadyServiceNamespacedName () types.NamespacedName {
1572
1631
return types.NamespacedName {
1573
1632
Name : cr .Name + "-proxysql-unready" ,
0 commit comments