Skip to content

Commit

Permalink
Make Helm chart cleanup job container image configurable
Browse files Browse the repository at this point in the history
We `parameters.backup_k8up.images.kubectl` and add a postprocessing
filter which patches the cleanup job to use the image location specified
in that image parameter.
  • Loading branch information
simu committed Oct 2, 2023
1 parent ad590bb commit c76809f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions class/backup-k8up.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ parameters:
- type: jsonnet
filter: postprocess/optional_global_config.jsonnet
path: ${_instance}/01_k8up_helmchart/k8up/templates
- type: jsonnet
filter: postprocess/cleanup-job.jsonnet
path: ${_instance}/01_k8up_helmchart/k8up/templates
4 changes: 4 additions & 0 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ parameters:
repository: k8up-io/k8up
tag: v2.7.1
pullPolicy: IfNotPresent
kubectl:
registry: docker.io
repository: bitnami/kubectl
tag: latest

helmReleaseName: k8up

Expand Down
28 changes: 28 additions & 0 deletions postprocess/cleanup-job.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local com = import 'lib/commodore.libjsonnet';
local kube = import 'lib/kube.libjsonnet';

local inv = com.inventory();
local params = inv.parameters.backup_k8up;

local chart_output_dir = std.extVar('output_path');

local patch_registry(obj) =
if obj.kind == 'Job' then
obj {
spec+: {
template+: {
spec+: {
containers: [
c {
image: '%(registry)s/%(repository)s:%(tag)s' % params.images.kubectl,
}
for c in super.containers
],
},
},
},
}
else
obj;

com.fixupDir(chart_output_dir, patch_registry)
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ spec:
command:
- sh
- -c
image: bitnami/kubectl:latest
image: docker.io/bitnami/kubectl:latest
name: k8up-cleanup
restartPolicy: Never
serviceAccountName: cleanup-service-account

0 comments on commit c76809f

Please sign in to comment.