[Kubernetes] Install CSI Driver SMB(v1.15.0) for Kubernetes Using Helm Chart

Helm 설치 및 설명 참고 {: .prompt-info }

Install CSI Driver SMB #

1helm repo add csi-driver-smb https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/charts
2helm repo update
3helm install csi-driver-smb csi-driver-smb/csi-driver-smb --version 1.15.0

CSI Driver SMB - Helm 설치 참고

Customize Default Configuration #

Install Customize Default Configuration #

1helm install [RELEASE NAME] [Chart.yaml 경로] -f [YAML 파일 또는 URL에 값 지정 (여러 개를 지정가능)] -n [NAMESPACE NAME]
1helm install csi-driver-smb csi-driver-smb/csi-driver-smb -f override-values.yaml -n [NAMESPACE NAME]

Test #

1. Namespace 생성 #

1kubectl create ns smb-test

2. Secret 생성 #

1kubectl -n smb-test create secret generic smb-creds \
2--from-literal username=testuser \
3--from-literal domain=12.123.123.123 \
4--from-literal password=testpw

3. PersistentVolume or StorageClass 생성 #

PersistentVolume #

 1apiVersion: v1
 2kind: PersistentVolume
 3metadata:
 4  name: pv-smb
 5  namespace: smb-test
 6spec:
 7  storageClassName: ''
 8  capacity:
 9    storage: 50Gi
10  accessModes:
11    - ReadWriteMany
12  persistentVolumeReclaimPolicy: Retain
13  mountOptions:
14    - dir_mode=0777
15    - file_mode=0777
16    - vers=3.0
17  csi:
18    driver: smb.csi.k8s.io
19    readOnly: false
20    volumeHandle: $VOLUMEID  # make sure it's a unique id in the cluster
21    volumeAttributes:
22      source: //12.123.123.123/testuser
23    nodeStageSecretRef:
24      name: smb-creds
25      namespace: smb-test

StorageClass #

 1apiVersion: storage.k8s.io/v1
 2kind: StorageClass
 3metadata:
 4  name: smb
 5  namespace: smb-test
 6provisioner: smb.csi.k8s.io
 7parameters:
 8  # On Windows, "*.default.svc.cluster.local" could not be recognized by csi-proxy
 9  source: //smb-server.default.svc.cluster.local/share
10  # if csi.storage.k8s.io/provisioner-secret is provided, will create a sub directory
11  # with PV name under source
12  # csi.storage.k8s.io/provisioner-secret-name: smbcreds
13  # csi.storage.k8s.io/provisioner-secret-namespace: [NAMESPACE NAME]
14  csi.storage.k8s.io/node-stage-secret-name: smbcreds
15  csi.storage.k8s.io/node-stage-secret-namespace: smb-test
16volumeBindingMode: Immediate
17mountOptions:
18  - dir_mode=0777
19  - file_mode=0777
20  - uid=1001
21  - gid=1001
22  - noperm
23  - mfsymlinks
24  - cache=strict
25  - noserverino  # required to prevent data corruption

Storage Class 참고

4. PersistentVolumeClaim 생성 #

 1kind: PersistentVolumeClaim
 2apiVersion: v1
 3metadata:
 4  name: pvc-smb
 5  namespace: smb-test
 6spec:
 7  accessModes:
 8    - ReadWriteMany
 9  resources:
10    requests:
11      storage: 10Gi
12  volumeName: pv-smb    # pv를 설정했을 때
13  storageClassName: smb    # sc를 설정했을 때

5. Deployment 생성 #

 1apiVersion: apps/v1
 2kind: Deployment
 3metadata:
 4  labels:
 5    app: nginx
 6  name: deploy-smb-pod
 7  namespace: smb-test
 8spec:
 9  replicas: 1
10  selector:
11    matchLabels:
12      app: nginx
13  template:
14    metadata:
15      labels:
16        app: nginx
17      name: deploy-smb-pod
18    spec:
19      containers:
20        - name: deploy-smb-pod
21          image: nginx:1.19.5
22          command:
23            - "/bin/bash"
24            - "-c"
25            - set -euo pipefail; while true; do echo $(date) >> /mnt/smb/outfile; sleep 1; done
26          volumeMounts:
27            - name: smb
28              mountPath: "/mnt/smb"
29              readOnly: false
30      volumes:
31        - name: smb
32          persistentVolumeClaim:
33            claimName: pvc-smb

6. 확인 #

1kubectl -n smb-test exec -it deploy-smb-pod-8569fdd89c-dmlzh -- ls -rtl /mnt/smb
2
3total 28
4-rwxrwxrwx 1 root root 26280 Sep 25 17:53 outfile

7. test.txt 파일 생성 #

1kubectl -n smb-test exec -it deploy-smb-pod-8569fdd89c-dmlzh -- touch /mnt/smb/test.txt

8. 확인2 #

1kubectl -n smb-test exec -it deploy-smb-pod-8569fdd89c-dmlzh -- ls -la /mnt/smb
2
3total 48
4drwxrwxrwx 2 root root     0 Sep 25 18:02 .
5drwxr-xr-x 1 root root  4096 Sep 25 17:51 ..
6-rwxrwxrwx 1 root root 43800 Sep 25 18:03 outfile
7-rwxrwxrwx 1 root root     0 Sep 25 18:15 test.txt
Advertisement