Skip to content

Commit 733634b

Browse files
authored
Merge pull request #61 from andyzhangx/storage-class-support
feat: Storage class support
2 parents a04e886 + b28ed77 commit 733634b

18 files changed

+284
-27
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ smb-windows:
100100

101101
.PHONY: container
102102
container: smb
103-
docker build --no-cache -t $(IMAGE_TAG) -f ./pkg/smbplugin/Dockerfile .
103+
docker build --no-cache -t $(IMAGE_TAG) -f ./pkg/smbplugin/dev.Dockerfile .
104104

105105
.PHONY: smb-container
106106
smb-container:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Please refer to [`smb.csi.k8s.io` driver parameters](./docs/driver-parameters.md
2121
Please refer to [install SMB CSI driver](./docs/install-csi-driver-master.md)
2222

2323
### Examples
24-
- [Set up a SMB server deployment on a Kubernetes cluster](./deploy/example/smb-provisioner/)
24+
- [Set up a Samba Server deployment on a Kubernetes cluster](./deploy/example/smb-provisioner/)
2525
- [Basic usage](./deploy/example/e2e_usage.md)
2626
- [Windows](./deploy/example/windows)
2727

deploy/csi-smb-controller.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
kind: Deployment
3+
apiVersion: apps/v1
4+
metadata:
5+
name: csi-smb-controller
6+
namespace: kube-system
7+
spec:
8+
replicas: 2
9+
selector:
10+
matchLabels:
11+
app: csi-smb-controller
12+
template:
13+
metadata:
14+
labels:
15+
app: csi-smb-controller
16+
spec:
17+
serviceAccountName: csi-smb-controller-sa
18+
nodeSelector:
19+
kubernetes.io/os: linux
20+
priorityClassName: system-cluster-critical
21+
tolerations:
22+
- key: "node-role.kubernetes.io/master"
23+
operator: "Equal"
24+
value: "true"
25+
effect: "NoSchedule"
26+
containers:
27+
- name: csi-provisioner
28+
image: mcr.microsoft.com/oss/kubernetes-csi/csi-provisioner:v1.4.0
29+
args:
30+
- "-v=5"
31+
- "--csi-address=$(ADDRESS)"
32+
- "--enable-leader-election"
33+
- "--leader-election-type=leases"
34+
env:
35+
- name: ADDRESS
36+
value: /csi/csi.sock
37+
volumeMounts:
38+
- mountPath: /csi
39+
name: socket-dir
40+
resources:
41+
limits:
42+
cpu: 1
43+
memory: 1Gi
44+
requests:
45+
cpu: 10m
46+
memory: 20Mi
47+
- name: liveness-probe
48+
image: mcr.microsoft.com/oss/kubernetes-csi/livenessprobe:v1.1.0
49+
args:
50+
- --csi-address=/csi/csi.sock
51+
- --connection-timeout=3s
52+
- --health-port=29632
53+
- --v=5
54+
volumeMounts:
55+
- name: socket-dir
56+
mountPath: /csi
57+
resources:
58+
limits:
59+
cpu: 1
60+
memory: 1Gi
61+
requests:
62+
cpu: 10m
63+
memory: 20Mi
64+
- name: smb
65+
image: mcr.microsoft.com/k8s/csi/smb-csi:latest
66+
imagePullPolicy: IfNotPresent
67+
args:
68+
- "--v=5"
69+
- "--endpoint=$(CSI_ENDPOINT)"
70+
ports:
71+
- containerPort: 29632
72+
name: healthz
73+
protocol: TCP
74+
- containerPort: 29634
75+
name: metrics
76+
protocol: TCP
77+
livenessProbe:
78+
failureThreshold: 5
79+
httpGet:
80+
path: /healthz
81+
port: healthz
82+
initialDelaySeconds: 30
83+
timeoutSeconds: 10
84+
periodSeconds: 30
85+
env:
86+
- name: CSI_ENDPOINT
87+
value: unix:///csi/csi.sock
88+
volumeMounts:
89+
- mountPath: /csi
90+
name: socket-dir
91+
resources:
92+
limits:
93+
cpu: 1
94+
memory: 1Gi
95+
requests:
96+
cpu: 10m
97+
memory: 20Mi
98+
volumes:
99+
- name: socket-dir
100+
emptyDir: {}

deploy/example/e2e_usage.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## CSI driver E2E usage example
22
### Prerequisite
3-
- [Set up a SMB server on a Kubernetes cluster](./smb-provisioner/)
3+
- [Set up a Samba Server on a Kubernetes cluster](./smb-provisioner/)
44

55
#### 1. Create PV/PVC bound with SMB share
66
- Use `kubectl create secret` to create `smbcreds` with SMB username, password
@@ -9,7 +9,7 @@ kubectl create secret generic smbcreds --from-literal username=USERNAME --from-l
99
```
1010
> add `--from-literal domain=DOMAIN-NAME` for domain support
1111
12-
- Create a smb CSI PV, download [`pv-smb-csi.yaml`](https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/pv-smb-csi.yaml) file and edit `source` in `volumeAttributes`
12+
- 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`
1313
```yaml
1414
apiVersion: v1
1515
kind: PersistentVolume
@@ -38,12 +38,12 @@ spec:
3838
> For [Azure File](https://docs.microsoft.com/en-us/azure/storage/files/), format of `source`: `//accountname.file.core.windows.net/sharename`
3939

4040
```console
41-
kubectl create -f pv-smb-csi.yaml
41+
kubectl create -f pv-smb.yaml
4242
```
4343

4444
- Create a PVC
4545
```console
46-
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/pvc-smb-csi-static.yaml
46+
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/pvc-smb-static.yaml
4747
```
4848
- make sure pvc is created and in `Bound` status finally
4949
```console
@@ -70,4 +70,4 @@ In the above example, there is a `/mnt/smb` directory mounted as cifs filesystem
7070
### 2.2 Create a deployment on Windows
7171
```
7272
kubectl apply -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/windows/deployment.yaml
73-
```
73+
```

deploy/example/pvc-smb-csi.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
kind: PersistentVolumeClaim
3+
apiVersion: v1
4+
metadata:
5+
name: pvc-smb
6+
spec:
7+
accessModes:
8+
- ReadWriteMany
9+
resources:
10+
requests:
11+
storage: 10Gi
12+
storageClassName: smb

deploy/example/smb-provisioner/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
## Set up a SMB server and a deployment to access SMB server on a Kubernetes cluster
1+
## Set up a Samba Server and a deployment to access Samba Server on a Kubernetes cluster
22
This page will show you how to:
3-
- set up a SMB server deployment on a Kubernetes cluster, the file share data is stored on local disk.
4-
- set up a deployment to access SMB server on a Kubernetes cluster
3+
- set up a Samba Server deployment on a Kubernetes cluster, the file share data is stored on local disk.
4+
- set up a deployment to access Samba Server on a Kubernetes cluster
55

66
### Stey-by-step
77
- Use `kubectl create secret` to create `smbcreds` with SMB username, password
88
```console
99
kubectl create secret generic smbcreds --from-literal username=USERNAME --from-literal password="PASSWORD"
1010
```
1111

12-
- Create a SMB server deployment
12+
- Create a Samba Server deployment
1313
> modify `/smbshare-volume` in deployment to specify different path for smb share data store
1414
```console
1515
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/smb-provisioner/smb-server.yaml
1616
```
1717

1818
After deployment, a new service `smb-server` is created, file share path is `//smb-server.default.svc.cluster.local/share`
1919

20-
- Create a deployment to access above SMB server
20+
- Create a deployment to access above Samba Server
2121
```console
22-
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/smb-provisioner/pv-smb-csi.yaml
23-
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/pvc-smb-csi-static.yaml
22+
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/smb-provisioner/pv-smb.yaml
23+
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/pvc-smb-static.yaml
2424
kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/deploy/example/deployment.yaml
2525
```
2626

deploy/example/statefulset.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: StatefulSet
4+
metadata:
5+
name: statefulset-smb
6+
labels:
7+
app: nginx
8+
spec:
9+
serviceName: statefulset-smb
10+
replicas: 1
11+
template:
12+
metadata:
13+
labels:
14+
app: nginx
15+
spec:
16+
containers:
17+
- name: statefulset-smb
18+
image: nginx
19+
command:
20+
- "/bin/sh"
21+
- "-c"
22+
- while true; do echo $(date) >> /mnt/smb/outfile; sleep 1; done
23+
volumeMounts:
24+
- name: persistent-storage
25+
mountPath: /mnt/smb
26+
updateStrategy:
27+
type: RollingUpdate
28+
selector:
29+
matchLabels:
30+
app: nginx
31+
volumeClaimTemplates:
32+
- metadata:
33+
name: persistent-storage
34+
annotations:
35+
volume.beta.kubernetes.io/storage-class: smb
36+
spec:
37+
accessModes: ["ReadWriteOnce"]
38+
resources:
39+
requests:
40+
storage: 10Gi
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: storage.k8s.io/v1
3+
kind: StorageClass
4+
metadata:
5+
name: smb
6+
provisioner: smb.csi.k8s.io
7+
parameters:
8+
source: "//smb-server.default.svc.cluster.local/share"
9+
csi.storage.k8s.io/node-stage-secret-name: "smbcreds"
10+
csi.storage.k8s.io/node-stage-secret-namespace: "default"
11+
reclaimPolicy: Retain # only retain is supported
12+
volumeBindingMode: Immediate
13+
mountOptions:
14+
- dir_mode=0777
15+
- file_mode=0777
16+
- uid=1001
17+
- gid=1001

0 commit comments

Comments
 (0)