From d7231119a87c3048d70b0a2ba02c75e3a2c1056a Mon Sep 17 00:00:00 2001 From: Frank Hsiao Date: Mon, 28 Apr 2025 04:14:23 +0000 Subject: [PATCH] feat: add support for setting SC for state pvc Add a new field statePVSCName in SmbCommonConfig.spec that allows users to specify StorageClass for Samba StatefulSet's state PVC. If not set, state PVC uses default StorageClass as before. Signed-off-by: FTS152 --- api/v1alpha1/smbcommonconfig_types.go | 5 +++++ .../crd/bases/samba-operator.samba.org_smbcommonconfigs.yaml | 3 +++ internal/resources/getters.go | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/api/v1alpha1/smbcommonconfig_types.go b/api/v1alpha1/smbcommonconfig_types.go index 42f11849..b3d9bcfb 100644 --- a/api/v1alpha1/smbcommonconfig_types.go +++ b/api/v1alpha1/smbcommonconfig_types.go @@ -38,6 +38,11 @@ type SmbCommonConfigSpec struct { // under PodSettings allow admins and users to customize how pods // are scheduled in a kubernetes cluster. PodSettings *SmbCommonConfigPodSettings `json:"podSettings,omitempty"` + + // StateSCName specifies which StorageClass is to be used for this share. + // If left empty, the operator's default will be used. + // +optional + StatePVSCName string `json:"statePVSCName,omitempty"` } // SmbCommonNetworkSpec values define networking properties for the services diff --git a/config/crd/bases/samba-operator.samba.org_smbcommonconfigs.yaml b/config/crd/bases/samba-operator.samba.org_smbcommonconfigs.yaml index feb8b40c..d22b701d 100644 --- a/config/crd/bases/samba-operator.samba.org_smbcommonconfigs.yaml +++ b/config/crd/bases/samba-operator.samba.org_smbcommonconfigs.yaml @@ -510,6 +510,9 @@ spec: description: NodeSelector values will be assigned to a PodSpec's NodeSelector. type: object type: object + statePVSCName: + description: StateSCName specifies which StorageClass is to be used for this share. If left empty, the operator's default will be used. + type: string type: object status: description: SmbCommonConfigStatus defines the observed state of SmbCommonConfig diff --git a/internal/resources/getters.go b/internal/resources/getters.go index 609da723..e848061d 100644 --- a/internal/resources/getters.go +++ b/internal/resources/getters.go @@ -119,6 +119,11 @@ func (m *SmbShareManager) getOrCreateStatePVC( }, }, } + + if planner.CommonConfig.Spec.StatePVSCName != "" { + spec.StorageClassName = &planner.CommonConfig.Spec.StatePVSCName + } + pvc, cr, err := m.getOrCreateGenericPVC( ctx, planner.SmbShare, spec, name, ns) if err != nil {