This is similar to questions that have been asked before (for example How to inject secrets from Google Secret Manager into K8s pod? and Loading secrets as ENV from init container), but I'm looking for an actual example of a deployment.yaml
file.
Let's say I have this Kubernetes yaml file:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
labels:
name: my-app
spec:
selector:
matchLabels:
name: "my-app"
template:
metadata:
labels:
name: "my-app"
version: "1.0.0"
spec:
serviceAccountName: my-app
containers:
- name: "my-app"
env:
- name: DB_USER
value: postgres
- name: DB_PASS
value: password
- name: DB_NAME
value: postgres
image: "my-app:1.0.0"
...
We have stored the "DB_USER" and "DB_PASS" in Google Secret Manager and are looking for a way to pass these secrets to "my-app" as environment variables. I've found the ghcr.io/doitintl/secrets-init:0.4.7 image which seems very promising, but I cannot seem to find any example of how to actually use it with Google Cloud Secret Manager in Kubernetes. What I'm looking for is how to modify the example above to load the secrets "DB_USER" and "DB_PASS" from Goolge Secret Manager and pass them as environment variables.