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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# GraphDB Helm chart release notes

## Version 12.2.0

### New

- Added support for string template rendering in the following properties:
Comment thread
Secchol marked this conversation as resolved.
- `extraEnvFrom`
- `extraEnv`
- `extraVolumes`
- `extraVolumeMounts`
- `extraVolumeClaimTemplates`
- `extraInitContainers`
- `extraContainerPorts`
- `extraContainers`

## Version 12.1.0

### New
Expand Down
18 changes: 18 additions & 0 deletions examples/templated-extra-objects-and-fields/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Templated Extra Objects and Chart values Example

This example shows how to configure the extra chart values with templated items.

## Configuration

The default [values.yaml](values.yaml) in the example creates an additional configmap resource and
environment variables which reference sections from values.yaml. The additional configmap and environment variables are templated with Helm
and have use of `include`, `tpl`, `range` and `if`. Other templating functions are also supported.

NOTE: For templated resources in extraObjects, extraEnv, extraVolumes, etc., they need to be a string instead of YAML
object.

## Usage

```bash
helm upgrade --install --values ./values.yaml graphdb ontotext/graphdb
```
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ extraObjects:
resources:
requests:
storage: 5Gi

extraEnv:
- name: JVM_OPTS
value: "-Xms512m -Xmx1024m"
- name: GDB_REPLICA_ID
value: "{{ $.Release.Name }}"
- |
- name: CLUSTER_NAME
value: "{{ $.Release.Name }}"
- |
{{- if and .Values.randomCM.enabled (eq .Values.randomCM.values.key1 "value1") }}
- name: NODE_ID
value: test
{{- end }}
17 changes: 0 additions & 17 deletions examples/templated-extra-objects/README.md

This file was deleted.

21 changes: 21 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,24 @@ Calculate provisoner's bcrypt-hashed password
{{- define "graphdb.security.provisioner.passwordHash" -}}
{{- printf "%s" ( htpasswd .Values.security.provisioner.username .Values.security.provisioner.password | trimPrefix (printf "%s:" .Values.security.provisioner.username)) -}}
{{- end -}}

{{/*
Render a mixed list (strings or maps) into a normalized YAML list.
Useful when values may contain templated strings or raw YAML objects.
*/}}
{{- define "render.mixedList.toYaml" -}}
{{- $ctx := .ctx -}}
{{- $items := .items | default (list) -}}
{{- range $raw := $items }}
{{- if kindIs "string" $raw -}}
{{- $val := fromYamlArray (tpl $raw $ctx) -}}
{{- if $val }}
{{- toYaml $val | nindent 0 -}}
{{- end }}
{{- else -}}
{{- $m := fromYaml (tpl (toYaml $raw) $ctx ) -}}
{{- $list := list $m -}}
{{- toYaml $list | nindent 0 -}}
{{- end -}}
{{ end }}
{{- end -}}
10 changes: 6 additions & 4 deletions templates/extra-objects.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{ range .Values.extraObjects }}
{{- if .Values.extraObjects -}}
{{- $objs := include "render.list.singleMaps" (dict "ctx" $ "items" .Values.extraObjects) | fromYamlArray -}}
{{- range $obj := $objs }}
---
{{- $value := typeIs "string" . | ternary . (. | toYaml) }}
{{ tpl $value $ }}
{{ end }}
{{ toYaml $obj | nindent 0 }}
{{- end -}}
{{- end -}}
17 changes: 9 additions & 8 deletions templates/graphdb/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
{{- toYaml .Values.import.volumeMount.volumeClaimTemplate.spec | nindent 8 }}
{{- end }}
{{- with .Values.extraVolumeClaimTemplates }}
{{- tpl (toYaml .) $ | nindent 4 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 4 }}
{{- end }}
{{- end }}
template:
Expand Down Expand Up @@ -219,7 +219,7 @@ spec:
{{- end }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector: {{- tpl (toYaml .) $ | nindent 8 }}
Expand Down Expand Up @@ -404,7 +404,7 @@ spec:

echo 'Done'
{{- with .Values.extraInitContainers }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
Expand All @@ -425,16 +425,17 @@ spec:
containerPort: {{ .Values.containerPorts.rpc }}
{{- end }}
{{- with .Values.extraContainerPorts }}
{{- toYaml . | nindent 12 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim nindent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ include "graphdb.fullname.configmap.environment" . }}
{{- with .Values.extraEnvFrom }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 12 }}
{{- end }}
{{- with .Values.extraEnv }}
env: {{- tpl (toYaml .) $ | nindent 12 }}
env:
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 12 }}
{{- end }}
volumeMounts:
- name: {{ .Values.persistence.volumeClaimTemplate.name }}
Expand Down Expand Up @@ -464,7 +465,7 @@ spec:
mountPath: {{ .Values.cluster.tls.mountPath }}
{{- end }}
{{- with .Values.extraVolumeMounts }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .)| trim | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources: {{ toYaml . | nindent 12 }}
Expand All @@ -482,5 +483,5 @@ spec:
livenessProbe: {{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraContainers }}
{{ tpl (toYaml .) $ | nindent 8 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 8 }}
{{- end }}
17 changes: 9 additions & 8 deletions templates/proxy/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
{{- toYaml .Values.proxy.persistence.volumeClaimTemplate.spec | nindent 8 }}
{{- end }}
{{- with .Values.proxy.extraVolumeClaimTemplates }}
{{- tpl (toYaml .) $ | nindent 4 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 4 }}
{{- end }}
{{- end }}
template:
Expand Down Expand Up @@ -187,7 +187,7 @@ spec:
{{- end }}
{{- end }}
{{- with .Values.proxy.extraVolumes }}
{{- tpl (toYaml .) $ | nindent 8 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 8 }}
{{- end }}
{{- with .Values.proxy.nodeSelector }}
nodeSelector: {{- tpl (toYaml .) $ | nindent 8 }}
Expand Down Expand Up @@ -347,7 +347,7 @@ spec:

echo 'Done'
{{- with .Values.proxy.extraInitContainers }}
{{- toYaml . | nindent 8 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 8 }}
{{- end }}
containers:
- name: {{ include "graphdb-proxy.chartName" . }}
Expand All @@ -366,18 +366,19 @@ spec:
- configMapRef:
name: {{ include "graphdb-proxy.fullname.configmap.environment" . }}
{{- with .Values.proxy.extraEnvFrom }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 12 }}
{{- end }}
{{- with .Values.proxy.extraEnv }}
env: {{- tpl (toYaml .) $ | nindent 12 }}
env:
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.proxy.containerPorts.http }}
- name: rpc
containerPort: {{ .Values.proxy.containerPorts.rpc }}
{{- with .Values.proxy.extraContainerPorts }}
{{- toYaml . | nindent 12 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 12 }}
{{- end }}
volumeMounts:
- name: {{ .Values.proxy.persistence.volumeClaimTemplate.name }}
Expand All @@ -396,7 +397,7 @@ spec:
mountPath: {{ .Values.cluster.tls.mountPath }}
{{- end }}
{{- with .Values.proxy.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 12 }}
{{- end }}
{{- with .Values.proxy.resources }}
resources: {{ toYaml . | nindent 12 }}
Expand All @@ -414,6 +415,6 @@ spec:
livenessProbe: {{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.proxy.extraContainers }}
{{ tpl (toYaml .) $ | nindent 8 }}
{{- include "render.list.singleMaps" (dict "ctx" $ "items" .) | trim | nindent 8 }}
{{- end }}
{{- end }}