Merge pull request #12220 from spuiuk/krb5-fixes-2
nfs: Add Spec.Security.Kerberos.DomainName to the CRD to configure /etc/idmapd.conf
This commit is contained in:
7 files changed
+66
-7
No files matched your search
@@ -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: `<principalName>/<namespace>-<name>@<realm>`.
|
||||
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).
|
||||
|
||||
@@ -6440,6 +6440,18 @@ See <a href="https://github.com/nfs-ganesha/nfs-ganesha/wiki/RPCSEC_GSS">https:/
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>domainName</code><br/>
|
||||
<em>
|
||||
string
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
<em>(Optional)</em>
|
||||
<p>DomainName should be set to the Kerberos Realm.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>configFiles</code><br/>
|
||||
<em>
|
||||
<a href="#ceph.rook.io/v1.KerberosConfigFiles">
|
||||
@@ -11042,5 +11054,5 @@ string
|
||||
<hr/>
|
||||
<p><em>
|
||||
Generated with <code>gen-crd-api-reference-docs</code>
|
||||
on git commit <code>f8f8a3375</code>.
|
||||
on git commit <code>ff431de56</code>.
|
||||
</em></p>
|
||||
@@ -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.
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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.
|
||||
//
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user