22
22
23
23
type freenasProvisionerConfig struct {
24
24
// common params
25
- FSType string
25
+ FSType string
26
+ ReclaimPolicy * v1.PersistentVolumeReclaimPolicy
26
27
27
28
// Provisioner options
28
29
ProvisionerRollbackPartialFailures bool
@@ -41,6 +42,11 @@ type freenasProvisionerConfig struct {
41
42
TargetGroupInitiatorgroup int
42
43
TargetGroupPortalgroup int
43
44
45
+ // Authentication options
46
+ DiscoveryCHAPAuth bool
47
+ SessionCHAPAuth bool
48
+ AuthSecretRef * v1.SecretReference
49
+
44
50
// Zvol options
45
51
ZvolCompression string
46
52
ZvolDedup string
@@ -93,6 +99,13 @@ func (p *freenasProvisioner) GetConfig(storageClassName string) (*freenasProvisi
93
99
var targetGroupInitiatorgroup int
94
100
var targetGroupPortalgroup int
95
101
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
+
96
109
// zvol defaults
97
110
var zvolCompression string
98
111
var zvolDedup string
@@ -153,6 +166,16 @@ func (p *freenasProvisioner) GetConfig(storageClassName string) (*freenasProvisi
153
166
case "targetGroupPortalgroup" :
154
167
targetGroupPortalgroup , _ = strconv .Atoi (v )
155
168
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
+
156
179
// Zvol options
157
180
case "zvolCompression" :
158
181
zvolCompression = v
@@ -216,8 +239,16 @@ func (p *freenasProvisioner) GetConfig(storageClassName string) (*freenasProvisi
216
239
provisionerTargetPortal = serverHost + ":3260"
217
240
}
218
241
242
+ if targetDiscoveryCHAPAuth || targetSessionCHAPAuth {
243
+ authSecretRef = & v1.SecretReference {
244
+ Namespace : authSecretNamespace ,
245
+ Name : authSecretName ,
246
+ }
247
+ }
248
+
219
249
return & freenasProvisionerConfig {
220
- FSType : fsType ,
250
+ FSType : fsType ,
251
+ ReclaimPolicy : class .ReclaimPolicy ,
221
252
222
253
// Provisioner options
223
254
ProvisionerRollbackPartialFailures : provisionerRollbackPartialFailures ,
@@ -236,6 +267,11 @@ func (p *freenasProvisioner) GetConfig(storageClassName string) (*freenasProvisi
236
267
TargetGroupInitiatorgroup : targetGroupInitiatorgroup ,
237
268
TargetGroupPortalgroup : targetGroupPortalgroup ,
238
269
270
+ // Authentication options
271
+ DiscoveryCHAPAuth : targetDiscoveryCHAPAuth ,
272
+ SessionCHAPAuth : targetSessionCHAPAuth ,
273
+ AuthSecretRef : authSecretRef ,
274
+
239
275
// Zvol options
240
276
ZvolCompression : zvolCompression ,
241
277
ZvolDedup : zvolDedup ,
@@ -554,7 +590,7 @@ func (p *freenasProvisioner) Provision(options controller.VolumeOptions) (*v1.Pe
554
590
},
555
591
},
556
592
Spec : v1.PersistentVolumeSpec {
557
- PersistentVolumeReclaimPolicy : options . PersistentVolumeReclaimPolicy ,
593
+ PersistentVolumeReclaimPolicy : * config . ReclaimPolicy ,
558
594
AccessModes : options .PVC .Spec .AccessModes ,
559
595
Capacity : v1.ResourceList {
560
596
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
563
599
VolumeMode : options .PVC .Spec .VolumeMode ,
564
600
PersistentVolumeSource : v1.PersistentVolumeSource {
565
601
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 ,
576
612
},
577
613
},
578
614
},
0 commit comments