Skip to content

Commit

Permalink
added csi node init container (#44)
Browse files Browse the repository at this point in the history
Signed-off-by: v.oleynikov <[email protected]>
  • Loading branch information
duckhawk authored Nov 2, 2023
1 parent 4c6687b commit be2e578
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/helm_lib/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
type: library
name: deckhouse_lib_helm
version: 1.11.0
version: 1.12.0
description: "Helm utils template definitions for Deckhouse modules."
24 changes: 23 additions & 1 deletion charts/helm_lib/templates/_csi_node.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ memory: 25Mi
{{- $serviceAccount := $config.serviceAccount | default "" }}
{{- $additionalNodeEnvs := $config.additionalNodeEnvs }}
{{- $additionalNodeArgs := $config.additionalNodeArgs }}
{{- $additionalInitContainerEnvs := $config.additionalInitContainerEnvs }}
{{- $additionalInitContainerParts := $config.additionalInitContainerParts }}
{{- $additionalNodeVolumes := $config.additionalNodeVolumes }}
{{- $additionalNodeVolumeMounts := $config.additionalNodeVolumeMounts }}
{{- $initContainerCommand := $config.initContainerCommand }}
{{- $initContainerImage := $config.initContainerImage }}

{{- $kubernetesSemVer := semver $context.Values.global.discovery.kubernetesVersion }}
{{- $driverRegistrarImageName := join "" (list "csiNodeDriverRegistrar" $kubernetesSemVer.Major $kubernetesSemVer.Minor) }}
Expand Down Expand Up @@ -120,7 +124,7 @@ spec:
mountPath: /registration
resources:
requests:
{{- include "helm_lib_module_ephemeral_storage_logs_with_extra" 10 | nindent 12 }}
{{- include "helm_lib_module_ephemeral_storage_only_logs" 10 | nindent 12 }}
{{- if not ($context.Values.global.enabledModules | has "vertical-pod-autoscaler-crd") }}
{{- include "node_driver_registrar_resources" $context | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -152,6 +156,24 @@ spec:
{{- include "helm_lib_module_ephemeral_storage_logs_with_extra" 10 | nindent 12 }}
{{- if not ($context.Values.global.enabledModules | has "vertical-pod-autoscaler-crd") }}
{{- include "node_resources" $context | nindent 12 }}
{{- end }}
{{- if $initContainerCommand }}
initContainers:
- command:
{{- $initContainerCommand | toYaml | nindent 8 }}
{{- if $additionalInitContainerEnvs }}
env:
{{- $additionalInitContainerEnvs | toYaml | nindent 8 }}
{{- end }}
image: {{ $initContainerImage }}
imagePullPolicy: IfNotPresent
name: csi-node-init-container
resources:
requests:
{{- include "helm_lib_module_ephemeral_storage_logs_with_extra" 10 | nindent 12 }}
{{- if $additionalInitContainerParts }}
{{- $additionalInitContainerParts | toYaml | nindent 8 }}
{{- end }}
{{- end }}
serviceAccount: {{ $serviceAccount | quote }}
serviceAccountName: {{ $serviceAccount | quote }}
Expand Down
1 change: 1 addition & 0 deletions tests/templates/helm_lib_csi_node_value.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ include "helm_lib_csi_node_manifests" (list . .Values._testvalues) }}
102 changes: 102 additions & 0 deletions tests/tests/helm_lib_csi_node_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
suite: helm_lib_csi_node_value definition
templates:
- helm_lib_csi_node_value.yaml
tests:
- it: renders initContainer when data provided

set:
global:
modules:
placement: {}
enabledModules:
- ceph-csi
modulesImages:
registry:
base: "deckhouse.io/deckhouse/ce"
digests:
common:
csiNodeDriverRegistrar125: csiNodeDriverRegistrar125
discovery:
kubernetesVersion: "1.25"
_testvalues:
nodeImage: nodeImage
driverFQDN: driverFQDN
additionalNodeEnvs:
- name: testEnv
value: testValue
additionalNodeArgs:
- --start
additionalNodeVolumes: {}
additionalNodeVolumeMounts: {}
initContainerCommand: |
- initContainerCommand
initContainerImage: initContainerImage
additionalInitContainerEnvs:
- name: testEnv
value: testValue
additionalInitContainerParts:
additionalPart0: additionalPart0
additionalPart1: additionalPart1

asserts:
- containsDocument:
kind: DaemonSet
apiVersion: apps/v1
name: csi-node
namespace: d8-test-module

- it: contains params according values

set:
global:
modules:
placement: {}
enabledModules:
- ceph-csi
modulesImages:
registry:
base: "deckhouse.io/deckhouse/ce"
digests:
common:
csiNodeDriverRegistrar125: csiNodeDriverRegistrar125
discovery:
kubernetesVersion: "1.25"
_testvalues:
nodeImage: nodeImage
driverFQDN: driverFQDN
additionalNodeEnvs:
- name: testEnv
value: testValue
additionalNodeArgs:
- --start
additionalNodeVolumes: {}
additionalNodeVolumeMounts: {}
initContainerCommand: |
- initContainerCommand
initContainerImage: initContainerImage
additionalInitContainerEnvs:
- name: testEnv
value: testValue
additionalInitContainerParts:
additionalPart0: additionalPart0
additionalPart1: additionalPart1

asserts:
- equal:
path: "spec.template.spec.initContainers[0].image"
value: initContainerImage

- equal:
path: "spec.template.spec.initContainers[0].command"
value: |
- initContainerCommand
- equal:
path: "spec.template.spec.initContainers[0].additionalPart0"
value: additionalPart0

- equal:
path: "spec.template.spec.initContainers[0].env[0]"
value:
name: testEnv
value: testValue

0 comments on commit be2e578

Please sign in to comment.