Skip to content

Add Google Cloud Secret Manager vault integration - #4748

Open
mnacharov wants to merge 1 commit into
actions:masterfrom
mnacharov:4737
Open

mnacharov wants to merge 1 commit into
actions:masterfrom
mnacharov:4737

Conversation

@mnacharov

@mnacharov mnacharov commented Nov 18, 2026 •

Copy link
Copy Markdown

Closes #4737

This PR adds Google Cloud Secret Manager as a second vault type for gha-runner-scale-set, alongside azure_key_vault (#4090). The controller and listener can read GitHub App or PAT credentials from Secret Manager, so the credentials never have to be stored in a Kubernetes Secret.

The scope matches #4090: proxy credentials, the listener configuration and runner JIT tokens stay in Kubernetes Secrets. Only the GitHub credentials move to the vault.

Configuration

githubConfigSecret: gha-runners-app   # used as the Secret Manager secret ID
keyVault:
  type: gcp_secret_manager
  gcpSecretManager:
    projectId: my-project
    # version: "3"   # optional, defaults to "latest"

In the experimental chart, set secretResolution.type: gcpSecretManager and secretResolution.gcpSecretManager.projectId. auth.secretName is the secret ID.

The secret payload uses the same JSON format as Azure Key Vault and is parsed by the existing appconfig.FromJSONString. It contains either github_app_id, github_app_installation_id and github_app_private_key, or github_token.

Authentication uses Google Application Default Credentials. On GKE this means Workload Identity Federation: grant the controller and listener Kubernetes ServiceAccounts roles/secretmanager.secretAccessor on the secret. No key files or certificates are mounted. Outside GKE, a credentials file referenced by GOOGLE_APPLICATION_CREDENTIALS works.

Changes

  • vault/gcpsecretmanager (new). Implements vault.Vault using the Secret Manager REST client.
    • Reads projects/{projectId}/secrets/{name}/versions/{version}.
    • Verifies the payload's CRC32C checksum.
    • IsNotFound reports only 404 / NOT_FOUND as not found, so permission and quota errors are still retried.
    • keyVault.proxy applies to Secret Manager traffic. Token acquisition (for example from the GKE metadata server) is not proxied.
  • vault. New VaultTypeGCPSecretManager constant.
  • API. New VaultConfig.GCPSecretManager (projectId, version). CRDs regenerated.
  • Secret resolver. Dispatches to the new vault. wrapAzureKeyVaultError is renamed to wrapVaultError and also maps GCP not-found errors to ErrNotFound.
  • Resource builder and listener.
    • The listener config Secret carries the new config, with only the project ID, version and secret name. No credentials.
    • The listener reads the secret at startup, as it does for Azure.
  • Charts. Templates and values for both gha-runner-scale-set and gha-runner-scale-set-experimental. Both charts fail to render when projectId is missing.

Small fixes found along the way:

  • The controller and listener now return an error when a vault type is set but its provider config block is missing. Previously both dereferenced a nil pointer and panicked, for azure_key_vault too.
  • The keyVault example in charts/gha-runner-scale-set/values.yaml used snake_case keys (client_id, tenant_id, …) that the template never read. It now uses the camelCase keys the template expects.

Dependencies

This adds cloud.google.com/go/secretmanager v1.24.0. It pulls in google.golang.org/api, gRPC, genproto and OpenTelemetry as indirect dependencies, including a pseudo-version of cloud.google.com/go/auth. Only the REST transport is used at runtime.

Testing

  • vault/gcpsecretmanager:
    • Unit tests run the real REST client against an httptest Secret Manager endpoint.
    • They cover the request path, payload decoding, checksum mismatch, 404 → not found, and 403 → not "not found".
    • They also cover config validation and missing ADC.
  • Secret resolver: GCP 404/403/429 cases added to the not-found tagging test.
  • Listener config:
    • Validation tests.
    • New Read() tests: missing provider config, invalid config, and dispatch to the GCP client.
  • Resource builder: the listener config Secret for a GCP vault contains the vault settings and no credentials; a missing provider config is rejected.
  • Charts:
    • Terratest cases for the stable chart.
    • helm-unittest cases for the experimental chart.
    • A contract test that renders the experimental chart and confirms the resolver dispatches to Secret Manager.
  • Full suite: go test -short ./controllers/actions.github.com/... ./cmd/... ./vault/... ./apis/... passes with envtest, and helm unittest passes for the experimental chart.

golangci-lint was not run locally; gofmt and go vet are clean.

Live testing

Tested end to end on a GKE cluster with images and charts built from this branch (commit f40b632):

  • Controller and listeners authenticate to Secret Manager through Workload Identity Federation: roles/secretmanager.secretAccessor on the secret for the controller namespace's principalSet. No Google service account and no key files.
  • Two gha-runner-scale-set releases in separate namespaces share one Secret Manager secret holding the GitHub App credentials. Both listeners start, register their scale sets, and workflow jobs run to completion.
  • No GitHub credentials exist in any Kubernetes Secret on the cluster.

One gotcha found while testing: in the JSON payload, github_app_installation_id must be a JSON number. A quoted value fails with json: cannot unmarshal string into Go struct field AppConfig.github_app_installation_id of type int64. This is existing appconfig.FromJSONString behaviour, shared with azure_key_vault. In a Kubernetes Secret the same field is a string, so it's easy to copy it over quoted.

Out of scope / possible follow-ups

  • Client reuse. A new Secret Manager client is created on each resolution, as the Azure path already does. Caching clients per config would avoid repeated credential lookups.
  • KMS signing. Signing the GitHub App JWT with Cloud KMS would keep the private key out of ARC's memory entirely. actions/scaleset already provides SignerJWTProvider / NewClientWithJWTProvider for this. That would be a separate change to GitHub auth, not to secret resolution.

Add gcp_secret_manager as a second vault type next to azure_key_vault,
so the controller and listener can read GitHub App or PAT credentials
from Google Cloud Secret Manager instead of a Kubernetes Secret.
Authentication uses Application Default Credentials (Workload Identity
Federation on GKE).

- vault/gcpsecretmanager: Secret Manager REST client with CRC32C
  verification and not-found detection
- API: VaultConfig.GCPSecretManager (projectId, version); CRDs regenerated
- secret resolver, listener config and resource builder wiring
- return an error instead of panicking when a vault type is set
  without its provider config
- gha-runner-scale-set and gha-runner-scale-set-experimental chart
  support and tests

Closes actions#4737

This branch has not been deployed

No deployments
Sign up for free to 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.

gha-runner-scale-set: support Google Cloud Secret Manager as a vault for GitHub credentials

1 participant