Skip to content

Commit

Permalink
Merge pull request #129 from projectsyn/feat/patch-cleanup-job-image-…
Browse files Browse the repository at this point in the history
…registry

Make Helm chart cleanup job container image configurable
  • Loading branch information
simu committed Oct 2, 2023
2 parents ad590bb + 10aa57c commit bbb7db2
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
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
5 changes: 4 additions & 1 deletion docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The default K8up Helm chart version to use.
type:: dict
default:: See `class/defaults.yml`

The default Docker image location and tag to use for K8up (key `k8up`).
The default Docker image location and tag to use for K8up (key `k8up`) and kubectl (key `kubectl`).

Entries in this dict should be dictionaries with keys `registry`, `repository`, and `tag`.
This structure provides the basis for https://syn.tools/syn/SDDs/0017-maintenance-with-renovate.html[dependency maintenance with Renovate].
Expand All @@ -26,6 +26,9 @@ Please customize K8up image location and tag in this dict instead of directly in

The value of `k8up.tag` in this dict is used by the component to select the CRD YAML to download.

The component uses the contents of field `kubectl` to patch the Helm chart's cleanup job.
This allows users to configure a custom location for the `kubectl` image used by the job.

== `helmValues`

[horizontal]
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 bbb7db2

Please sign in to comment.