From 9edb044d35f366ab9269844fd858bc77943b86ef Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 26 Aug 2024 22:27:32 +0200 Subject: [PATCH] Use helm for install --- README.md | 13 +++-- helm/Chart.yaml | 4 ++ .../templates/controller.yaml | 43 ++++++++-------- helm/templates/default-storageClass.yaml | 13 +++++ .../templates/driverinfo.yaml | 3 +- .../templates/node.yaml | 34 ++++++------- .../templates/rbac.yaml | 3 +- helm/values.yaml | 50 +++++++++++++++++++ 8 files changed, 114 insertions(+), 49 deletions(-) create mode 100644 helm/Chart.yaml rename deploy/csi-webdav-controller.yaml => helm/templates/controller.yaml (70%) create mode 100644 helm/templates/default-storageClass.yaml rename deploy/csi-webdav-driverinfo.yaml => helm/templates/driverinfo.yaml (88%) rename deploy/csi-webdav-node.yaml => helm/templates/node.yaml (81%) rename deploy/csi-webdav-rbac.yaml => helm/templates/rbac.yaml (96%) create mode 100644 helm/values.yaml diff --git a/README.md b/README.md index e1f53ba..eda787e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ This is a repository for webdav csi driver, csi plugin name: `webdav.csi.io`. This driver supports dynamic provisioning of Persistent Volumes via Persistent Volume Claims by creating a new sub directory under webdav server. +### Deploy CSI +#### With Helm +```bash +helm install -n webdav-csi-driver webdav-csi-driver helm/ +``` + ### Quick start with kind #### Build plugin image @@ -24,10 +30,7 @@ kind load docker-image registry.k8s.io/sig-storage/csi-node-driver-registrar:v2. kind load docker-image localhost:5000/webdavplugin:v0.0.1 ``` -### Deploy CSI -```bash -kubectl apply -f deploy/ -``` + ### Tests ```bash @@ -35,4 +38,4 @@ kubectl apply -f examples/csi-webdav-secret.yaml kubectl apply -f examples/csi-webdav-storageclass.yaml kubectl apply -f examples/csi-webdav-dynamic-pvc.yaml kubectl apply -f examples/csi-webdav-pod.yaml -``` \ No newline at end of file +``` diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..91029da --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +name: webdav-csi-driver +description: A Helm chart for deploying CSI WebDAV Storage Driver +version: 0.0.1 diff --git a/deploy/csi-webdav-controller.yaml b/helm/templates/controller.yaml similarity index 70% rename from deploy/csi-webdav-controller.yaml rename to helm/templates/controller.yaml index a0ca556..9f5aeee 100644 --- a/deploy/csi-webdav-controller.yaml +++ b/helm/templates/controller.yaml @@ -1,24 +1,23 @@ ---- -kind: Deployment apiVersion: apps/v1 +kind: Deployment metadata: - name: csi-webdav-controller + name: webdav-csi-controller namespace: kube-system spec: - replicas: 1 + replicas: {{ .Values.controller.replicas }} selector: matchLabels: - app: csi-webdav-controller + app: webdav-csi-controller template: metadata: labels: - app: csi-webdav-controller + app: webdav-csi-controller spec: - hostNetwork: true # controller also needs to mount webdav to create dir - dnsPolicy: ClusterFirstWithHostNet # available values: Default, ClusterFirstWithHostNet, ClusterFirst + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet serviceAccountName: webdav-csi-sa nodeSelector: - kubernetes.io/os: linux # add "kubernetes.io/role: master" to run controller on master node + kubernetes.io/os: linux priorityClassName: system-cluster-critical securityContext: seccompProfile: @@ -35,8 +34,8 @@ spec: effect: "NoSchedule" containers: - name: csi-provisioner - image: registry.k8s.io/sig-storage/csi-provisioner:v3.6.2 - imagePullPolicy: IfNotPresent + image: {{ .Values.csiProvisioner.image.name }}:{{ .Values.csiProvisioner.image.tag }} + imagePullPolicy: {{ .Values.csiProvisioner.image.pullPolicy }} args: - "-v=2" - "--csi-address=$(ADDRESS)" @@ -52,13 +51,13 @@ spec: name: socket-dir resources: limits: - memory: 400Mi + memory: {{ .Values.controller.resources.limits.memory }} requests: - cpu: 10m - memory: 20Mi + cpu: {{ .Values.controller.resources.requests.cpu }} + memory: {{ .Values.controller.resources.requests.memory }} - name: liveness-probe - image: registry.k8s.io/sig-storage/livenessprobe:v2.11.0 - imagePullPolicy: IfNotPresent + image: {{ .Values.livenessProbe.image.name }}:{{ .Values.livenessProbe.image.tag }} + imagePullPolicy: {{ .Values.livenessProbe.image.pullPolicy }} args: - --csi-address=/csi/csi.sock - --probe-timeout=3s @@ -74,8 +73,8 @@ spec: cpu: 10m memory: 20Mi - name: webdav - image: localhost:5000/webdavplugin:v0.0.1 - imagePullPolicy: IfNotPresent + image: {{ .Values.controller.image.name }}:{{ .Values.controller.image.tag }} + imagePullPolicy: {{ .Values.controller.image.pullPolicy }} securityContext: privileged: true capabilities: @@ -112,14 +111,14 @@ spec: name: socket-dir resources: limits: - memory: 200Mi + memory: {{ .Values.controller.resources.limits.memory }} requests: - cpu: 10m - memory: 20Mi + cpu: {{ .Values.controller.resources.requests.cpu }} + memory: {{ .Values.controller.resources.requests.memory }} volumes: - name: pods-mount-dir hostPath: path: /var/lib/kubelet/pods type: Directory - name: socket-dir - emptyDir: {} \ No newline at end of file + emptyDir: {} diff --git a/helm/templates/default-storageClass.yaml b/helm/templates/default-storageClass.yaml new file mode 100644 index 0000000..22748ca --- /dev/null +++ b/helm/templates/default-storageClass.yaml @@ -0,0 +1,13 @@ +{{- if .defaultStorageClass }} +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: {{ .defaultStorageClass.name }} +provisioner: webdav.csi.io +parameters: + {{- toYaml .defaultStorageClass.parameters | nindent 2 }} +reclaimPolicy: {{ .defaultStorageClass.reclaimPolicy }} +volumeBindingMode: {{ .defaultStorageClass.volumeBindingMode }} +mountOptions: + {{- toYaml .defaultStorageClass.mountOptions | nindent 2 }} +{{- end }} diff --git a/deploy/csi-webdav-driverinfo.yaml b/helm/templates/driverinfo.yaml similarity index 88% rename from deploy/csi-webdav-driverinfo.yaml rename to helm/templates/driverinfo.yaml index 16407db..ff3d7b1 100644 --- a/deploy/csi-webdav-driverinfo.yaml +++ b/helm/templates/driverinfo.yaml @@ -1,4 +1,3 @@ ---- apiVersion: storage.k8s.io/v1 kind: CSIDriver metadata: @@ -6,4 +5,4 @@ metadata: spec: attachRequired: false volumeLifecycleModes: - - Persistent \ No newline at end of file + - Persistent diff --git a/deploy/csi-webdav-node.yaml b/helm/templates/node.yaml similarity index 81% rename from deploy/csi-webdav-node.yaml rename to helm/templates/node.yaml index 8578874..408bf1b 100644 --- a/deploy/csi-webdav-node.yaml +++ b/helm/templates/node.yaml @@ -1,8 +1,7 @@ ---- -kind: DaemonSet apiVersion: apps/v1 +kind: DaemonSet metadata: - name: csi-webdav-node + name: webdav-csi-node namespace: kube-system spec: updateStrategy: @@ -11,14 +10,14 @@ spec: type: RollingUpdate selector: matchLabels: - app: csi-webdav-node + app: webdav-csi-node template: metadata: labels: - app: csi-webdav-node + app: webdav-csi-node spec: - hostNetwork: true # original webdav connection would be broken without hostNetwork setting - dnsPolicy: ClusterFirstWithHostNet # available values: Default, ClusterFirstWithHostNet, ClusterFirst + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet serviceAccountName: webdav-csi-sa priorityClassName: system-node-critical securityContext: @@ -30,8 +29,8 @@ spec: - operator: "Exists" containers: - name: liveness-probe - image: registry.k8s.io/sig-storage/livenessprobe:v2.11.0 - imagePullPolicy: IfNotPresent + image: {{ .Values.livenessProbe.image.name }}:{{ .Values.livenessProbe.image.tag }} + imagePullPolicy: {{ .Values.livenessProbe.image.pullPolicy }} args: - --csi-address=/csi/csi.sock - --probe-timeout=3s @@ -63,7 +62,7 @@ spec: timeoutSeconds: 15 env: - name: DRIVER_REG_SOCK_PATH - value: /var/lib/kubelet/plugins/csi-webdavplugin/csi.sock + value: /var/lib/kubelet/plugins/webdav-csiplugin/csi.sock - name: KUBE_NODE_NAME valueFrom: fieldRef: @@ -85,8 +84,8 @@ spec: capabilities: add: ["SYS_ADMIN"] allowPrivilegeEscalation: true - image: localhost:5000/webdavplugin:v0.0.1 - imagePullPolicy: IfNotPresent + image: {{ .Values.node.image.name }}:{{ .Values.node.image.tag }} + imagePullPolicy: {{ .Values.node.image.pullPolicy }} args: - "-v=5" - "--nodeid=$(NODE_ID)" @@ -110,7 +109,6 @@ spec: initialDelaySeconds: 30 timeoutSeconds: 10 periodSeconds: 30 - imagePullPolicy: "IfNotPresent" volumeMounts: - name: socket-dir mountPath: /csi @@ -119,14 +117,14 @@ spec: mountPropagation: "Bidirectional" resources: limits: - memory: 300Mi + memory: {{ .Values.node.resources.limits.memory }} requests: - cpu: 10m - memory: 20Mi + cpu: {{ .Values.node.resources.requests.cpu }} + memory: {{ .Values.node.resources.requests.memory }} volumes: - name: socket-dir hostPath: - path: /var/lib/kubelet/plugins/csi-webdavplugin + path: /var/lib/kubelet/plugins/webdav-csiplugin type: DirectoryOrCreate - name: pods-mount-dir hostPath: @@ -135,4 +133,4 @@ spec: - hostPath: path: /var/lib/kubelet/plugins_registry type: Directory - name: registration-dir \ No newline at end of file + name: registration-dir diff --git a/deploy/csi-webdav-rbac.yaml b/helm/templates/rbac.yaml similarity index 96% rename from deploy/csi-webdav-rbac.yaml rename to helm/templates/rbac.yaml index ef9f2fc..110b440 100644 --- a/deploy/csi-webdav-rbac.yaml +++ b/helm/templates/rbac.yaml @@ -1,4 +1,3 @@ ---- apiVersion: v1 kind: ServiceAccount metadata: @@ -46,4 +45,4 @@ subjects: roleRef: kind: ClusterRole name: webdav-csi-cr - apiGroup: rbac.authorization.k8s.io \ No newline at end of file + apiGroup: rbac.authorization.k8s.io diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..29e9680 --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1,50 @@ +controller: + replicas: 1 + image: + name: ghcr.io/ruakij/webdav-csi-driver + tag: v0.0.1 + pullPolicy: IfNotPresent + resources: + limits: + memory: 200Mi + requests: + cpu: 10m + memory: 20Mi + +node: + image: + name: ghcr.io/ruakij/webdav-csi-driver + tag: v0.0.1 + pullPolicy: IfNotPresent + resources: + limits: + memory: 300Mi + requests: + cpu: 10m + memory: 20Mi + +livenessProbe: + image: + name: registry.k8s.io/sig-storage/livenessprobe + tag: v2.11.0 + pullPolicy: IfNotPresent + +csiProvisioner: + image: + name: registry.k8s.io/sig-storage/csi-provisioner + tag: v3.6.2 + pullPolicy: IfNotPresent + +# Configuration for the default storage class +defaultStorageClass: {} +# name: "webdav" +# parameters: +# # alist folder webdav address +# share: http://ip:port/dav/media +# csi.storage.k8s.io/provisioner-secret-name: "webdav-secrect" +# csi.storage.k8s.io/provisioner-secret-namespace: "default" +# csi.storage.k8s.io/node-publish-secret-name: "webdav-secrect" +# csi.storage.k8s.io/node-publish-secret-namespace: "default" +# reclaimPolicy: "Delete" +# volumeBindingMode: Immediate +# mountOptions: {}