Skip to content

Commit d349377

Browse files
authored
Merge pull request #57 from mayankshah1607/dev-docs
Add manifest for installing driver controller and install docs
2 parents ebc69d6 + 639d1aa commit d349377

File tree

5 files changed

+234
-1
lines changed

5 files changed

+234
-1
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
/bin
2+
3+
# This is where the result of the go build goes
4+
/output*/
5+
/_output*/
6+
/_output

Makefile

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
CMDS=nfsplugin
15+
DEPLOY_FOLDER = ./deploy/kubernetes
1516
CMDS=nfsplugin
1617
all: build
1718

@@ -21,3 +22,25 @@ include release-tools/build.make
2122
sanity-test: build
2223
./test/sanity/run-test.sh
2324

25+
.PHONY: local-build-push
26+
local-build-push: build
27+
docker build -t $(LOCAL_USER)/nfsplugin:latest .
28+
docker push $(LOCAL_USER)/nfsplugin
29+
30+
.PHONY: local-k8s-install
31+
local-k8s-install:
32+
echo "Instlling locally"
33+
kubectl apply -f $(DEPLOY_FOLDER)/rbac-csi-nfs-controller.yaml
34+
kubectl apply -f $(DEPLOY_FOLDER)/csi-nfs-driverinfo.yaml
35+
kubectl apply -f $(DEPLOY_FOLDER)/csi-nfs-controller.yaml
36+
kubectl apply -f $(DEPLOY_FOLDER)/csi-nfs-node.yaml
37+
echo "Successfully installed"
38+
39+
.PHONY: local-k8s-uninstall
40+
local-k8s-uninstall:
41+
echo "Uninstalling driver"
42+
kubectl delete -f $(DEPLOY_FOLDER)/csi-nfs-controller.yaml --ignore-not-found
43+
kubectl delete -f $(DEPLOY_FOLDER)/csi-nfs-node.yaml --ignore-not-found
44+
kubectl delete -f $(DEPLOY_FOLDER)/csi-nfs-driverinfo.yaml --ignore-not-found
45+
kubectl delete -f $(DEPLOY_FOLDER)/rbac-csi-nfs-controller.yaml --ignore-not-found
46+
echo "Uninstalled NFS driver"
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
kind: Deployment
3+
apiVersion: apps/v1
4+
metadata:
5+
name: csi-nfs-controller
6+
namespace: kube-system
7+
spec:
8+
replicas: 2
9+
selector:
10+
matchLabels:
11+
app: csi-nfs-controller
12+
template:
13+
metadata:
14+
labels:
15+
app: csi-nfs-controller
16+
spec:
17+
serviceAccountName: csi-nfs-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: 100m
43+
memory: 100Mi
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=29642
53+
- --v=5
54+
volumeMounts:
55+
- name: socket-dir
56+
mountPath: /csi
57+
resources:
58+
limits:
59+
cpu: 100m
60+
memory: 100Mi
61+
requests:
62+
cpu: 10m
63+
memory: 20Mi
64+
- name: nfs
65+
image: quay.io/k8scsi/nfsplugin:v2.0.0
66+
securityContext:
67+
privileged: true
68+
capabilities:
69+
add: ["SYS_ADMIN"]
70+
allowPrivilegeEscalation: true
71+
imagePullPolicy: IfNotPresent
72+
args:
73+
- "--nodeid=$(NODE_ID)"
74+
- "--endpoint=$(CSI_ENDPOINT)"
75+
env:
76+
- name: NODE_ID
77+
valueFrom:
78+
fieldRef:
79+
fieldPath: spec.nodeName
80+
- name: CSI_ENDPOINT
81+
value: unix:///csi/csi.sock
82+
volumeMounts:
83+
- name: plugin-dir
84+
mountPath: /plugin
85+
- name: pods-mount-dir
86+
mountPath: /var/lib/kubelet/pods
87+
mountPropagation: "Bidirectional"
88+
- mountPath: /csi
89+
name: socket-dir
90+
resources:
91+
limits:
92+
cpu: 200m
93+
memory: 200Mi
94+
requests:
95+
cpu: 10m
96+
memory: 20Mi
97+
volumes:
98+
- name: plugin-dir
99+
hostPath:
100+
path: /var/lib/kubelet/plugins/csi-nfsplugin
101+
type: DirectoryOrCreate
102+
- name: pods-mount-dir
103+
hostPath:
104+
path: /var/lib/kubelet/pods
105+
type: Directory
106+
- name: socket-dir
107+
emptyDir: {}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: csi-nfs-controller-sa
6+
namespace: kube-system
7+
8+
---
9+
10+
kind: ClusterRole
11+
apiVersion: rbac.authorization.k8s.io/v1
12+
metadata:
13+
name: nfs-external-provisioner-role
14+
rules:
15+
- apiGroups: [""]
16+
resources: ["persistentvolumes"]
17+
verbs: ["get", "list", "watch", "create", "delete"]
18+
- apiGroups: [""]
19+
resources: ["persistentvolumeclaims"]
20+
verbs: ["get", "list", "watch", "update"]
21+
- apiGroups: ["storage.k8s.io"]
22+
resources: ["storageclasses"]
23+
verbs: ["get", "list", "watch"]
24+
- apiGroups: [""]
25+
resources: ["events"]
26+
verbs: ["get", "list", "watch", "create", "update", "patch"]
27+
- apiGroups: ["storage.k8s.io"]
28+
resources: ["csinodes"]
29+
verbs: ["get", "list", "watch"]
30+
- apiGroups: [""]
31+
resources: ["nodes"]
32+
verbs: ["get", "list", "watch"]
33+
- apiGroups: ["coordination.k8s.io"]
34+
resources: ["leases"]
35+
verbs: ["get", "list", "watch", "create", "update", "patch"]
36+
---
37+
38+
kind: ClusterRoleBinding
39+
apiVersion: rbac.authorization.k8s.io/v1
40+
metadata:
41+
name: nfs-csi-provisioner-binding
42+
subjects:
43+
- kind: ServiceAccount
44+
name: csi-nfs-controller-sa
45+
namespace: kube-system
46+
roleRef:
47+
kind: ClusterRole
48+
name: nfs-external-provisioner-role
49+
apiGroup: rbac.authorization.k8s.io

docs/csi-dev.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# CSI Driver Development Guide
2+
3+
## Build this project
4+
5+
- Clone this repo
6+
7+
```bash
8+
git clone https://github.com/kubernetes-csi/csi-driver-nfs
9+
```
10+
11+
- Build CSI Driver
12+
13+
```bash
14+
$ cd csi-driver-nfs
15+
$ make
16+
```
17+
18+
- Verify code before submitting PRs
19+
20+
```bash
21+
make verify
22+
```
23+
## Test CSI Driver locally
24+
25+
> WIP
26+
27+
## Test CSI Driver in a Kubernetes Cluster
28+
29+
- Build container image and push to DockerHub
30+
31+
```bash
32+
# Run `docker login` first
33+
$ export LOCAL_USER=<DockerHub Username>
34+
$ make local-build-push
35+
```
36+
37+
- Replace `quay.io/k8scsi/nfsplugin:v2.0.0` in `deploy/kubernetes/csi-nfs-controller.yaml` and `deploy/kubernetes/csi-nfs-node.yaml` with `<YOUR DOCKERHUB ID>/nfsplugin:latest`
38+
39+
- Install driver locally
40+
41+
```bash
42+
make local-k8s-install
43+
```
44+
45+
- Uninstall driver
46+
47+
```bash
48+
make local-k8s-uninstall
49+
```

0 commit comments

Comments
 (0)