|
1 | 1 | ## CSI driver E2E usage example |
2 | 2 | ### Prerequisite |
3 | 3 | - [Set up a Samba Server on a Kubernetes cluster](./smb-provisioner/) |
4 | | - |
5 | | -#### 1. Create PV/PVC bound with SMB share |
6 | | - - Use `kubectl create secret` to create `smbcreds` with SMB username, password |
| 4 | + > this example will create a new Samba Server(`//smb-server.default.svc.cluster.local/share`) with credential stored in secret `smbcreds` |
| 5 | + - Use `kubectl create secret` to create `smbcreds` with Samba Server username, password |
| 6 | + > skip this if already done |
7 | 7 | ```console |
8 | 8 | kubectl create secret generic smbcreds --from-literal username=USERNAME --from-literal password="PASSWORD" |
9 | 9 | ``` |
10 | 10 | > add `--from-literal domain=DOMAIN-NAME` for domain support |
11 | 11 |
|
| 12 | +### Option#1: Storage Class Usage |
| 13 | +#### 1. Create a storage class |
| 14 | +```yaml |
| 15 | +apiVersion: storage.k8s.io/v1 |
| 16 | +kind: StorageClass |
| 17 | +metadata: |
| 18 | + name: smb |
| 19 | +provisioner: smb.csi.k8s.io |
| 20 | +parameters: |
| 21 | + source: "//smb-server.default.svc.cluster.local/share" |
| 22 | + csi.storage.k8s.io/node-stage-secret-name: "smbcreds" |
| 23 | + csi.storage.k8s.io/node-stage-secret-namespace: "default" |
| 24 | + createSubDir: "true" # optional: create a sub dir for new volume |
| 25 | +reclaimPolicy: Retain # only retain is supported |
| 26 | +volumeBindingMode: Immediate |
| 27 | +mountOptions: |
| 28 | + - dir_mode=0777 |
| 29 | + - file_mode=0777 |
| 30 | + - uid=1001 |
| 31 | + - gid=1001 |
| 32 | +``` |
| 33 | + - Run below command to create a storage class |
| 34 | +```console |
| 35 | +kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/storageclass-smb.yaml |
| 36 | +``` |
| 37 | + |
| 38 | +#### 2. Create a statefulset pod |
| 39 | +```console |
| 40 | +kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/statefulset.yaml |
| 41 | +``` |
| 42 | + - enter the pod container to verify |
| 43 | +```console |
| 44 | +# k exec -it statefulset-smb2-0 bash |
| 45 | +root@statefulset-smb2-0:/# df -h |
| 46 | +Filesystem Size Used Avail Use% Mounted on |
| 47 | +... |
| 48 | +//smb-server.default.svc.cluster.local/share 124G 15G 110G 12% /mnt/smb |
| 49 | +/dev/sda1 124G 15G 110G 12% /etc/hosts |
| 50 | +... |
| 51 | +``` |
| 52 | + |
| 53 | +### Option#2: PV/PVC Usage |
| 54 | +#### 1. Create PV/PVC bound with SMB share |
12 | 55 | - Create a smb CSI PV, download [`pv-smb.yaml`](https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/pv-smb.yaml) file and edit `source` in `volumeAttributes` |
13 | 56 | ```yaml |
14 | 57 | apiVersion: v1 |
@@ -68,6 +111,6 @@ Filesystem Size Used Avail Use% Mounted on |
68 | 111 | In the above example, there is a `/mnt/smb` directory mounted as cifs filesystem. |
69 | 112 |
|
70 | 113 | ### 2.2 Create a deployment on Windows |
71 | | -``` |
| 114 | +```console |
72 | 115 | kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/windows/deployment.yaml |
73 | 116 | ``` |
0 commit comments