Difference between revisions of "Tutorials:Mount cifs storage in a pod"

From Collective Computational Unit
Jump to navigation Jump to search
(Adding your mounting option in your pod)
Line 91: Line 91:
 
         options:
 
         options:
 
           networkPath: "//timon.cascb.uni-konstanz.de/<Your-Storage-Folder>"  # Storage address, here assumed to be part of your DMP
 
           networkPath: "//timon.cascb.uni-konstanz.de/<Your-Storage-Folder>"  # Storage address, here assumed to be part of your DMP
           mountOptions: "vers=3.0,dir_mode=0755,file_mode=0644,noperm"
+
           mountOptions: "vers=3.0,dir_mode=0755,file_mode=0644,noperm,domain=CASCB"
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 06:20, 30 April 2025

Overview

If you have a Data Management Plan (DMP), or you have access to a custom CIFS (SMB, Samba, Windows Share) storage you want to mount in a pod please follow the steps below

Convert your credentials to base64 encoding

In a terminal type:

echo -n "<Your_CIFS_Username>" | base64
$ PFlvdXJfQ0lGU19Vc2VybmFtZT4=
echo -n "<Your_CIFS_Password" | base64
$ PFlvdXJfQ0lGU19QYXNzd29yZA==

Note that the output shown here is literally for the example used

Create a secret containing your credentials to the storage

Having your credentials encoded in base 64, you can create a cifs_secret.yaml like shown below:

apiVersion: v1
kind: Secret
metadata:
  name: cifs-secret
  namespace: user-<your-username>
type: fstab/cifs
data:
  username: 'PFlvdXJfQ0lGU19Vc2VybmFtZT4='
  password: 'PFlvdXJfQ0lGU19QYXNzd29yZA=='

You can then type:

kubectl create secret -f secret.yaml

Adding your mounting option in your pod

Reusing our standard example of pod, we have to modify the section volumeMounts and Volumes in our pod creation file:

apiVersion: v1
kind: Pod
metadata:
  name: busybox-test-pod
spec:
  containers:
  - name: busybox
    image: ccu-k8s.inf.uni-konstanz.de:32250/<your.username>/my_busybox # example of when we hosted our own image in the CCU repository
    command: ["sleep", "1d"]
    resources:
      requests:
        cpu: 100m
        memory: 100Mi
      limits:
        cpu: 1
        memory: 1Gi
    volumeMounts:
      - mountPath: /abyss/home
        name: cephfs-home
        readOnly: false
      - mountPath: /abyss/shared
        name: cephfs-shared
        readOnly: false
      - mountPath: /abyss/datasets
        name: cephfs-datasets
        readOnly: true
      - mountPath: "/abyss/home/<your-already-created-mount-location-folder>" ## Add here location of where to mount the storage
        name: samba-share
        readOnly: false
  imagePullSecrets:                     
  - name: <A_Name_For_Your_Secret>      ## Secret for accessing the CCU repository
  volumes:
    - name: cephfs-home
      hostPath:
        path: "/cephfs/abyss/home/<your-username>"
        type: Directory
    - name: cephfs-shared
      hostPath:
        path: "/cephfs/abyss/shared"
        type: Directory
    - name: cephfs-datasets
      hostPath:
        path: "/cephfs/abyss/datasets"
        type: Directory
    - name: samba-share  ## Details of the source of the storage to be mounted 
      flexVolume:
        driver: "fstab/cifs"
        fsType: "cifs"
        secretRef:
          name: "cifs-secret"
        options:
          networkPath: "//timon.cascb.uni-konstanz.de/<Your-Storage-Folder>"  # Storage address, here assumed to be part of your DMP
          mountOptions: "vers=3.0,dir_mode=0755,file_mode=0644,noperm,domain=CASCB"

Checking if everything was mounted properly

Check the status of the pod with

kubectl describe pods busybox-test-pod

And when accessing your pod, your cifs storage should be mounted at:

/abyss/home/<your-already-created-mount-location-folder>