Skip to content

Commit 03d3252

Browse files
committed
✨ Add Pool support to helm chart
Signed-off-by: Muhammed Hussain Karimi <[email protected]>
1 parent 1cf534f commit 03d3252

File tree

6 files changed

+72
-14
lines changed

6 files changed

+72
-14
lines changed

deploy/helm/rawfile-localpv/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Please follow the [install guide](https://github.com/openebs/rawfile-localpv/tre
2828
|-----|------|---------|-------------|
2929
| auth.enabled | bool | `true` | Enables authentication for internal gRPC server |
3030
| auth.token | string | `""` | Sets authentication token for internal gRPC server, will generate one if nothing provided |
31-
| capacityOverride | string | `""` | Overrides total capacity of the storage for data dir storage on each host (Support size values) [e.g. `50GB` or `10MiB`] |
3231
| controller.externalResizer.image.registry | string | `""` | Image registry for `csi-resizer` |
3332
| controller.externalResizer.image.repository | string | `"sig-storage/csi-resizer"` | Image Repository for `csi-resizer` |
3433
| controller.externalResizer.image.tag | string | `"v1.13.2"` | Image tag for `csi-resizer` |
@@ -58,6 +57,7 @@ Please follow the [install guide](https://github.com/openebs/rawfile-localpv/tre
5857
| metrics.serviceMonitor.enabled | bool | `false` | Enables prometheus service monitor |
5958
| metrics.serviceMonitor.interval | string | `"1m"` | Sets prometheus target interval |
6059
| node.dataDirPath | string | `"/var/csi/rawfile"` | Data dir path for provisioner to be used by provisioner |
60+
| node.defaultPool | string | `"default"` | Default storage pool name |
6161
| node.driverRegistrar.image.registry | string | `""` | Image Registry for `csi-node-driver-registrar` |
6262
| node.driverRegistrar.image.repository | string | `"sig-storage/csi-node-driver-registrar"` | Image Repository for `csi-node-driver-registrar` |
6363
| node.driverRegistrar.image.tag | string | `"v2.13.0"` | Image Tag for `csi-node-driver-registrar` |
@@ -81,9 +81,9 @@ Please follow the [install guide](https://github.com/openebs/rawfile-localpv/tre
8181
| node.snapshotController.image.registry | string | `""` | Image Registry for `snapshot-controller` |
8282
| node.snapshotController.image.repository | string | `"sig-storage/snapshot-controller"` | Image Repository for `snapshot-controller` |
8383
| node.snapshotController.image.tag | string | `"v8.2.1"` | Image Tag for `snapshot-controller` |
84+
| node.storagePools | object | `{"default":{"capacityOverride":"","defaultFs":"ext4","path":"/var/local/openebs/rawfile/default-pool/data","reservedCapacity":""}}` | Storage pools configuration |
8485
| node.tolerations | string | `nil` | Tolerations for node component |
8586
| provisionerName | string | `"rawfile.csi.openebs.io"` | Name of the registered CSI Driver in the cluster |
86-
| reservedCapacity | string | `""` | Used to reserve capacity on each node for data dir storage on each host (Supports percentage and size) [e.g. `25%` or `50GB` or `10MiB`] |
8787
| snapshotClasses[0].deletionPolicy | string | `"Delete"` | Sets deletion policy for snapshots created using this class (Delete or Retain) |
8888
| snapshotClasses[0].enabled | bool | `true` | Enable or disable SnapshotClass |
8989
| snapshotClasses[0].isDefault | bool | `false` | Make the snapshot class as default |

deploy/helm/rawfile-localpv/templates/_helpers.tpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,19 @@ Some helpers to handle image global information
120120
{{- define "rawfile-localpv.metadata-dir-path" -}}
121121
{{- tpl .Values.node.metadataDirPath . }}
122122
{{- end }}
123+
124+
{{- define "rawfile-localpv.pool-volumes" -}}
125+
{{- range $name, $pool := .Values.node.storagePools }}
126+
- name: pool-{{ $name }}
127+
hostPath:
128+
path: {{ tpl $pool.path . }}
129+
type: DirectoryOrCreate
130+
{{- end }}
131+
{{- end }}
132+
133+
{{- define "rawfile-localpv.pool-volume-mounts" -}}
134+
{{- range $name, $pool := .Values.node.storagePools }}
135+
- name: pool-{{ $name }}
136+
mountPath: {{ tpl $pool.path . }}
137+
{{- end }}
138+
{{- end }}

deploy/helm/rawfile-localpv/templates/node-plugin/daemonset.yaml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ spec:
3131
hostPath:
3232
path: {{ include "rawfile-localpv.node-kubelet-path" . }}
3333
type: DirectoryOrCreate
34-
- name: data-dir
35-
hostPath:
36-
path: {{ .Values.node.dataDirPath }}
37-
type: DirectoryOrCreate
3834
- name: metadata-dir
3935
hostPath:
4036
path: {{ include "rawfile-localpv.metadata-dir-path" . }}
@@ -43,6 +39,7 @@ spec:
4339
hostPath:
4440
path: /dev
4541
type: Directory
42+
{{- include "rawfile-localpv.pool-volumes" . | nindent 8 }}
4643
containers:
4744
- name: csi-driver
4845
image: "{{ include "rawfile-localpv.node-image" . }}"
@@ -111,6 +108,28 @@ spec:
111108
name: {{ include "rawfile-localpv.fullname" . }}-secrets
112109
key: internal-signature
113110
{{- end }}
111+
- name: CSI_DRIVER__DEFAULT_POOL
112+
value: {{ .Values.node.defaultPool }}
113+
- name: CSI_DRIVER__STORAGE_POOLS
114+
value: |
115+
{
116+
{{- $keys := keys .Values.node.storagePools | sortAlpha }}
117+
{{- range $i, $name := $keys }}
118+
"{{ $name }}": {
119+
"path": "{{ tpl (index $.Values.node.storagePools $name).path . }}"
120+
{{- with (index $.Values.node.storagePools $name).reservedCapacity }}
121+
, "reserved_capacity": "{{ . | toString }}"
122+
{{- end }}
123+
{{- with (index $.Values.node.storagePools $name).capacityOverride }}
124+
, "capacity_override": "{{ . | toString }}"
125+
{{- end }}
126+
{{- with (index $.Values.node.storagePools $name).defaultFs }}
127+
, "default_fs": "{{ . }}"
128+
{{- end }}
129+
}{{ if lt (add1 $i) (len $keys) }},{{ end }}
130+
{{- end }}
131+
}
132+
114133
ports:
115134
- name: metrics
116135
containerPort: {{ .Values.metrics.port }}
@@ -122,12 +141,11 @@ spec:
122141
- name: mountpoint-dir
123142
mountPath: {{ include "rawfile-localpv.node-kubelet-path" . }}
124143
mountPropagation: "Bidirectional"
125-
- name: data-dir
126-
mountPath: /data
127144
- name: metadata-dir
128145
mountPath: {{ include "rawfile-localpv.metadata-dir-path" . }}
129146
- name: device
130147
mountPath: /dev
148+
{{- include "rawfile-localpv.pool-volume-mounts" . | nindent 12 }}
131149
resources:
132150
{{- include "rawfile-localpv.controller-resources" . | nindent 12 }}
133151
- name: node-driver-registrar

deploy/helm/rawfile-localpv/values.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ logLevel: INFO
66
# -- Format of the logs (json, pretty)
77
logFormat: json
88

9-
# -- Used to reserve capacity on each node for data dir storage on each host (Supports percentage and size) [e.g. `25%` or `50GB` or `10MiB`]
10-
reservedCapacity: ""
11-
# -- Overrides total capacity of the storage for data dir storage on each host (Support size values) [e.g. `50GB` or `10MiB`]
12-
capacityOverride: ""
13-
149
auth:
1510
# -- Enables authentication for internal gRPC server
1611
enabled: true
@@ -129,6 +124,16 @@ node:
129124
# -- Data dir path for provisioner to be used by provisioner
130125
dataDirPath: /var/csi/rawfile
131126

127+
# -- Default storage pool name
128+
defaultPool: default
129+
# -- Storage pools configuration
130+
storagePools:
131+
default:
132+
path: /var/local/openebs/rawfile/default-pool/data
133+
reservedCapacity: ""
134+
capacityOverride: ""
135+
defaultFs: ext4
136+
132137
# -- Metadata dir path for rawfile volumes metadata and tasks store file
133138
metadataDirPath: /var/local/openebs/rawfile/{{ .Release.Name }}/meta
134139

rawfile/config/model.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
DirectoryPath,
1717
StringConstraints,
1818
Field,
19+
field_validator,
1920
model_validator,
2021
)
2122
from pydantic.networks import IPvAnyAddress
2223
from typing import Annotated, Final, Literal
2324
import consts
2425
from utils.logs import LoggingFormats
2526
from datetime import timedelta
27+
import json
2628

2729
NAME_REGEX: Final[re.Pattern] = re.compile(
2830
r"^(?=.{1,253}$)(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?)(\.([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?))*$"
@@ -108,6 +110,15 @@ class CSIDriverCmd(BaseModel):
108110
description="Type/Mode of the CSI plugin"
109111
)
110112

113+
@field_validator("storage_pools", mode="before")
114+
def parse_dict(cls, v):
115+
if isinstance(v, str):
116+
try:
117+
return json.loads(v)
118+
except Exception as e:
119+
raise ValueError(f"Invalid JSON for storage_pools: {e}")
120+
return v
121+
111122
@model_validator(mode="after")
112123
def validate_node_plugin(
113124
self,

rawfile/volume_schema.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from typing import Final
33

4-
LATEST_SCHEMA_VERSION: Final[int] = 5
4+
LATEST_SCHEMA_VERSION: Final[int] = 6
55

66

77
def migrate_0_to_1(data: dict) -> dict:
@@ -36,6 +36,14 @@ def migrate_4_to_5(data: dict) -> dict:
3636
return data
3737

3838

39+
def migrate_5_to_6(data: dict) -> dict:
40+
from config import config
41+
42+
data["schema_version"] = 6
43+
data["storage_pool"] = config.csi_driver.default_pool
44+
return data
45+
46+
3947
def migrate_to(data: dict, version: int) -> dict:
4048
current = data.get("schema_version", 0)
4149
if current > version:

0 commit comments

Comments
 (0)