Manage Secrets
Declare a secret in a manifest, add its value in Google Cloud Secret Manager and inject it into an application. Never put a secret value in Git.
Prerequisites
- An
Applicationmanifest that needs the secret. - The names of your
organization,organizational-unit,environmentandproject.
Steps
-
Create the
Secretmanifest. It declares an empty secret. It has no value.apiVersion: lowops.manifests.v1
kind: Secret
metadata:
name: partner-api-key
project: payment-gateway
environment: production
organizational-unit: retail-banking
organization: fincorp
spec:
description: "API key for the external partner integration" -
Open a pull request and merge it. The platform creates the empty secret in Secret Manager.
-
Open Secret Manager in the Google Cloud console for the project. Select the secret and choose Add new version. Enter the value.
-
Grant the application access in its
accessControlblock. The key is the name of theSecretmanifest.spec:
accessControl:
secrets:
partner-api-key:
envVar: PARTNER_API_KEY # expose as this environment variable
# version: "latest" # optional: pin a version -
Open a pull request and merge it.
Verify
The platform grants the service account of the application read access to the secret. It restarts the application with the value in PARTNER_API_KEY.