Set automountServiceAccountToken on Praefect, jobs and upgrade check
What does this MR do?
Some chart workloads never rendered automountServiceAccountToken, so their pods mounted the token despite the false global default.
- The Praefect StatefulSet, the registry migrations Job and the upgrade check Job now render it through the shared helper, as the other charts do.
- The upgrade check Job has no chart key, so it reads the global key.
- None of these pods calls the Kubernetes API. The toolbox Deployment, which runs the same image under the same ServiceAccount, already defaults to
false. - An upgrade note lists the keys for anyone relying on the mount.
- The Gitaly chart page gains an example of dedicated ServiceAccounts for Gitaly and Praefect.
The toolbox backup and database reindex CronJobs keep today's behaviour, because a CronJob that needs the token fails only at its next scheduled run.
backups.cron.automountServiceAccountTokenanddatabaseReindex.cron.automountServiceAccountTokenare unset by default and render nothing.- The 11.0 upgrade notes say the CronJobs then follow
serviceAccount.automountServiceAccountTokenand the global default.
Work item 3188 reported IRSA breaking with the token off.
- The reporter had set the role annotation in chart values for a ServiceAccount created outside the chart, so it never reached that ServiceAccount.
- They closed it as their own error, and a maintainer there had tested IRSA with the token off.
Test evidence
- Spec:
spec/configuration/service_account_token_spec.rbrenders the chart with every workload we template enabled and checks each Deployment, StatefulSet, Job and CronJob. By default and with the global keytrue, each sets the field, except the two toolbox CronJobs, which must leave it unset. Each CronJob key, set, must render the field on its own CronJob only. With the line removed from the Praefect StatefulSet, the spec fails. helm templateagainst the merge base, with the same values: only the Praefect StatefulSet, the registry migrations Job and the upgrade check Job gain the field. Both CronJobs are byte-identical. With each key set, the field renders on that CronJob.- Cluster, k3s with the chart upgraded in place, before the CronJobs were taken out of the default change:
- master chart: the migrations and upgrade check pods mount
/var/run/secrets/kubernetes.io/serviceaccount; - this branch, default: both jobs complete with no token mount;
- this branch, per-chart
truefor registry and globaltruefor the upgrade check: the token is mounted again; - this branch, Praefect enabled with two replicas: both pods are Ready with no token mount.
- master chart: the migrations and upgrade check pods mount
The shared-secrets, self-signed certificate and cert-manager issuer Jobs keep the token because they run kubectl.
Related issues
Relates to work item 634070
Author checklist
For general guidance, please follow our Contributing guide.
Required
For anything in this list which will not be completed, please provide a reason in the MR discussion.
- Merge Request Title and Description are up to date, accurate, and descriptive.
- MR targeting the appropriate branch.
- MR has a green pipeline.
- Documentation created/updated.
- Tests added/updated.
- Have you validated that your change works end-to-end on a real cluster deployment?
- Described under Test evidence above.
- Equivalent MR/issue for omnibus-gitlab opened.
- Not applicable: the change is to chart templates only.
- When ready for review, MR is marked as ready (not a draft) and assigned to a reviewer.
Reviewers checklist
- As soon as you begin reviewing, select Start a review on your first comment so the MR shows Reviewer started review.
- MR has a green pipeline on https://gitlab.com/gitlab-org/charts/gitlab.
- Consider downstream impact to the Operator, as per evaluating impact from changes to GitLab chart.
An AI coding assistant wrote this change. It checked each claim against the chart templates, a k3s cluster run on a test VM and helm template output, and ran RSpec, markdownlint and Vale on the changed files.