Skip to content

Prod: Implement self-upgrade CronJob for Helm chart automation - #90

Merged
saadqbal merged 3 commits into
mainfrom
develop
Apr 30, 2026
Merged

Prod: Implement self-upgrade CronJob for Helm chart automation#90
saadqbal merged 3 commits into
mainfrom
develop

Conversation

@saadqbal

@saadqbalsaadqbal commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Related

Type of change

  • Feature
  • Bug fix
  • Tech-debt / refactor
  • Docs
  • Security / hardening
  • Breaking change

Test plan

Screenshots / recordings

Deployment notes

Checklist

  • Tests added / updated and passing locally
  • Docs updated if behavior or config changed
  • No secrets / credentials in the diff
  • For security-sensitive paths: appropriate reviewer requested

Note

High Risk
Installs a default-on CronJob that can mutate the release and binds its ServiceAccount to cluster-admin, increasing blast radius if the pod or chart repo is compromised and potentially changing cluster state automatically over time.

Overview
Bumps the client Helm chart to 1.3.0 and adds an opt-out, default-enabled self-upgrade mechanism that periodically upgrades the release to the latest published chart.

This introduces new templates for an auto-upgrade ConfigMap+CronJob (runs a pinned alpine/helm image and executes helm upgrade --reset-then-reuse-values after semver-checking the repo) plus accompanying RBAC (ServiceAccount + cluster-admin ClusterRoleBinding), wires the feature into values.yaml/values.schema.json, adds helm-unittest coverage, and updates NOTES.txt and MIGRATION.md with upgrade/rollback guidance and the new autoUpgrade configuration.

Reviewed by Cursor Bugbot for commit 39e5349. Bugbot is set up for automated code reviews on this repo. Configure here.

Ship a chart-side CronJob that polls the published Helm repo daily and runs
`helm upgrade --reuse-values` when a newer chart version is available, so
deployed clients no longer freeze on the version they first installed and
miss security/stability fixes.
- New templates: auto-upgrade-cronjob.yaml (ConfigMap + CronJob),
auto-upgrade-rbac.yaml (ServiceAccount + ClusterRoleBinding to the
built-in cluster-admin ClusterRole).
- New values: autoUpgrade.{enabled, schedule, repoUrl, repoName, chartName,
timeout, suspend, successfulJobsHistoryLimit, failedJobsHistoryLimit,
startingDeadlineSeconds, image, resources}; default ON.
- Pod satisfies PSA restricted (runAsNonRoot, dropped caps, RO root,
RuntimeDefault seccomp); HOME/HELM_*_HOME redirected to a tmp emptyDir.
- Version compare uses sort -V so 1.10 > 1.9.
- Bumps chart 1.2.3 -> 1.3.0; MIGRATION.md documents how to opt out.
Cluster-admin (rather than a curated narrow role) keeps the upgrader
robust: the chart already templates cluster-scoped resources
(PriorityClass, StorageClass, ClusterRole/Binding, optionally Namespace),
so a narrower role would silently break the day a future chart adds a new
resource kind. Operators who want tighter posture can disable the feature
and run `helm upgrade` manually.
Backend reporting from the issue is intentionally deferred — no endpoint
exists yet; will land as a follow-up once the contract is defined.
Caught during the #69 verification on tb-client-dev-templates: a dry-run
1.1.0 -> 1.3.0 helm upgrade with --reuse-values fails with
template: client/templates/auto-upgrade-rbac.yaml:1:14:
executing "..." at <.Values.autoUpgrade.enabled>:
nil pointer evaluating interface {}.enabled
because --reuse-values reuses the previous release's COMPUTED values, not
just user overrides — so any top-level key added to values.yaml in the
upgraded chart (autoUpgrade in 1.3.0, anything similar in future bumps) is
absent from the merged values when rendering and the new templates blow up.
--reset-then-reuse-values (helm 3.14+, available in our pinned alpine/helm
3.16.4 image) resets to the new chart's defaults, then layers the customer's
user-supplied values on top — operator overrides like clientId,
dockerRegistry creds, or autoUpgrade.enabled=false are preserved while new
defaults flow through.
- Switch the in-chart upgrade script to --reset-then-reuse-values.
- Update the unit test to assert the corrected flag.
- MIGRATION.md: tell operators to use the same flag for the manual 1.x ->
1.3.0 jump (subsequent chart bumps will go through the CronJob, which
now uses the right flag itself).
feat(client): self-upgrade CronJob (closes#69)
@saadqbal
saadqbal merged commit dde5993 into mainApr 30, 2026
14 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@saadqbal@saqlainsyed007@LukasWodka