Add a shared Service Ping internal API key setting

What does this MR do?

What

Adds global.appConfig.servicePing.jwtSecret and generates the Service Ping internal API key at install, so the Webservice, Sidekiq and toolbox pods use the same key. An admin can point the chart at their own Secret instead.

  • charts/gitlab/templates/_service_ping.tpl: mounts the Secret at /etc/gitlab/service_ping/.gitlab_service_ping_secret and sets service_ping.secret_file in gitlab.yml. The mount is optional, so the pods start when the Secret is missing. The Secret name defaults to <release>-gitlab-service-ping-secret and jwtSecret.key defaults to secret, also when empty.
  • templates/shared-secrets/_manifest.tpl: generates the default Secret with 32 random bytes in base64, like the Workhorse secret. jwtSecret.secret only renames the Secret. An existing Secret of that name is kept and the key is added only if missing.

Why

Every instance has Service Ping, so the key is treated like the Workhorse secret: consistent across pods, with an admin override. Unlike the Workhorse secret, GitLab does not need it to run. Without it, only the Service Ping internal API rejects requests.

This matches the Linux package, which generates the key on reconfigure in gitlab-org/omnibus-gitlab!10032 (merged).

Design choices for review

  • Generated by shared-secrets, not admin-created. Orbit uses an opt-in Secret because Orbit is an add-on. Service Ping ships in every instance, so a Helm install that never sets a value still gets one shared key.
  • Mounted in webservice, sidekiq and toolbox. Only webservice serves the endpoint, but every Rails process runs the initializer that reads the key. Without the mount, sidekiq and toolbox log a failed write on every boot since the Rails root is read-only for the git user. This matches the Workhorse and KAS secrets.
  • No enabled flag. global.appConfig.enableUsagePing only controls sending. The endpoint still answers with service_ping_enabled: false, and the exporter needs the key to read that.
  • Not mounted in migrations or geo-logcursor. Neither serves or verifies the endpoint, and the Rails initializer only logs a warning when it cannot write the file. This matches the knowledge graph and iam-auth secrets.
  • Helpers stay in charts/gitlab/templates/. That is where the other appConfig secret helpers are, such as _iam_auth.tpl and _mailroom.tpl, rather than the top-level templates/.
  • Optional mount. Rails does not need the key to start. ServicePing::InternalApiAuthenticator.ensure_secret! only logs a warning when it cannot write the file, and the endpoint then returns 401. A required mount would leave new pods in Init on upgrade for anyone who disabled the shared-secrets job, and Toolbox (Recreate) would stay down. With optional: true, default installs still get the shared key, and those users keep a working upgrade. This matches gitlab-org/omnibus-gitlab!10032 (merged), which provides the key by default but never blocks GitLab without it.

Out of scope

  • Admin steps to copy the key to the exporter cluster. These go in the Service Ping exporter docs.
  • The Omnibus equivalent, handled in gitlab-org/omnibus-gitlab!10032 (merged).
  • The Orbit jwtSecret.key row in globals.md leaves the Default column empty, though the template defaults to secret. Separate fix.

Depends on gitlab-org/gitlab!266694 (merged).

Related to gitlab-org/analytics-section/analytics-instrumentation/internal#1000

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?
    • Describe how you did it in a comment.
  • Equivalent MR/issue for omnibus-gitlab opened. gitlab-org/omnibus-gitlab!10032 (merged)
  • When ready for review, MR is marked as ready (not a draft) and assigned to a reviewer.

Reviewers checklist

Edited by Homer Silva

Merge request reports

Loading
Loading