2222
2323type freenasProvisionerConfig struct {
2424 // common params
25- FSType string
25+ FSType string
26+ ReclaimPolicy * v1.PersistentVolumeReclaimPolicy
2627
2728 // Provisioner options
2829 ProvisionerRollbackPartialFailures bool
@@ -41,6 +42,11 @@ type freenasProvisionerConfig struct {
4142 TargetGroupInitiatorgroup int
4243 TargetGroupPortalgroup int
4344
45+ // Authentication options
46+ DiscoveryCHAPAuth bool
47+ SessionCHAPAuth bool
48+ AuthSecretRef * v1.SecretReference
49+
4450 // Zvol options
4551 ZvolCompression string
4652 ZvolDedup string
@@ -93,6 +99,13 @@ func (p *freenasProvisioner) GetConfig(storageClassName string) (*freenasProvisi
9399 var targetGroupInitiatorgroup int
94100 var targetGroupPortalgroup int
95101
102+ // Authentication options
103+ var targetDiscoveryCHAPAuth = false
104+ var targetSessionCHAPAuth = false
105+ var authSecretNamespace = "kube-system"
106+ var authSecretName = "freenas-iscsi-chap"
107+ var authSecretRef * v1.SecretReference
108+
96109 // zvol defaults
97110 var zvolCompression string
98111 var zvolDedup string
@@ -153,6 +166,16 @@ func (p *freenasProvisioner) GetConfig(storageClassName string) (*freenasProvisi
153166 case "targetGroupPortalgroup" :
154167 targetGroupPortalgroup , _ = strconv .Atoi (v )
155168
169+ // Authentication options
170+ case "targetDiscoveryCHAPAuth" :
171+ targetDiscoveryCHAPAuth , _ = strconv .ParseBool (v )
172+ case "targetSessionCHAPAuth" :
173+ targetSessionCHAPAuth , _ = strconv .ParseBool (v )
174+ case "authSecretNamespace" :
175+ authSecretNamespace = v
176+ case "authSecretName" :
177+ authSecretName = v
178+
156179 // Zvol options
157180 case "zvolCompression" :
158181 zvolCompression = v
@@ -216,8 +239,16 @@ func (p *freenasProvisioner) GetConfig(storageClassName string) (*freenasProvisi
216239 provisionerTargetPortal = serverHost + ":3260"
217240 }
218241
242+ if targetDiscoveryCHAPAuth || targetSessionCHAPAuth {
243+ authSecretRef = & v1.SecretReference {
244+ Namespace : authSecretNamespace ,
245+ Name : authSecretName ,
246+ }
247+ }
248+
219249 return & freenasProvisionerConfig {
220- FSType : fsType ,
250+ FSType : fsType ,
251+ ReclaimPolicy : class .ReclaimPolicy ,
221252
222253 // Provisioner options
223254 ProvisionerRollbackPartialFailures : provisionerRollbackPartialFailures ,
@@ -236,6 +267,11 @@ func (p *freenasProvisioner) GetConfig(storageClassName string) (*freenasProvisi
236267 TargetGroupInitiatorgroup : targetGroupInitiatorgroup ,
237268 TargetGroupPortalgroup : targetGroupPortalgroup ,
238269
270+ // Authentication options
271+ DiscoveryCHAPAuth : targetDiscoveryCHAPAuth ,
272+ SessionCHAPAuth : targetSessionCHAPAuth ,
273+ AuthSecretRef : authSecretRef ,
274+
239275 // Zvol options
240276 ZvolCompression : zvolCompression ,
241277 ZvolDedup : zvolDedup ,
@@ -554,7 +590,7 @@ func (p *freenasProvisioner) Provision(options controller.VolumeOptions) (*v1.Pe
554590 },
555591 },
556592 Spec : v1.PersistentVolumeSpec {
557- PersistentVolumeReclaimPolicy : options . PersistentVolumeReclaimPolicy ,
593+ PersistentVolumeReclaimPolicy : * config . ReclaimPolicy ,
558594 AccessModes : options .PVC .Spec .AccessModes ,
559595 Capacity : v1.ResourceList {
560596 v1 .ResourceName (v1 .ResourceStorage ): options .PVC .Spec .Resources .Requests [v1 .ResourceName (v1 .ResourceStorage )],
@@ -563,16 +599,16 @@ func (p *freenasProvisioner) Provision(options controller.VolumeOptions) (*v1.Pe
563599 VolumeMode : options .PVC .Spec .VolumeMode ,
564600 PersistentVolumeSource : v1.PersistentVolumeSource {
565601 ISCSI : & v1.ISCSIPersistentVolumeSource {
566- TargetPortal : config .ProvisionerTargetPortal ,
567- Portals : portals ,
568- IQN : iscsiConfig .Basename + ":" + iscsiName ,
569- ISCSIInterface : config .ProvisionerISCSIInterface ,
570- Lun : int32 (* targetToExtent .Lunid ),
571- ReadOnly : extent .Ro ,
572- FSType : config .FSType ,
573- // DiscoveryCHAPAuth: false ,
574- // SessionCHAPAuth: false ,
575- // SecretRef: getSecretRef(getBool(options.Parameters["chapAuthDiscovery"]), getBool(options.Parameters["chapAuthSession"]), &v1.SecretReference{Name: viper.GetString("provisioner-name") + "-chap-secret"}) ,
602+ TargetPortal : config .ProvisionerTargetPortal ,
603+ Portals : portals ,
604+ IQN : iscsiConfig .Basename + ":" + iscsiName ,
605+ ISCSIInterface : config .ProvisionerISCSIInterface ,
606+ Lun : int32 (* targetToExtent .Lunid ),
607+ ReadOnly : extent .Ro ,
608+ FSType : config .FSType ,
609+ DiscoveryCHAPAuth : config . DiscoveryCHAPAuth ,
610+ SessionCHAPAuth : config . SessionCHAPAuth ,
611+ SecretRef : config . AuthSecretRef ,
576612 },
577613 },
578614 },
0 commit comments