Skip to content

mbp-1142: Use short-lived tokens for the Quay registry - #194

Open
mlorenzofr wants to merge 2 commits into
validatedpatterns:mainfrom
mlorenzofr:mbp-1142
Open

mlorenzofr wants to merge 2 commits into
validatedpatterns:mainfrom
mlorenzofr:mbp-1142

Conversation

@mlorenzofr

Copy link
Copy Markdown
Collaborator

Summary

With the built-in Quay registry (Option 1), the pipeline and qtodo used the Quay admin password for push and pull. This PR adds an optional feature that replaces it with one-hour Quay robot tokens, each scoped to a single repository and role.

The External Secrets Operator generates them with two chained generators:

  1. VaultDynamicSecret: logs in to Vault with a dedicated ServiceAccount (Kubernetes auth / TokenReview) and gets a 15-minute JWT from the Vault identity OIDC provider.
  2. Webhook: exchanges that JWT for a Quay robot token through Quay robot account federation, which trusts the Vault issuer.

This works without exposing the API server's issuer endpoints, and no long-lived registry credential reaches workloads. The admin password is now only used by the robot provisioner.

Changes

  • Vault: ansible/configure-vault-quay-federation.yaml (imperative job) plus overrides/values-vault-quay-federation.yaml configure the identity OIDC issuer, signing key, roles, policies and Kubernetes auth roles.
  • supply-chain chart: push identity and generators, qtodo-registry-auth built from the robot token, and a quay-robot-provisioner (Sync hook + CronJob) that creates the robots, their federation and repository permissions.
  • qtodo chart: read-only pull identity and generators for the image pull secret.
  • gen-feature-variants: new quay-token-generator feature (requires --registry-option 1), plus a registry_options_allowed field.
  • Docs: new docs/quay-short-lived-tokens.md; updates to supply-chain.md, SYNC-WAVE-INVENTORY.md and gen-feature-variants.md.

The feature is disabled by default. Enable it with:

python3 scripts/gen-feature-variants.py --features supply-chain,quay-token-generator --registry-option 1

With the feature disabled, the charts render the same as before.

Testing

Deployed on OpenShift 4.22 with Quay 3.18: the pipeline pushes with ztvp+pipeline, qtodo pulls with ztvp+qtodo, and the tokens rotate automatically.

@sabre1041

Copy link
Copy Markdown
Collaborator

@mlorenzofr Both jobs are failing due to TLS issues

ERROR: TLS verification failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:1147)

It appears that TLS for the requests are only trusting the cluster CA. In my cluster, letsencrypt certs are being used to protect quay

Signed-off-by: Manuel Lorenzo <mlorenzofr@redhat.com>
The Quay robot provisioner only trusted the cluster service CA, so it
failed with CERTIFICATE_VERIFY_FAILED when Quay is protected by a
publicly trusted certificate such as Let's Encrypt.

The provisioner now verifies Quay with the system trust store plus the
ztvp-trusted-ca bundle from ztvp-certificates, mounted as an optional
ConfigMap. When the bundle is not distributed to the namespace, the
system trust store alone is used. Kubernetes API requests use the pod's
service account CA, and connection or certificate errors on that path
are retried instead of failing the Job.

The ztvp-certificates profile now distributes the bundle to the real
supply-chain namespace, which is vp-gitops in single Argo CD mode.

Signed-off-by: Manuel Lorenzo <mlorenzofr@redhat.com>
@mlorenzofr

Copy link
Copy Markdown
Collaborator Author

@sabre1041 Fixed in the latest commit. The provisioner now verifies Quay with the container's system trust store plus the ztvp-trusted-ca bundle from the ztvp-certificates chart, mounted as an optional ConfigMap, so Let's Encrypt and cluster-CA-signed routes both work without any extra values.

@sabre1041 sabre1041 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants