Skip to content

Commit 0c4aff6

Browse files
authored
feat(snapshotAgent): allow extraVolumeMounts & Environment (#136)
1 parent 8af72a4 commit 0c4aff6

File tree

6 files changed

+111
-3
lines changed

6 files changed

+111
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Unreleased
22

3+
## 0.24.1
4+
5+
- fix(snapshotAgent): allow setting extraVolumeMounts, extraEnvironmentVars & extraSecretEnvironmentVars
6+
37
## 0.24.0
48

59
- feat: add support for gateway-api httproute

charts/openbao/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
apiVersion: v2
55
name: openbao
6-
version: 0.24.0
6+
version: 0.24.1
77
appVersion: v2.4.4
88
kubeVersion: ">= 1.30.0-0"
99
description: Official OpenBao Chart
@@ -28,7 +28,7 @@ annotations:
2828
artifacthub.io/changes: |
2929
- kind: added
3030
description: |
31-
feat: add support for gateway-api httproute
31+
fix(snapshotAgent): allow setting extraEnvironmentVars and extraVolumeMounts
3232
3333
maintainers:
3434
- name: OpenBao

charts/openbao/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# openbao
22

3-
![Version: 0.24.0](https://img.shields.io/badge/Version-0.24.0-informational?style=flat-square) ![AppVersion: v2.4.4](https://img.shields.io/badge/AppVersion-v2.4.4-informational?style=flat-square)
3+
![Version: 0.24.1](https://img.shields.io/badge/Version-0.24.1-informational?style=flat-square) ![AppVersion: v2.4.4](https://img.shields.io/badge/AppVersion-v2.4.4-informational?style=flat-square)
44

55
Official OpenBao Chart
66

@@ -326,6 +326,9 @@ Kubernetes: `>= 1.30.0-0`
326326
| snapshotAgent.config.s3Uri | string | `"s3://openbao-snapshots"` | |
327327
| snapshotAgent.config.s3cmdExtraFlag | string | `"-v"` | |
328328
| snapshotAgent.enabled | bool | `false` | |
329+
| snapshotAgent.extraEnvironmentVars | object | `{}` | Map of extra environment variables to set in the snapshot-agent cronjob |
330+
| snapshotAgent.extraSecretEnvironmentVars | list | `[]` | List of extra environment variables to set in the snapshot-agent cronjob These variables take value from existing Secret objects. |
331+
| snapshotAgent.extraVolumeMounts | list | `[]` | List of additional volumeMounts for the snapshot cronjob container. These are rendered via toYaml rather than pre-processed like the extraVolumes value. |
329332
| snapshotAgent.extraVolumes | object | `{}` | |
330333
| snapshotAgent.image.repository | string | `"ghcr.io/openbao/openbao-snapshot-agent"` | |
331334
| snapshotAgent.image.tag | string | `"0.2.4"` | |

charts/openbao/templates/snapshotagent-cronjob.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ spec:
4545
secretKeyRef:
4646
key: AWS_ACCESS_KEY_ID
4747
name: {{ .Values.snapshotAgent.s3CredentialsSecret }}
48+
{{- include "openbao.extraSecretEnvironmentVars" .Values.snapshotAgent | nindent 12 }}
49+
{{- include "openbao.extraEnvironmentVars" .Values.snapshotAgent | nindent 12 }}
4850
image: {{ .Values.snapshotAgent.image.repository }}:{{ .Values.snapshotAgent.image.tag }}
4951
{{ template "openbao.snapshotAgent.resources". }}
5052
{{ template "snapshotAgent.securityContext.container" .}}
5153
volumeMounts:
5254
- name: snapshot-dir
5355
mountPath: /bao-snapshots
56+
{{- with .Values.snapshotAgent.extraVolumeMounts }}
57+
{{- toYaml . | nindent 14 }}
58+
{{- end }}
5459
imagePullPolicy: IfNotPresent
5560
volumes:
5661
- name: snapshot-dir

charts/openbao/values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,14 @@ snapshotAgent:
15151515
# extraVolumes for the snapshot agent cronjob
15161516
extraVolumes: {}
15171517

1518+
# -- List of additional volumeMounts for the snapshot cronjob container. These are rendered
1519+
# via toYaml rather than pre-processed like the extraVolumes value.
1520+
extraVolumeMounts: []
1521+
# - mountPath: /openbao/tls/ca.crt
1522+
# name: openbao-tls
1523+
# readOnly: true
1524+
# subPath: ca.crt
1525+
15181526
# s3CredentialsSecret to use
15191527
s3CredentialsSecret: "my-s3-credentials"
15201528

@@ -1531,6 +1539,17 @@ snapshotAgent:
15311539
# configuration of the CronJobs resources
15321540
resources: {}
15331541

1542+
# -- Map of extra environment variables to set in the snapshot-agent cronjob
1543+
extraEnvironmentVars: {}
1544+
# BAO_CACERT: /openbao/tls/ca.crt
1545+
1546+
# -- List of extra environment variables to set in the snapshot-agent cronjob
1547+
# These variables take value from existing Secret objects.
1548+
extraSecretEnvironmentVars: []
1549+
# - envName: AWS_SECRET_ACCESS_KEY
1550+
# secretName: openbao
1551+
# secretKey: AWS_SECRET_ACCESS_KEY
1552+
15341553
# Security context for the pod template and the snapshotAgent container
15351554
# The default pod securityContext is:
15361555
# runAsNonRoot: true

test/unit/snapshotagent.bats

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,83 @@ load _helpers
263263
[ "${actual}" = "https://bao.example.com" ]
264264
}
265265

266+
#--------------------------------------------------------------------
267+
# extraEnvironmentVars
268+
269+
@test "snapshot/cronjob: specify extraEnvironmentVar" {
270+
cd `chart_dir`
271+
local object=$(helm template \
272+
--show-only templates/snapshotagent-cronjob.yaml \
273+
--set 'snapshotAgent.enabled=true' \
274+
--set 'snapshotAgent.extraEnvironmentVars.BAO_FOO=bar' \
275+
. | tee /dev/stderr |
276+
yq -r '.spec.jobTemplate.spec.template.spec.containers[0].env' | tee /dev/stderr )
277+
278+
local actual=$(echo $object |
279+
yq -r '.[2].name' | tee /dev/stderr)
280+
[ "${actual}" = "BAO_FOO" ]
281+
282+
local actual=$(echo $object |
283+
yq -r '.[2].value' | tee /dev/stderr)
284+
[ "${actual}" = "bar" ]
285+
}
286+
287+
#--------------------------------------------------------------------
288+
# extraSecretEnvironmentVars
289+
290+
@test "snapshot/cronjob: set extraSecretEnvironmentVars" {
291+
cd `chart_dir`
292+
local object=$(helm template \
293+
--show-only templates/snapshotagent-cronjob.yaml \
294+
--set 'snapshotAgent.enabled=true' \
295+
--set 'snapshotAgent.extraSecretEnvironmentVars[0].envName=ENV_FOO_0' \
296+
--set 'snapshotAgent.extraSecretEnvironmentVars[0].secretName=secret_name_0' \
297+
--set 'snapshotAgent.extraSecretEnvironmentVars[0].secretKey=secret_key_0' \
298+
--set 'snapshotAgent.extraSecretEnvironmentVars[1].envName=ENV_FOO_1' \
299+
--set 'snapshotAgent.extraSecretEnvironmentVars[1].secretName=secret_name_1' \
300+
--set 'snapshotAgent.extraSecretEnvironmentVars[1].secretKey=secret_key_1' \
301+
. | tee /dev/stderr |
302+
yq -r '.spec.jobTemplate.spec.template.spec.containers[0].env' | tee /dev/stderr)
303+
304+
local value=$(echo $object |
305+
yq -r 'map(select(.name=="ENV_FOO_0")) | .[] .valueFrom.secretKeyRef.name' | tee /dev/stderr)
306+
[ "${value}" = "secret_name_0" ]
307+
308+
local value=$(echo $object |
309+
yq -r 'map(select(.name=="ENV_FOO_0")) | .[] .valueFrom.secretKeyRef.key' | tee /dev/stderr)
310+
[ "${value}" = "secret_key_0" ]
311+
312+
local value=$(echo $object |
313+
yq -r 'map(select(.name=="ENV_FOO_1")) | .[] .valueFrom.secretKeyRef.name' | tee /dev/stderr)
314+
[ "${value}" = "secret_name_1" ]
315+
316+
local value=$(echo $object |
317+
yq -r 'map(select(.name=="ENV_FOO_1")) | .[] .valueFrom.secretKeyRef.key' | tee /dev/stderr)
318+
[ "${value}" = "secret_key_1" ]
319+
}
320+
321+
#--------------------------------------------------------------------
322+
# extraVolumeMounts
323+
324+
@test "snapshot/cronjob: specify extraVolumeMounts" {
325+
cd `chart_dir`
326+
local object=$(helm template \
327+
--show-only templates/snapshotagent-cronjob.yaml \
328+
--set 'snapshotAgent.enabled=true' \
329+
--set 'snapshotAgent.extraVolumeMounts[0].mountPath=/mnt' \
330+
--set 'snapshotAgent.extraVolumeMounts[0].name=secret' \
331+
. | tee /dev/stderr |
332+
yq -r '.spec.jobTemplate.spec.template.spec.containers[0].volumeMounts' | tee /dev/stderr )
333+
334+
local actual=$(echo $object |
335+
yq -r '.[1].mountPath' | tee /dev/stderr)
336+
[ "${actual}" = "/mnt" ]
337+
338+
local actual=$(echo $object |
339+
yq -r '.[1].name' | tee /dev/stderr)
340+
[ "${actual}" = "secret" ]
341+
}
342+
266343
#--------------------------------------------------------------------
267344
# securityContext
268345

0 commit comments

Comments
 (0)