From 8cda85db733c50ec2e4df464a0591facd15ccab6 Mon Sep 17 00:00:00 2001 From: geoffrey1330 Date: Fri, 27 Sep 2024 11:17:31 +0100 Subject: [PATCH] applied DRY on storage node daemonset --- charts/README.md | 23 +++++-- .../spdk-csi/templates/storage-node.yaml | 67 +++---------------- charts/latest/spdk-csi/values.yaml | 26 +++++-- 3 files changed, 48 insertions(+), 68 deletions(-) diff --git a/charts/README.md b/charts/README.md index 4b33048..8e01f68 100644 --- a/charts/README.md +++ b/charts/README.md @@ -112,12 +112,23 @@ The following table lists the configurable parameters of the latest Simplyblock | `cachingnode.cpuMask` | the cpu mask for the spdk app to use for caching node | `` | | | `cachingnode.spdkMem` | the amount of hugepage memory to allocate for caching node | `` | | | `cachingnode.spdkImage` | SPDK image uri for caching node | `` | | -| `cachingnode.multipathing` | Enable multipathing for lvol connection | `true` | | -| `storagenode.tolerations.create` | Whether to create tolerations for the storage node | `false` | | -| `storagenode.tolerations.effect` | the effect of tolerations on the storage node | `NoSchedule` | | -| `storagenode.tolerations.key ` | the key of tolerations for the storage node | `dedicated` | | -| `storagenode.tolerations.operator ` | the operator for the storage node tolerations | `Equal` | | -| `storagenode.tolerations.value ` | the value of tolerations for the storage node | `simplyblock-cache` | | +| `cachingnode.multipathing` | Enable multipathing for lvol connection | `true` | | +| `storagenode.daemonsets[0].name` | The name of the storage node DaemonSet | `storage-node-ds` | | +| `storagenode.daemonsets[0].appLabel` | The label applied to the storage node DaemonSet for identification | `storage-node` | | +| `storagenode.daemonsets[0].nodeSelector` | The node selector to specify which nodes the storage node DaemonSet should run on | `storage-node` | | +| `storagenode.daemonsets[0].tolerations.create` | Whether to create tolerations for the storage node | `false` | | +| `storagenode.daemonsets[0].tolerations.effect` | the effect of tolerations on the storage node | `NoSchedule` | | +| `storagenode.daemonsets[0].tolerations.key ` | the key of tolerations for the storage node | `dedicated` | | +| `storagenode.daemonsets[0].tolerations.operator ` | the operator for the storage node tolerations | `Equal` | | +| `storagenode.daemonsets[0].tolerations.value ` | the value of tolerations for the storage node | `simplyblock-cache` | | +| `storagenode.daemonsets[1].name` | The name of the reserve storage node DaemonSet | `storage-node-ds` | | +| `storagenode.daemonsets[1].appLabel` | The label applied to the reserve storage node DaemonSet for identification | `storage-node` | | +| `storagenode.daemonsets[1].nodeSelector` | The node selector to specify which nodes the reserve storage node DaemonSet should run on | `storage-node` | | +| `storagenode.daemonsets[1].tolerations.create` | Whether to create tolerations for the reserve storage node | `false` | | +| `storagenode.daemonsets[1].tolerations.effect` | the effect of tolerations on the reserve storage node | `NoSchedule` | | +| `storagenode.daemonsets[1].tolerations.key ` | the key of tolerations for the reserve storage node | `dedicated` | | +| `storagenode.daemonsets[1].tolerations.operator ` | the operator for the reserve storage node tolerations | `Equal` | | +| `storagenode.daemonsets[1].tolerations.value ` | the value of tolerations for the reserve storage node | `simplyblock-cache` | | | `storagenode.ifname` | the default interface to be used for binding the storage node to host interface | `eth0` | | | `storagenode.cpuMask` | the cpu mask for the spdk app to use for storage node | `` | | | `storagenode.spdkImage` | SPDK image uri for storage node | `` | | diff --git a/charts/latest/spdk-csi/templates/storage-node.yaml b/charts/latest/spdk-csi/templates/storage-node.yaml index b441bf0..2bf3b2f 100644 --- a/charts/latest/spdk-csi/templates/storage-node.yaml +++ b/charts/latest/spdk-csi/templates/storage-node.yaml @@ -31,36 +31,37 @@ roleRef: name: storage-node-role apiGroup: rbac.authorization.k8s.io +{{- range .Values.storagenode.daemonsets }} --- apiVersion: apps/v1 kind: DaemonSet metadata: - name: storage-node-ds + name: {{ .name }} annotations: helm.sh/hook: post-install spec: selector: matchLabels: - app: storage-node + app: {{ .appLabel }} template: metadata: labels: - app: storage-node + app: {{ .appLabel }} spec: serviceAccountName: storage-node-sa nodeSelector: - type: simplyblock-storage-plane + type: {{ .nodeSelector }} volumes: - name: dev-vol hostPath: path: /dev hostNetwork: true - {{- if .Values.storagenode.tolerations.create }} + {{- if .tolerations.create }} tolerations: - - effect: {{ .Values.storagenode.tolerations.effect }} - key: {{ .Values.storagenode.tolerations.key }} - operator: {{ .Values.storagenode.tolerations.operator }} - value: {{ .Values.storagenode.tolerations.value }} + - effect: {{ .tolerations.effect }} + key: {{ .tolerations.key }} + operator: {{ .tolerations.operator }} + value: {{ .tolerations.value }} {{- end }} containers: - name: s-node-api-container @@ -77,50 +78,4 @@ spec: volumeMounts: - name: dev-vol mountPath: /dev - ---- -apiVersion: apps/v1 -kind: DaemonSet -metadata: - name: storage-node-ds-reserve - annotations: - helm.sh/hook: post-install -spec: - selector: - matchLabels: - app: storage-node-reserve - template: - metadata: - labels: - app: storage-node-reserve - spec: - serviceAccountName: storage-node-sa - nodeSelector: - type: simplyblock-storage-plane-reserve - volumes: - - name: dev-vol - hostPath: - path: /dev - hostNetwork: true - {{- if .Values.storagenode.tolerations.create }} - tolerations: - - effect: {{ .Values.storagenode.tolerations.effect }} - key: {{ .Values.storagenode.tolerations.key }} - operator: {{ .Values.storagenode.tolerations.operator }} - value: {{ .Values.storagenode.tolerations.value }} - {{- end }} - containers: - - name: s-node-api-container - image: "{{ .Values.image.simplyblock.repository }}:{{ .Values.image.simplyblock.tag }}" - imagePullPolicy: "{{ .Values.image.simplyblock.pullPolicy }}" - command: ["python", "simplyblock_web/snode_app_k8s.py"] - env: - - name: HOSTNAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - securityContext: - privileged: true - volumeMounts: - - name: dev-vol - mountPath: /dev +{{- end }} diff --git a/charts/latest/spdk-csi/values.yaml b/charts/latest/spdk-csi/values.yaml index 81814c8..0a2e5fb 100644 --- a/charts/latest/spdk-csi/values.yaml +++ b/charts/latest/spdk-csi/values.yaml @@ -97,6 +97,7 @@ benchmarks: 0 # FIXME: this will not work if there are group of nodes with different AMI types like: AL2, AL2023 # AL2_x86_64: eth0 # AL2023_x86_64_STANDARD: ens5 + cachingnode: tolerations: create: false @@ -111,12 +112,6 @@ cachingnode: multipathing: true storagenode: - tolerations: - create: false - effect: NoSchedule - key: dedicated - operator: Equal - value: simplyblock-storage-plane ifname: eth0 cpuMask: spdkImage: @@ -128,3 +123,22 @@ storagenode: numDevices: 1 iobufSmallPoolCount: iobufLargePoolCount: + daemonsets: + - name: storage-node-ds + appLabel: storage-node + nodeSelector: simplyblock-storage-plane + tolerations: + create: false + effect: NoSchedule + key: dedicated + operator: Equal + value: simplyblock-storage-plane + - name: storage-node-ds-reserve + appLabel: storage-node-reserve + nodeSelector: simplyblock-storage-plane-reserve + tolerations: + create: false + effect: NoSchedule + key: dedicated + operator: Equal + value: simplyblock-storage-plane-reserve