Skip to content

Commit

Permalink
try fixing nfs mount opts
Browse files Browse the repository at this point in the history
  • Loading branch information
QcFe committed May 9, 2024
1 parent af2c10b commit cfd02e5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion operators/pkg/forge/cloudinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func CloudInitUserData(nfsServerName, nfsPath string, publicKeys []string) ([]by
fmt.Sprintf("%s:%s", nfsServerName, nfsPath),
MyDriveVolumeMountPath,
"nfs",
"rw,tcp,hard,intr,rsize=8192,wsize=8192,timeo=14",
"rw,tcp,hard,intr,rsize=8192,wsize=8192,timeo=14,_netdev,user",
"0",
"0",
}}
Expand Down
2 changes: 1 addition & 1 deletion operators/pkg/forge/cloudinit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mounts:
- - rook-ceph-nfs-my-nfs-a.rook-ceph.svc.cluster.local:/path
- /media/mydrive
- nfs
- rw,tcp,hard,intr,rsize=8192,wsize=8192,timeo=14
- rw,tcp,hard,intr,rsize=8192,wsize=8192,timeo=14,all_squash,anonuid=1000,anongid=1000
- "0"
- "0"
ssh_authorized_keys:
Expand Down
3 changes: 3 additions & 0 deletions operators/pkg/instctrl/cloudinit-startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
mkdir -p $NFSPATH
chown 1000:1000 $NFSPATH
10 changes: 9 additions & 1 deletion operators/pkg/instctrl/cloudinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package instctrl

import (
"bytes"
"context"
_ "embed"
"fmt"

corev1 "k8s.io/api/core/v1"
Expand All @@ -41,6 +43,9 @@ const (
UserDataKey = "userdata"
)

//go:embed cloudinit-startup.sh
var scriptdata []byte

// EnforceCloudInitSecret enforces the creation/update of a secret containing the cloud-init configuration,
// based on the information retrieved for the tenant object and its associated WebDav credentials.
func (r *InstanceReconciler) EnforceCloudInitSecret(ctx context.Context) error {
Expand Down Expand Up @@ -71,12 +76,15 @@ func (r *InstanceReconciler) EnforceCloudInitSecret(ctx context.Context) error {
log.Error(err, "unable to marshal secret content")
return err
}

userScriptData := bytes.ReplaceAll(scriptdata, []byte("$NFSPATH"), []byte(forge.MyDriveVolumeMountPath))

// Enforce the cloud-init secret presence.
instance := clctx.InstanceFrom(ctx)
secret := corev1.Secret{ObjectMeta: forge.ObjectMeta(instance)}
res, err := ctrl.CreateOrUpdate(ctx, r.Client, &secret, func() error {
secret.SetLabels(forge.InstanceObjectLabels(secret.GetLabels(), instance))
secret.Data = map[string][]byte{UserDataKey: userdata}
secret.Data = map[string][]byte{UserDataKey: userdata, "x-shellscript": userScriptData}
secret.Type = corev1.SecretTypeOpaque
return ctrl.SetControllerReference(instance, &secret, r.Scheme)
})
Expand Down

0 comments on commit cfd02e5

Please sign in to comment.