From 47bdde6f19b803be0813ce89ce0508ced3dc5c5f Mon Sep 17 00:00:00 2001 From: Muhammed Hussein Karimi Date: Sun, 25 Feb 2024 19:50:25 +0330 Subject: [PATCH 1/7] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20refactor:=20some=20?= =?UTF-8?q?chart=20improvments=20and=20optimizations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit making images customizable adding StorageClass management via helm chart move to `registry.k8s.io` for kubernetes images (all of the images are available there) switch from yaml anchors/pointers to global values and helpers to handle default values so it will make customizations easier for resources/images getting default tag from appVersion in Chart.yaml dataDir path for plugin is customizable now documenting chart using helm-docs tool (with comments in values file) Signed-off-by: Muhammed Hussein Karimi --- deploy/charts/rawfile-csi/Chart.yaml | 1 + deploy/charts/rawfile-csi/README.md | 51 ++++++++ .../templates/01-controller-plugin.yaml | 19 ++- .../rawfile-csi/templates/01-node-plugin.yaml | 22 ++-- .../templates/01-storage-class.yaml | 14 +++ .../charts/rawfile-csi/templates/_helpers.tpl | 49 ++++++++ deploy/charts/rawfile-csi/values.yaml | 110 +++++++++++++++++- 7 files changed, 238 insertions(+), 28 deletions(-) create mode 100644 deploy/charts/rawfile-csi/README.md create mode 100644 deploy/charts/rawfile-csi/templates/01-storage-class.yaml diff --git a/deploy/charts/rawfile-csi/Chart.yaml b/deploy/charts/rawfile-csi/Chart.yaml index 3896e28..90558d5 100644 --- a/deploy/charts/rawfile-csi/Chart.yaml +++ b/deploy/charts/rawfile-csi/Chart.yaml @@ -4,3 +4,4 @@ description: RawFile Driver Container Storage Interface type: application version: 0.8.0 appVersion: 0.8.0 +kubeVersion: ">= 1.21" diff --git a/deploy/charts/rawfile-csi/README.md b/deploy/charts/rawfile-csi/README.md new file mode 100644 index 0000000..adeb034 --- /dev/null +++ b/deploy/charts/rawfile-csi/README.md @@ -0,0 +1,51 @@ +# rawfile-csi + +![Version: 0.8.0](https://img.shields.io/badge/Version-0.8.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.8.0](https://img.shields.io/badge/AppVersion-0.8.0-informational?style=flat-square) + +RawFile Driver Container Storage Interface + +## Requirements + +Kubernetes: `>= 1.21` + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| controller.externalResizer.image.repository | string | `"registry.k8s.io/sig-storage/csi-resizer"` | Image Repository for `csi-resizer` | +| controller.externalResizer.image.tag | string | `"v1.2.0"` | Image tag for `csi-resizer` | +| controller.image.pullPolicy | string | `""` | Overrides default image pull policy for controller component | +| controller.image.repository | string | `""` | Overrides default image repository for controller component | +| controller.image.tag | string | `""` | Overrides default image tag for controller component | +| controller.resources | object | `{}` | Overrides default resources for controller component | +| controller.tolerations | list | `[{"effect":"NoSchedule","key":"node-role.kubernetes.io/master","operator":"Equal","value":"true"}]` | Tolerations for controller component | +| global.image.pullPolicy | string | `"IfNotPresent"` | Default image pull policy for node and controller components | +| global.image.repository | string | `"docker.io/openebs/rawfile-localpv"` | Default image repository for node and controller components | +| global.image.tag | string | `""` | Default image tag for node and controller components (uses AppVersion if empty) | +| global.resources.limits.cpu | int | `1` | Default CPU Limit for node and controller components | +| global.resources.limits.memory | string | `"100Mi"` | Default Memory Limit for node and controller components | +| global.resources.requests.cpu | string | `"10m"` | Default CPU Request (Guaranty) for node and controller components | +| global.resources.requests.memory | string | `"100Mi"` | Default Memory Request (Guaranty) for node and controller components | +| imagePullSecrets | list | `[]` | Sets image pull secret while pulling images from a private registry | +| node.dataDirPath | string | `"/var/lib/rawfile-localpv"` | Data dir path for provisioner to be used by provisioner | +| node.driverRegistrar.image.repository | string | `"registry.k8s.io/sig-storage/csi-node-driver-registrar"` | Image Repository for `csi-node-driver-registrar` | +| node.driverRegistrar.image.tag | string | `"v2.2.0"` | Image Tag for `csi-node-driver-registrar` | +| node.externalProvisioner.image.repository | string | `"registry.k8s.io/sig-storage/csi-provisioner"` | Image Repository for `csi-provisioner` | +| node.externalProvisioner.image.tag | string | `"v2.2.2"` | Image Tag for `csi-provisioner` | +| node.externalSnapshotter.image.repository | string | `"registry.k8s.io/sig-storage/csi-snapshotter"` | Image Repository for `csi-snapshotter` | +| node.externalSnapshotter.image.tag | string | `"v5.0.1"` | Image Tag for `csi-snapshotter` | +| node.image.pullPolicy | string | `""` | Overrides default image pull policy for node component | +| node.image.repository | string | `""` | Overrides default image repository for node component | +| node.image.tag | string | `""` | Overrides default image tag for node component | +| node.metrics.enabled | bool | `false` | | +| node.resources | object | `{}` | Overrides default resources for node component | +| node.tolerations | list | `[{"operator":"Exist"}]` | Tolerations for node component | +| provisionerName | string | `"rawfile.csi.openebs.io"` | Name of the registered CSI Driver in cluster | +| serviceMonitor.enabled | bool | `false` | Enables prometheus service monitor | +| serviceMonitor.interval | string | `"1m"` | Sets prometheus target interval | +| storageClasses[0].allowVolumeExpansion | bool | `true` | volumes are able to expand/resize or not? | +| storageClasses[0].enabled | bool | `true` | Enable or disable StorageClass | +| storageClasses[0].name | string | `"rawfile-localpv"` | Name of the StorageClass | +| storageClasses[0].reclaimPolicy | string | `"Delete"` | Sets default reclaimPolicy for StorageClass volumes | +| storageClasses[0].volumeBindingMode | string | `"WaitForFirstConsumer"` | Sets volumeBindingMode for StorageClass | + diff --git a/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml index bed2a0c..8663657 100644 --- a/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml @@ -30,17 +30,14 @@ spec: serviceAccount: {{ include "rawfile-csi.fullname" . }}-driver priorityClassName: system-cluster-critical tolerations: - - key: "node-role.kubernetes.io/master" - operator: Equal - value: "true" - effect: NoSchedule + {{- .Values.controller.tolerations | toYaml | nindent 8 }} volumes: - name: socket-dir emptyDir: {} containers: - name: csi-driver - image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag }}" - imagePullPolicy: {{ .Values.controller.image.pullPolicy }} + image: "{{ include "rawfile-csi.controller-image" . }}" + imagePullPolicy: "{{ include "rawfile-csi.controller-pull-policy" . }}" args: - csi-driver - --disable-metrics @@ -50,10 +47,10 @@ spec: - name: CSI_ENDPOINT value: unix:///csi/csi.sock - name: IMAGE_REPOSITORY - value: "{{ .Values.controller.image.repository }}" - {{- if regexMatch "^.*-ci$" .Values.controller.image.tag }} + value: "{{ include "rawfile-csi.controller-image-repository" . }}" + {{- if regexMatch "^.*-ci$" (include "rawfile-csi.controller-image-tag" .) }} - name: IMAGE_TAG - value: "{{ .Values.controller.image.tag }}" + value: "{{ include "rawfile-csi.controller-image-tag" . }}" {{- end }} volumeMounts: - name: socket-dir @@ -62,9 +59,9 @@ spec: - name: csi-probe containerPort: 9808 resources: - {{- toYaml .Values.controller.resources | nindent 12 }} + {{- include "rawfile-csi.controller-resources" . | nindent 12 }} - name: external-resizer - image: k8s.gcr.io/sig-storage/csi-resizer:v1.2.0 + image: {{ printf "%s:%s" .Values.controller.externalResizer.image.repository .Values.controller.externalResizer.image.tag }} imagePullPolicy: IfNotPresent args: - "--csi-address=$(ADDRESS)" diff --git a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml index 06e1d91..9c99075 100644 --- a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml @@ -35,7 +35,7 @@ spec: serviceAccount: {{ include "rawfile-csi.fullname" . }}-driver priorityClassName: system-node-critical tolerations: - - operator: "Exists" + {{- .Values.node.tolerations | toYaml | nindent 8 }} volumes: - name: registration-dir hostPath: @@ -51,12 +51,12 @@ spec: type: DirectoryOrCreate - name: data-dir hostPath: - path: /var/csi/rawfile + path: {{ .Values.node.dataDirPath }} type: DirectoryOrCreate containers: - name: csi-driver - image: "{{ .Values.node.image.repository }}:{{ .Values.node.image.tag }}" - imagePullPolicy: {{ .Values.node.image.pullPolicy }} + image: "{{ include "rawfile-csi.node-image" . }}" + imagePullPolicy: "{{ include "rawfile-csi.node-pull-policy" . }}" securityContext: privileged: true env: @@ -65,10 +65,10 @@ spec: - name: CSI_ENDPOINT value: unix:///csi/csi.sock - name: IMAGE_REPOSITORY - value: "{{ .Values.node.image.repository }}" - {{- if regexMatch "^.*-ci$" .Values.node.image.tag }} + value: "{{ include "rawfile-csi.node-image-repository" . }}" + {{- if regexMatch "^.*-ci$" (include "rawfile-csi.node-image-tag" .) }} - name: IMAGE_TAG - value: "{{ .Values.node.image.tag }}" + value: "{{ include "rawfile-csi.node-image-tag" . }}" {{- end }} - name: NODE_ID valueFrom: @@ -89,9 +89,9 @@ spec: - name: data-dir mountPath: /data resources: - {{- toYaml .Values.node.resources | nindent 12 }} + {{- include "rawfile-csi.controller-resources" . | nindent 12 }} - name: node-driver-registrar - image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.2.0 + image: {{ printf "%s:%s" .Values.node.driverRegistrar.image.repository .Values.node.driverRegistrar.image.tag }} imagePullPolicy: IfNotPresent args: - --csi-address=$(ADDRESS) @@ -124,7 +124,7 @@ spec: cpu: 10m memory: 100Mi - name: external-provisioner - image: k8s.gcr.io/sig-storage/csi-provisioner:v2.2.2 + image: {{ printf "%s:%s" .Values.node.externalProvisioner.image.repository .Values.node.externalProvisioner.image.tag }} imagePullPolicy: IfNotPresent args: - "--csi-address=$(ADDRESS)" @@ -154,7 +154,7 @@ spec: - name: socket-dir mountPath: /csi - name: external-snapshotter - image: gcr.io/k8s-staging-sig-storage/csi-snapshotter:v5.0.1 + image: {{ printf "%s:%s" .Values.node.externalSnapshotter.image.repository .Values.node.externalSnapshotter.image.tag }} imagePullPolicy: IfNotPresent args: - "--csi-address=$(ADDRESS)" diff --git a/deploy/charts/rawfile-csi/templates/01-storage-class.yaml b/deploy/charts/rawfile-csi/templates/01-storage-class.yaml new file mode 100644 index 0000000..09a8fd9 --- /dev/null +++ b/deploy/charts/rawfile-csi/templates/01-storage-class.yaml @@ -0,0 +1,14 @@ +{{- $vals := .Values }} +{{- range $class := .Values.storageClasses }} +{{- if $class.enabled }} +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: {{ $class.name }} +provisioner: {{ $vals.provisionerName }} +reclaimPolicy: {{ $class.reclaimPolicy }} +volumeBindingMode: {{ $class.volumeBindingMode }} +allowVolumeExpansion: {{ $class.allowVolumeExpansion }} +--- +{{- end }} +{{- end }} diff --git a/deploy/charts/rawfile-csi/templates/_helpers.tpl b/deploy/charts/rawfile-csi/templates/_helpers.tpl index 6a093e3..b630389 100644 --- a/deploy/charts/rawfile-csi/templates/_helpers.tpl +++ b/deploy/charts/rawfile-csi/templates/_helpers.tpl @@ -61,3 +61,52 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Some helpers to handle image global information +*/}} +{{- define "rawfile-csi.controller-image-tag" -}} +{{- $imageTag := .Values.controller.image.tag | default (.Values.global.image.tag | default .Chart.AppVersion) }} +{{- printf "%s" $imageTag }} +{{- end }} + +{{- define "rawfile-csi.controller-image-repository" -}} +{{- $imageRepo := (.Values.controller.image.repository | default .Values.global.image.repository) }} +{{- printf "%s" $imageRepo }} +{{- end }} + +{{- define "rawfile-csi.controller-image" -}} +{{- $imageTag := .Values.controller.image.tag | default (.Values.global.image.tag | default .Chart.AppVersion) }} +{{- printf "%s:%s" (include "rawfile-csi.controller-image-repository" .) (include "rawfile-csi.controller-image-tag" .) }} +{{- end }} + +{{- define "rawfile-csi.controller-pull-policy" -}} +{{- printf "%s" (.Values.controller.image.pullPolicy | default .Values.global.image.pullPolicy) }} +{{- end }} + +{{- define "rawfile-csi.controller-resources" -}} +{{- toYaml (.Values.controller.resources | default .Values.global.resources) }} +{{- end }} + +{{- define "rawfile-csi.node-image-tag" -}} +{{- $imageTag := .Values.node.image.tag | default (.Values.global.image.tag | default .Chart.AppVersion) }} +{{- printf "%s" $imageTag }} +{{- end }} + +{{- define "rawfile-csi.node-image-repository" -}} +{{- $imageRepo := (.Values.node.image.repository | default .Values.global.image.repository) }} +{{- printf "%s" $imageRepo }} +{{- end }} + +{{- define "rawfile-csi.node-image" -}} +{{- $imageTag := .Values.node.image.tag | default (.Values.global.image.tag | default .Chart.AppVersion) }} +{{- printf "%s:%s" (include "rawfile-csi.node-image-repository" .) (include "rawfile-csi.node-image-tag" .) }} +{{- end }} + +{{- define "rawfile-csi.node-pull-policy" -}} +{{- printf "%s" (.Values.node.image.pullPolicy | default .Values.global.image.pullPolicy) }} +{{- end }} + +{{- define "rawfile-csi.node-resources" -}} +{{- toYaml (.Values.node.resources | default .Values.global.resources) }} +{{- end }} diff --git a/deploy/charts/rawfile-csi/values.yaml b/deploy/charts/rawfile-csi/values.yaml index 69fe959..30fc6af 100644 --- a/deploy/charts/rawfile-csi/values.yaml +++ b/deploy/charts/rawfile-csi/values.yaml @@ -1,27 +1,125 @@ +# -- Name of the registered CSI Driver in cluster provisionerName: "rawfile.csi.openebs.io" -defaults: &defaults +global: image: + # -- Default image repository for node and controller components repository: docker.io/openebs/rawfile-localpv - tag: 0.8.0 - pullPolicy: Always + # -- Default image tag for node and controller components (uses AppVersion if empty) + tag: "" + # -- Default image pull policy for node and controller components + pullPolicy: IfNotPresent resources: limits: + # -- Default CPU Limit for node and controller components cpu: 1 + # -- Default Memory Limit for node and controller components memory: 100Mi requests: + # -- Default CPU Request (Guaranty) for node and controller components cpu: 10m + # -- Default Memory Request (Guaranty) for node and controller components memory: 100Mi controller: - <<: *defaults + image: + # -- Overrides default image repository for controller component + repository: "" + # -- Overrides default image tag for controller component + tag: "" + # -- Overrides default image pull policy for controller component + pullPolicy: "" + + externalResizer: + image: + # -- Image Repository for `csi-resizer` + repository: registry.k8s.io/sig-storage/csi-resizer + # -- Image tag for `csi-resizer` + tag: v1.2.0 + + # -- Overrides default resources for controller component + resources: + {} + # limits: + # cpu: 1 + # memory: 100Mi + # requests: + # cpu: 10m + # memory: 100Mi + + # -- Tolerations for controller component + tolerations: + - key: "node-role.kubernetes.io/master" + operator: Equal + value: "true" + effect: NoSchedule node: - <<: *defaults + image: + # -- Overrides default image repository for node component + repository: "" + # -- Overrides default image tag for node component + tag: "" + # -- Overrides default image pull policy for node component + pullPolicy: "" + + driverRegistrar: + image: + # -- Image Repository for `csi-node-driver-registrar` + repository: registry.k8s.io/sig-storage/csi-node-driver-registrar + # -- Image Tag for `csi-node-driver-registrar` + tag: v2.2.0 + + externalProvisioner: + image: + # -- Image Repository for `csi-provisioner` + repository: registry.k8s.io/sig-storage/csi-provisioner + # -- Image Tag for `csi-provisioner` + tag: v2.2.2 + + externalSnapshotter: + image: + # -- Image Repository for `csi-snapshotter` + repository: registry.k8s.io/sig-storage/csi-snapshotter + # -- Image Tag for `csi-snapshotter` + tag: v5.0.1 + + # -- Data dir path for provisioner to be used by provisioner + dataDirPath: /var/lib/rawfile-localpv + + # -- Overrides default resources for node component + resources: + {} + # limits: + # cpu: 1 + # memory: 100Mi + # requests: + # cpu: 10m + # memory: 100Mi metrics: enabled: false + # -- Tolerations for node component + tolerations: + - operator: Exist + +# -- Sets image pull secret while pulling images from a private registry imagePullSecrets: [] + serviceMonitor: - enabled: true + # -- Enables prometheus service monitor + enabled: false + # -- Sets prometheus target interval interval: 1m + +storageClasses: + - # -- Name of the StorageClass + name: rawfile-localpv + # -- Enable or disable StorageClass + enabled: true + # -- Sets volumeBindingMode for StorageClass + volumeBindingMode: WaitForFirstConsumer + # -- volumes are able to expand/resize or not? + allowVolumeExpansion: true + # -- Sets default reclaimPolicy for StorageClass volumes + reclaimPolicy: Delete From 3a44144fd8b639437bc71146751ceea0d117a4e4 Mon Sep 17 00:00:00 2001 From: Muhammed Hussein Karimi Date: Sun, 25 Feb 2024 20:02:16 +0330 Subject: [PATCH 2/7] =?UTF-8?q?=E2=9C=A8=20feat:=20move=20priorityClassNam?= =?UTF-8?q?e=20to=20values=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Muhammed Hussein Karimi --- deploy/charts/rawfile-csi/README.md | 2 ++ .../charts/rawfile-csi/templates/01-controller-plugin.yaml | 2 +- deploy/charts/rawfile-csi/templates/01-node-plugin.yaml | 2 +- deploy/charts/rawfile-csi/values.yaml | 6 ++++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/deploy/charts/rawfile-csi/README.md b/deploy/charts/rawfile-csi/README.md index adeb034..1d5de0f 100644 --- a/deploy/charts/rawfile-csi/README.md +++ b/deploy/charts/rawfile-csi/README.md @@ -17,6 +17,7 @@ Kubernetes: `>= 1.21` | controller.image.pullPolicy | string | `""` | Overrides default image pull policy for controller component | | controller.image.repository | string | `""` | Overrides default image repository for controller component | | controller.image.tag | string | `""` | Overrides default image tag for controller component | +| controller.priorityClassName | string | `"system-cluster-critical"` | priorityClassName for controller component since this part is critical for cluster `system-cluster-critical` is default | | controller.resources | object | `{}` | Overrides default resources for controller component | | controller.tolerations | list | `[{"effect":"NoSchedule","key":"node-role.kubernetes.io/master","operator":"Equal","value":"true"}]` | Tolerations for controller component | | global.image.pullPolicy | string | `"IfNotPresent"` | Default image pull policy for node and controller components | @@ -38,6 +39,7 @@ Kubernetes: `>= 1.21` | node.image.repository | string | `""` | Overrides default image repository for node component | | node.image.tag | string | `""` | Overrides default image tag for node component | | node.metrics.enabled | bool | `false` | | +| node.priorityClassName | string | `"system-node-critical"` | priorityClassName for node component since this part is critical for node `system-node-critical` is default | | node.resources | object | `{}` | Overrides default resources for node component | | node.tolerations | list | `[{"operator":"Exist"}]` | Tolerations for node component | | provisionerName | string | `"rawfile.csi.openebs.io"` | Name of the registered CSI Driver in cluster | diff --git a/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml index 8663657..0438c3e 100644 --- a/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml @@ -28,7 +28,7 @@ spec: labels: *selectorLabels spec: serviceAccount: {{ include "rawfile-csi.fullname" . }}-driver - priorityClassName: system-cluster-critical + priorityClassName: {{ .Values.controller.priorityClassName }} tolerations: {{- .Values.controller.tolerations | toYaml | nindent 8 }} volumes: diff --git a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml index 9c99075..277aa9e 100644 --- a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml @@ -33,7 +33,7 @@ spec: labels: *selectorLabels spec: serviceAccount: {{ include "rawfile-csi.fullname" . }}-driver - priorityClassName: system-node-critical + priorityClassName: {{ .Values.node.priorityClassName }} tolerations: {{- .Values.node.tolerations | toYaml | nindent 8 }} volumes: diff --git a/deploy/charts/rawfile-csi/values.yaml b/deploy/charts/rawfile-csi/values.yaml index 30fc6af..ec54f85 100644 --- a/deploy/charts/rawfile-csi/values.yaml +++ b/deploy/charts/rawfile-csi/values.yaml @@ -47,6 +47,9 @@ controller: # cpu: 10m # memory: 100Mi + # -- priorityClassName for controller component since this part is critical for cluster `system-cluster-critical` is default + priorityClassName: system-cluster-critical + # -- Tolerations for controller component tolerations: - key: "node-role.kubernetes.io/master" @@ -99,6 +102,9 @@ node: metrics: enabled: false + # -- priorityClassName for node component since this part is critical for node `system-node-critical` is default + priorityClassName: system-node-critical + # -- Tolerations for node component tolerations: - operator: Exist From 4d15705bb531da9f3aad6db33348e707f047795d Mon Sep 17 00:00:00 2001 From: Muhammed Hussein Karimi Date: Sun, 25 Feb 2024 20:34:02 +0330 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=93=9D=20docs:=20refer=20to=20chart?= =?UTF-8?q?=20docs=20in=20main=20readme=20and=20update=20usage=20based=20o?= =?UTF-8?q?n=20new=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Muhammed Hussein Karimi --- README.md | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d49c847..22a8378 100644 --- a/README.md +++ b/README.md @@ -7,27 +7,20 @@ Kubernetes LocalPVs on Steroids Prerequisite --- + - Kubernetes: 1.21+ Install --- + `helm install -n kube-system rawfile-csi ./deploy/charts/rawfile-csi/` +> Refer to chart's [README](./deploy/charts/rawfile-csi/README.md) to see the [values](./deploy/charts/rawfile-csi/values.yaml) documentation if you need to customize it + Usage --- -Create a `StorageClass` with your desired options: - -``` -apiVersion: storage.k8s.io/v1 -kind: StorageClass -metadata: - name: my-sc -provisioner: rawfile.csi.openebs.io -reclaimPolicy: Delete -volumeBindingMode: WaitForFirstConsumer -allowVolumeExpansion: true -``` +You can create one or more storage classes using chart, by default we have a storage class named `rawfile-localpv`, but you can change the name or other options by changing chart values Features --- @@ -36,12 +29,12 @@ Features - [x] Dynamic provisioning - [x] Enforced volume size limit - [x] Access Modes - - [x] ReadWriteOnce - - ~~ReadOnlyMany~~ - - ~~ReadWriteMany~~ + - [x] ReadWriteOnce + - ~~ReadOnlyMany~~ + - ~~ReadWriteMany~~ - [ ] Volume modes - - [x] `Filesystem` mode - - [ ] `Block` mode + - [x] `Filesystem` mode + - [ ] `Block` mode - [x] Volume metrics - [x] Supports fsTypes: `ext4`, `btrfs`, `xfs` - [x] Online expansion: If fs supports it (e.g. ext4, btrfs, xfs) @@ -52,24 +45,28 @@ Features Motivation --- + One might have a couple of reasons to consider using node-based (rather than network-based) storage solutions: + - Performance: Almost no network-based storage solution can keep up with baremetal disk performance in terms of IOPS/latency/throughput combined. And you’d like to get the best out of the SSD you’ve got! - On-premise Environment: You might not be able to afford the cost of upgrading all your networking infrastructure, to get the best out of your network-based storage solution. - Complexity: Network-based solutions are distributed systems. And distributed systems are not easy! You might want to have a system that is easier to understand and to reason about. Also, with less complexity, you can fix unpredicted issues more easily. Using node-based storage has come a long way since k8s was born. Right now, OpenEBS’s hostPath makes it pretty easy to automatically provision hostPath PVs and use them in your workloads. There are known limitations though: + - You can’t monitor volume usage: There are hacky workarounds to run “du” regularly, but that could prove to be a performance killer, since it could put a lot of burden on your CPU and cause your filesystem cache to fill up. Not really good for a production workload. -- You can’t enforce hard limits on your volume’s size: Again, you can hack your way around it, with the same caveats. +- You can’t enforce hard limits on your volume’s size: Again, you can hack your way around it, with the same caveats. - You are stuck with whatever filesystem your kubelet node is offering - You can’t customize your filesystem: All these issues stem from the same root cause: hostPath/LocalPVs are simple bind-mounts from the host filesystem into the pod. The idea here is to use a single file as the block device, using Linux’s loop, and create a volume based on it. That way: + - You can monitor volume usage by running df in `O(1)` since devices are mounted separately. - The size limit is enforced by the operating system, based on the backing file size. - Since volumes are backed by different files, each file could be formatted using different filesystems, and/or customized with different filesystem options. - ## License + [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fopenebs%2Frawfile-localpv.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fopenebs%2Frawfile-localpv?ref=badge_large) From 80a1507f7a6aca3623398c307fb3b2b82eb067f6 Mon Sep 17 00:00:00 2001 From: Muhammed Hussein Karimi Date: Wed, 28 Feb 2024 09:31:28 +0330 Subject: [PATCH 4/7] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20typo:=20better=20de?= =?UTF-8?q?fault=20value=20for=20dataDir=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Muhammed Hussein Karimi --- deploy/charts/rawfile-csi/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/charts/rawfile-csi/values.yaml b/deploy/charts/rawfile-csi/values.yaml index ec54f85..dbf206f 100644 --- a/deploy/charts/rawfile-csi/values.yaml +++ b/deploy/charts/rawfile-csi/values.yaml @@ -88,7 +88,7 @@ node: tag: v5.0.1 # -- Data dir path for provisioner to be used by provisioner - dataDirPath: /var/lib/rawfile-localpv + dataDirPath: /var/csi/rawfile # -- Overrides default resources for node component resources: From 75537940a89ed539d3caf19a1821a22a678ea840 Mon Sep 17 00:00:00 2001 From: Muhammed Hussein Karimi Date: Wed, 28 Feb 2024 12:18:56 +0330 Subject: [PATCH 5/7] =?UTF-8?q?=E2=9C=A8=20feat:=20propagate=20node=20data?= =?UTF-8?q?=20dir=20customization=20into=20task=20file=20and=20configurati?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Muhammed Hussein Karimi --- deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml | 2 ++ deploy/charts/rawfile-csi/templates/01-node-plugin.yaml | 2 ++ orchestrator/k8s.py | 1 + rawfile.py | 4 +++- templates/task.yaml | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml index 0438c3e..c7e83eb 100644 --- a/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-controller-plugin.yaml @@ -46,6 +46,8 @@ spec: value: "{{ .Values.provisionerName }}" - name: CSI_ENDPOINT value: unix:///csi/csi.sock + - name: NODE_DATADIR + value: "{{ .Values.node.dataDirPath }}" - name: IMAGE_REPOSITORY value: "{{ include "rawfile-csi.controller-image-repository" . }}" {{- if regexMatch "^.*-ci$" (include "rawfile-csi.controller-image-tag" .) }} diff --git a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml index 277aa9e..333f1b9 100644 --- a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml @@ -62,6 +62,8 @@ spec: env: - name: PROVISIONER_NAME value: "{{ .Values.provisionerName }}" + - name: NODE_DATADIR + value: "{{ .Values.node.dataDirPath }}" - name: CSI_ENDPOINT value: unix:///csi/csi.sock - name: IMAGE_REPOSITORY diff --git a/orchestrator/k8s.py b/orchestrator/k8s.py index 625b48b..b22f3e9 100644 --- a/orchestrator/k8s.py +++ b/orchestrator/k8s.py @@ -51,6 +51,7 @@ def run_on_node(fn, node): "cmd": json.dumps(fn), "image_repository": CONFIG["image_repository"], "image_tag": CONFIG["image_tag"], + "datadir": CONFIG["node_datadir"] } template = Path("./templates/task.yaml").read_bytes().decode() manifest = template.format(**ctx) diff --git a/rawfile.py b/rawfile.py index 634a916..80aea06 100755 --- a/rawfile.py +++ b/rawfile.py @@ -16,9 +16,11 @@ @click.group() @click.option("--image-repository", envvar="IMAGE_REPOSITORY") @click.option("--image-tag", envvar="IMAGE_TAG") -def cli(image_repository, image_tag): +@click.option("--node-datadir", envvar="NODE_DATADIR") +def cli(image_repository, image_tag, node_datadir): CONFIG["image_repository"] = image_repository CONFIG["image_tag"] = image_tag + CONFIG["node_datadir"] = node_datadir @cli.command() diff --git a/templates/task.yaml b/templates/task.yaml index 4445af8..a02aa77 100644 --- a/templates/task.yaml +++ b/templates/task.yaml @@ -11,7 +11,7 @@ spec: volumes: - name: data-dir hostPath: - path: /var/csi/rawfile + path: {datadir} type: DirectoryOrCreate nodeSelector: {nodeSelector} containers: From 51a75d64495996a9f0074304abe31224eb063e57 Mon Sep 17 00:00:00 2001 From: Muhammed Hussein Karimi Date: Wed, 4 Sep 2024 19:14:05 +0330 Subject: [PATCH 6/7] =?UTF-8?q?=E2=9C=A8=20feat:=20making=20metrics=20more?= =?UTF-8?q?=20customizable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Muhammed Hussein Karimi --- .../rawfile-csi/templates/01-node-plugin.yaml | 6 +++++- .../rawfile-csi/templates/01-servicemonitor.yaml | 4 +++- deploy/charts/rawfile-csi/values.yaml | 13 ++++++++----- metrics.py | 4 ++-- rawfile.py | 9 ++++++--- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml index 333f1b9..60285c0 100644 --- a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml @@ -9,7 +9,7 @@ spec: type: ClusterIP ports: - name: metrics - port: 9100 + port: {{ .Values.metrics.port }} targetPort: metrics protocol: TCP selector: @@ -77,6 +77,10 @@ spec: fieldRef: apiVersion: v1 fieldPath: spec.nodeName + - name: ENABLE_METRICS + value: {{ .Values.metrics.enabled | toString | quote }} + - name: METRICS_PORT + value: {{ .Values.metrics.port | toString | quote }} ports: - name: metrics containerPort: 9100 diff --git a/deploy/charts/rawfile-csi/templates/01-servicemonitor.yaml b/deploy/charts/rawfile-csi/templates/01-servicemonitor.yaml index ae4c58d..6f8bc11 100644 --- a/deploy/charts/rawfile-csi/templates/01-servicemonitor.yaml +++ b/deploy/charts/rawfile-csi/templates/01-servicemonitor.yaml @@ -1,4 +1,5 @@ -{{- if .Values.serviceMonitor.enabled }} +{{- if .Values.metrics.enabled }} +{{- if .Values.metrics.serviceMonitor.enabled }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: @@ -19,3 +20,4 @@ spec: {{- include "rawfile-csi.selectorLabels" . | nindent 6 }} component: node {{- end }} +{{- end }} diff --git a/deploy/charts/rawfile-csi/values.yaml b/deploy/charts/rawfile-csi/values.yaml index dbf206f..7ac9469 100644 --- a/deploy/charts/rawfile-csi/values.yaml +++ b/deploy/charts/rawfile-csi/values.yaml @@ -112,11 +112,14 @@ node: # -- Sets image pull secret while pulling images from a private registry imagePullSecrets: [] -serviceMonitor: - # -- Enables prometheus service monitor - enabled: false - # -- Sets prometheus target interval - interval: 1m +metrics: + enabled: true + port: 9100 + serviceMonitor: + # -- Enables prometheus service monitor + enabled: false + # -- Sets prometheus target interval + interval: 1m storageClasses: - # -- Name of the StorageClass diff --git a/metrics.py b/metrics.py index 8f4d6a7..2009e9c 100644 --- a/metrics.py +++ b/metrics.py @@ -35,6 +35,6 @@ def collect(self): return [remaining_capacity, volume_used, volume_total] -def expose_metrics(node): +def expose_metrics(node, port): REGISTRY.register(VolumeStatsCollector(node)) - start_http_server(9100) + start_http_server(port) diff --git a/rawfile.py b/rawfile.py index 80aea06..2e3a3eb 100755 --- a/rawfile.py +++ b/rawfile.py @@ -26,11 +26,14 @@ def cli(image_repository, image_tag, node_datadir): @cli.command() @click.option("--endpoint", envvar="CSI_ENDPOINT", default="0.0.0.0:5000") @click.option("--nodeid", envvar="NODE_ID") -@click.option("--enable-metrics/--disable-metrics", default=True) -def csi_driver(endpoint, nodeid, enable_metrics): +@click.option("--metrics-port", envvar="METRICS_PORT", default=9100) +@click.option( + "--enable-metrics/--disable-metrics", envvar="ENABLE_METRICS", default=True +) +def csi_driver(endpoint, nodeid, enable_metrics, metrics_port): migrate_all_volume_schemas() if enable_metrics: - expose_metrics(nodeid) + expose_metrics(nodeid, metrics_port) server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) csi_pb2_grpc.add_IdentityServicer_to_server( bd2fs.Bd2FsIdentityServicer(rawfile_servicer.RawFileIdentityServicer()), server From 7c24eac964749bd24db86913b1a4399bb584295c Mon Sep 17 00:00:00 2001 From: Muhammed Hussein Karimi Date: Sat, 7 Sep 2024 13:25:34 +0330 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=93=9D=20docs:=20update=20docs=20base?= =?UTF-8?q?d=20on=20new=20changes=20on=20metrics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Muhammed Hussein Karimi --- deploy/charts/rawfile-csi/README.md | 8 +++++--- deploy/charts/rawfile-csi/templates/01-node-plugin.yaml | 2 +- deploy/charts/rawfile-csi/values.yaml | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/deploy/charts/rawfile-csi/README.md b/deploy/charts/rawfile-csi/README.md index 1d5de0f..f0de326 100644 --- a/deploy/charts/rawfile-csi/README.md +++ b/deploy/charts/rawfile-csi/README.md @@ -28,7 +28,11 @@ Kubernetes: `>= 1.21` | global.resources.requests.cpu | string | `"10m"` | Default CPU Request (Guaranty) for node and controller components | | global.resources.requests.memory | string | `"100Mi"` | Default Memory Request (Guaranty) for node and controller components | | imagePullSecrets | list | `[]` | Sets image pull secret while pulling images from a private registry | -| node.dataDirPath | string | `"/var/lib/rawfile-localpv"` | Data dir path for provisioner to be used by provisioner | +| metrics.enabled | bool | `true` | Completely enable or disable metrics | +| metrics.port | int | `9100` | Sets metrics port | +| metrics.serviceMonitor.enabled | bool | `false` | Enables prometheus service monitor | +| metrics.serviceMonitor.interval | string | `"1m"` | Sets prometheus target interval | +| node.dataDirPath | string | `"/var/csi/rawfile"` | Data dir path for provisioner to be used by provisioner | | node.driverRegistrar.image.repository | string | `"registry.k8s.io/sig-storage/csi-node-driver-registrar"` | Image Repository for `csi-node-driver-registrar` | | node.driverRegistrar.image.tag | string | `"v2.2.0"` | Image Tag for `csi-node-driver-registrar` | | node.externalProvisioner.image.repository | string | `"registry.k8s.io/sig-storage/csi-provisioner"` | Image Repository for `csi-provisioner` | @@ -43,8 +47,6 @@ Kubernetes: `>= 1.21` | node.resources | object | `{}` | Overrides default resources for node component | | node.tolerations | list | `[{"operator":"Exist"}]` | Tolerations for node component | | provisionerName | string | `"rawfile.csi.openebs.io"` | Name of the registered CSI Driver in cluster | -| serviceMonitor.enabled | bool | `false` | Enables prometheus service monitor | -| serviceMonitor.interval | string | `"1m"` | Sets prometheus target interval | | storageClasses[0].allowVolumeExpansion | bool | `true` | volumes are able to expand/resize or not? | | storageClasses[0].enabled | bool | `true` | Enable or disable StorageClass | | storageClasses[0].name | string | `"rawfile-localpv"` | Name of the StorageClass | diff --git a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml index 60285c0..e16c0e7 100644 --- a/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml +++ b/deploy/charts/rawfile-csi/templates/01-node-plugin.yaml @@ -83,7 +83,7 @@ spec: value: {{ .Values.metrics.port | toString | quote }} ports: - name: metrics - containerPort: 9100 + containerPort: {{ .Values.metrics.port }} - name: csi-probe containerPort: 9808 volumeMounts: diff --git a/deploy/charts/rawfile-csi/values.yaml b/deploy/charts/rawfile-csi/values.yaml index 7ac9469..9ade865 100644 --- a/deploy/charts/rawfile-csi/values.yaml +++ b/deploy/charts/rawfile-csi/values.yaml @@ -113,7 +113,9 @@ node: imagePullSecrets: [] metrics: + # -- Completely enable or disable metrics enabled: true + # -- Sets metrics port port: 9100 serviceMonitor: # -- Enables prometheus service monitor