Skip to content

Commit 2bafa24

Browse files
refactor: add authKrbConf mount parameter
allows an end user to specify a secret which contains contents of a kerberos 5 configuration file that specifies how to connect to one or more realms
1 parent f634818 commit 2bafa24

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ install-nfs-server:
133133
kubectl apply -f ./deploy/example/nfs-provisioner/nfs-server.yaml
134134
kubectl apply -f ./deploy/example/nfs-provisioner/nfs-krb-server.yaml
135135
kubectl delete secret mount-options -n default --ignore-not-found
136-
kubectl create secret generic mount-options --from-literal mountOptions="nfsvers=4.1" --from-literal krb-pwd='password!' -n default
136+
kubectl create secret generic mount-options --from-literal mountOptions="nfsvers=4.1" --from-literal krb-pwd='password!' --from-file=krb5.conf=./test/krb5.conf -n default
137137

138138
.PHONY: install-helm
139139
install-helm:

pkg/nfs/nodeserver.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
7070
}
7171

7272
var server, baseDir, subDir string
73-
var krbPwd, krbPrinc string
73+
var krbPwd, krbPrinc, krbConf string
7474
subDirReplaceMap := map[string]string{}
7575

7676
mountPermissions := ns.Driver.mountPermissions
@@ -88,6 +88,10 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
8888
if v != "" {
8989
krbPwd = req.GetSecrets()[v]
9090
}
91+
case paramKrbConf:
92+
if v != "" {
93+
krbConf = req.GetSecrets()[v]
94+
}
9195
case pvcNamespaceKey:
9296
subDirReplaceMap[pvcNamespaceMetadata] = v
9397
case pvcNameKey:
@@ -138,7 +142,10 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
138142
if !notMnt {
139143
return &csi.NodePublishVolumeResponse{}, nil
140144
}
141-
145+
146+
if krbConf != "" {
147+
os.WriteFile("/etc/krb5.conf", []byte(krbConf), 0775)
148+
}
142149
klog.V(2).Infof("NodePublishVolume: volumeID(%v) source(%s) targetPath(%s) mountflags(%v)", volumeID, source, targetPath, mountOptions)
143150
execFunc := func() error {
144151
if krbPrinc != "" && krbPwd != "" {

test/e2e/e2e_suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ var (
9898
"csi.storage.k8s.io/provisioner-secret-namespace": "default",
9999
"csi.storage.k8s.io/provisioner-secret-name": "mount-options",
100100
"mountPermissions": "0755",
101+
"authKrbConf": "krb5.conf",
101102
"authPasswordSecret": "krb-pwd",
102103
"authPrincipal": "nfs/nfs-krb-server.default.svc.cluster.local@NFS-KRB-SERVER.DEFAULT.SVC.CLUSTER.LOCAL",
103104
}

test/krb5.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[libdefaults]
2+
default_realm = NFS-KRB-SERVER.DEFAULT.SVC.CLUSTER.LOCAL
3+
4+
[realms]
5+
NFS-KRB-SERVER.DEFAULT.SVC.CLUSTER.LOCAL = {
6+
tkdc = nfs-krb-server.default.svc.cluster.local
7+
tadmin_server = nfs-krb-server.default.svc.cluster.local
8+
}
9+
10+
[logging]
11+
kdc = FILE:/var/log/krb5kdc.log
12+
admin_server = FILE:/var/log/kadmin.log
13+
default = FILE:/var/log/krb5lib.log

0 commit comments

Comments
 (0)