diff --git a/Documentation/CRDs/ceph-nfs-crd.md b/Documentation/CRDs/ceph-nfs-crd.md index c1c4add25..23df9eb20 100644 --- a/Documentation/CRDs/ceph-nfs-crd.md +++ b/Documentation/CRDs/ceph-nfs-crd.md @@ -55,6 +55,7 @@ spec: security: kerberos: principalName: "nfs" + domainName: "DOMAIN1.EXAMPLE.COM" configFiles: volumeSource: @@ -114,6 +115,11 @@ The `security` spec sets security configuration for the NFS cluster. determine the full service principal name: `/-@`. e.g., nfs/rook-ceph-my-nfs@example.net. For full details, see the [NFS security doc](../Storage-Configuration/NFS/nfs-security.md#nfs-service-principals). + * `domainName`: this is the domain name used in the kerberos credentials. This is used to + configure idmap to map the kerberos credentials to uid/gid. Without this configured, NFS-Ganesha + will use the anonuid/anongid configured (default: -2) when accessing the local filesystem. + eg., DOMAIN1.EXAMPLE.COM. + [NFS security doc](../Storage-Configuration/NFS/nfs-security.md#kerberos-domain-name). * `configFiles`: defines where the Kerberos configuration should be sourced from. Config files will be placed into the `/etc/krb5.conf.rook/` directory. For advanced usage, see the [NFS security doc](../Storage-Configuration/NFS/nfs-security.md#kerberos-configuration). diff --git a/Documentation/CRDs/specification.md b/Documentation/CRDs/specification.md index 651c51f97..df17be2f2 100644 --- a/Documentation/CRDs/specification.md +++ b/Documentation/CRDs/specification.md @@ -6440,6 +6440,18 @@ See https:/ +domainName
+ +string + + + +(Optional) +

DomainName should be set to the Kerberos Realm.

+ + + + configFiles
@@ -11042,5 +11054,5 @@ string

Generated with gen-crd-api-reference-docs -on git commit f8f8a3375. +on git commit ff431de56.

diff --git a/Documentation/Storage-Configuration/NFS/nfs-security.md b/Documentation/Storage-Configuration/NFS/nfs-security.md index 2eea4fcb7..0148bb8e8 100644 --- a/Documentation/Storage-Configuration/NFS/nfs-security.md +++ b/Documentation/Storage-Configuration/NFS/nfs-security.md @@ -102,6 +102,8 @@ authenticate to the Kerberos server (KDC). The requirements are two-parted: 2. a keytab file that provides credentials for the [service principal](#nfs-service-principals) that NFS-Ganesha will use to authenticate with the Kerberos server. +3. a kerberos domain name which will be used to map kerberos credentials to uid/gid + [domain name](#kerberos-domain-name) that NFS-Ganesha will use to authenticate with the Methods of providing the configuration files are documented in the [NFS CRD security section](../../CRDs/ceph-nfs-crd.md#security). @@ -163,3 +165,10 @@ Users must add this service principal to their Kerberos server configuration. `spec.security.kerberos.principalName` corresponds directly to NFS-Ganesha's NFS_KRB5:PrincipalName config. See the [NFS-Ganesha wiki](https://github.com/nfs-ganesha/nfs-ganesha/wiki/RPCSEC_GSS) for more details. + +#### Kerberos domain name + +The kerberos domain name is used to setup the domain name in /etc/idmapd.conf. This domain name is used +by idmap to map the kerberos credential to the user uid/gid. Without this configured, NFS-Ganesha will +be unable to map the Kerberos principal to an uid/gid and will instead use the configured +anonuid/anongid (default: -2) when accessing the local filesystem. diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml index cacd1ee5d..e9070b79f 100644 --- a/deploy/charts/rook-ceph/templates/resources.yaml +++ b/deploy/charts/rook-ceph/templates/resources.yaml @@ -7312,6 +7312,9 @@ spec: type: object type: object type: object + domainName: + description: DomainName should be set to the Kerberos Realm. + type: string keytabFile: description: KeytabFile defines where the Kerberos keytab should be sourced from. The keytab file will be placed into `/etc/krb5.keytab`. If this is left empty, Rook will not add the file. This allows you to manage the `krb5.keytab` file yourself however you wish. For example, you may build it into your custom Ceph container image or use the Vault agent injector to securely add the file via annotations on the CephNFS spec (passed to the NFS server pods). properties: diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml index 96358b557..954045e16 100644 --- a/deploy/examples/crds.yaml +++ b/deploy/examples/crds.yaml @@ -7306,6 +7306,9 @@ spec: type: object type: object type: object + domainName: + description: DomainName should be set to the Kerberos Realm. + type: string keytabFile: description: KeytabFile defines where the Kerberos keytab should be sourced from. The keytab file will be placed into `/etc/krb5.keytab`. If this is left empty, Rook will not add the file. This allows you to manage the `krb5.keytab` file yourself however you wish. For example, you may build it into your custom Ceph container image or use the Vault agent injector to securely add the file via annotations on the CephNFS spec (passed to the NFS server pods). properties: diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index 8087b8088..f1b107357 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -2097,6 +2097,10 @@ type KerberosSpec struct { // +kubebuilder:default="nfs" PrincipalName string `json:"principalName"` + // DomainName should be set to the Kerberos Realm. + // +optional + DomainName string `json:"domainName"` + // ConfigFiles defines where the Kerberos configuration should be sourced from. Config files // will be placed into the `/etc/krb5.conf.rook/` directory. // diff --git a/pkg/operator/ceph/nfs/security.go b/pkg/operator/ceph/nfs/security.go index d3ed8cd0e..222904516 100644 --- a/pkg/operator/ceph/nfs/security.go +++ b/pkg/operator/ceph/nfs/security.go @@ -72,12 +72,14 @@ func addSSSDConfigsToPod(r *ReconcileCephNFS, nfs *cephv1.CephNFS, pod *v1.PodSp } func addKerberosConfigsToPod(r *ReconcileCephNFS, nfs *cephv1.CephNFS, pod *v1.PodSpec) { - init, volume, ganeshaMount := generateKrbConfResources(r, nfs) + init, volume, ganeshaMounts := generateKrbConfResources(r, nfs) pod.InitContainers = append(pod.InitContainers, *init) pod.Volumes = append(pod.Volumes, *volume) // assume the first container is the NFS-Ganesha container - pod.Containers[0].VolumeMounts = append(pod.Containers[0].VolumeMounts, *ganeshaMount) + for _, m := range ganeshaMounts { + pod.Containers[0].VolumeMounts = append(pod.Containers[0].VolumeMounts, *m) + } configVolSrc := nfs.Spec.Security.Kerberos.ConfigFiles.VolumeSource if configVolSrc != nil { @@ -187,9 +189,10 @@ ls --all --recursive /tmp/var/lib/sss/pipes`, func generateKrbConfResources(r *ReconcileCephNFS, nfs *cephv1.CephNFS) ( init *v1.Container, volume *v1.Volume, // add these volumes to the pod - ganeshaMount *v1.VolumeMount, // add these volume mounts to the nfs-ganesha container + ganeshaMounts []*v1.VolumeMount, // add these volume mounts to the nfs-ganesha container ) { generatedKrbConfVolName := "generated-krb5-conf" + kerberosDomainName := nfs.Spec.Security.Kerberos.DomainName volume = &v1.Volume{ Name: generatedKrbConfVolName, @@ -197,11 +200,29 @@ func generateKrbConfResources(r *ReconcileCephNFS, nfs *cephv1.CephNFS) ( EmptyDir: &v1.EmptyDirVolumeSource{}, }, } - ganeshaMount = &v1.VolumeMount{ + krbConfMount := &v1.VolumeMount{ Name: generatedKrbConfVolName, MountPath: "/etc/krb5.conf", SubPath: "krb5.conf", } + ganeshaMounts = append(ganeshaMounts, krbConfMount) + + domainNameCommand := "" + domainName := nfs.Spec.Security.Kerberos.DomainName + if domainName != "" { + domainNameCommand = ` +cat << EOF > /tmp/etc/idmapd.conf +[General] +Domain = ` + kerberosDomainName + ` +EOF +cat /etc/idmapd.conf` + idmapdConfMount := &v1.VolumeMount{ + Name: generatedKrbConfVolName, + MountPath: "/etc/idmapd.conf", + SubPath: "idmapd.conf", + } + ganeshaMounts = append(ganeshaMounts, idmapdConfMount) + } // the init container is needed to copy the starting content from the /var/lib/sss/pipes // directory into the shared sockets dir so that SSSD has the content it needs to start up @@ -216,7 +237,8 @@ default = STDERR includedir /etc/krb5.conf.rook/ EOF -cat /tmp/etc/krb5.conf`, +cat /tmp/etc/krb5.conf +` + domainNameCommand, }, VolumeMounts: []v1.VolumeMount{ {Name: generatedKrbConfVolName, MountPath: "/tmp/etc"}, @@ -225,7 +247,7 @@ cat /tmp/etc/krb5.conf`, Resources: nfs.Spec.Server.Resources, } - return init, volume, ganeshaMount + return init, volume, ganeshaMounts } func sssdConfigVolAndMount(volSource v1.VolumeSource) (v1.Volume, v1.VolumeMount) {