Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions charts/topograph/charts/node-data-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,20 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create the name of a generated ConfigMap mount.
*/}}
{{- define "node-data-broker.configMapMountName" -}}
{{- $root := .root -}}
{{- $name := required "node-data-broker.configMapMounts[].name is required" .name | lower | replace "_" "-" -}}
{{- printf "%s-%s" (include "node-data-broker.fullname" $root) $name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create the volume name for a generated ConfigMap mount.
*/}}
{{- define "node-data-broker.configMapMountVolumeName" -}}
{{- $name := required "node-data-broker.configMapMounts[].name is required" .name | lower | replace "_" "-" -}}
{{- printf "config-map-%s" $name | trunc 63 | trimSuffix "-" }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if and .Values.enabled .Values.configMapMounts }}
{{- range .Values.configMapMounts }}
{{- $data := required "node-data-broker.configMapMounts[].data is required" .data }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "node-data-broker.configMapMountName" (dict "root" $ "name" .name) }}
labels:
{{- include "node-data-broker.labels" $ | nindent 4 }}
data:
{{- range $key, $value := $data }}
{{ $key | quote }}: |-
{{ default "" $value | indent 4 }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- if .Values.enabled }}
{{- $providerParams := default dict .Values.global.provider.params }}
{{- $useGpuCliqueLabel := and (eq .Values.global.provider.name "infiniband-k8s") (eq (lower (toString (get $providerParams "useGpuCliqueLabel"))) "true") }}
{{- $configMapMounts := default list .Values.configMapMounts }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down Expand Up @@ -44,9 +45,19 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- with .Values.volumeMounts }}
{{- if or $configMapMounts .Values.volumeMounts }}
volumeMounts:
{{- range $configMapMounts }}
- name: {{ include "node-data-broker.configMapMountVolumeName" (dict "name" .name) }}
mountPath: {{ required "node-data-broker.configMapMounts[].mountPath is required" .mountPath | quote }}
{{- with .subPath }}
subPath: {{ . | quote }}
{{- end }}
readOnly: true
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
containers:
Expand All @@ -61,13 +72,30 @@ spec:
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
{{- if or $configMapMounts .Values.volumeMounts }}
volumeMounts:
{{- range $configMapMounts }}
- name: {{ include "node-data-broker.configMapMountVolumeName" (dict "name" .name) }}
mountPath: {{ required "node-data-broker.configMapMounts[].mountPath is required" .mountPath | quote }}
{{- with .subPath }}
subPath: {{ . | quote }}
{{- end }}
readOnly: true
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.volumes }}
{{- if or $configMapMounts .Values.volumes }}
volumes:
{{- range $configMapMounts }}
- name: {{ include "node-data-broker.configMapMountVolumeName" (dict "name" .name) }}
configMap:
name: {{ include "node-data-broker.configMapMountName" (dict "root" $ "name" .name) }}
{{- end }}
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
Comment thread
dmitsh marked this conversation as resolved.
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
Expand Down
13 changes: 13 additions & 0 deletions charts/topograph/charts/node-data-broker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ resources:
cpu: 100m
memory: 128Mi

# Optional ConfigMaps rendered by the chart and mounted into both the
# node-data-broker container and init container. Set subPath for file mounts;
# omit it to mount the whole ConfigMap as a directory.
configMapMounts: []
# name is used as a Kubernetes resource and volume suffix; keep it DNS-label-safe.
# - name: ibdiag
# mountPath: /etc/infiniband-diags/ibdiag.conf
# subPath: ibdiag.conf
# data:
# ibdiag.conf: |-
# CA=smi0
# Port=1

# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
Expand Down
14 changes: 14 additions & 0 deletions docs/providers/infiniband.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ node-data-broker:
- device-plugin-daemonset=my-daemonset
```

If `ibnetdiscover` needs extra config files, the chart can render ConfigMaps and mount them into the node-data-broker pods:

```yaml
node-data-broker:
configMapMounts:
- name: ibdiag
mountPath: /etc/infiniband-diags/ibdiag.conf
subPath: ibdiag.conf
data:
ibdiag.conf: |-
CA=smi0
Port=1
```

Example request payload with `nodeSelector`:

```json
Expand Down
9 changes: 9 additions & 0 deletions scripts/chart-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ echo "== subchart node-data-broker: initc.enabled=false =="
out=$(helm "${helm_common[@]}" --set node-data-broker.initc.enabled=false)
assert_output_not_contains "${out}" "init-node-labels" "node-data-broker.initc.enabled=false should omit init container"

echo "== subchart node-data-broker: configMapMounts =="
out=$(helm "${helm_common[@]}" \
--set-json 'node-data-broker.configMapMounts=[{"name":"ibdiag","mountPath":"/etc/infiniband-diags/ibdiag.conf","subPath":"ibdiag.conf","data":{"ibdiag.conf":"CA=smi0\nPort=1"}}]')
assert_output_contains "${out}" "name: chart-ci-node-data-broker-ibdiag" "node-data-broker.configMapMounts should render an ibdiag ConfigMap"
assert_output_contains "${out}" " CA=smi0" "node-data-broker configMapMounts should include configured CA"
assert_output_contains "${out}" " Port=1" "node-data-broker configMapMounts should include configured Port"
assert_output_contains "${out}" "mountPath: \"/etc/infiniband-diags/ibdiag.conf\"" "node-data-broker configMapMounts should mount at ibdiag.conf"
assert_output_contains "${out}" "subPath: \"ibdiag.conf\"" "node-data-broker configMapMounts should mount as a single file"
Comment thread
dmitsh marked this conversation as resolved.

echo "== subchart node-observer: replicaCount override =="
out=$(helm "${helm_common[@]}" --set node-observer.replicaCount=2)
assert_output_contains "${out}" "replicas: 2" "node-observer.replicaCount=2 should scale Deployment"
Expand Down
Loading