infra/k8s/matrix/secrets-init.yaml

25 lines
480 B
YAML
Raw Normal View History

2024-07-07 04:27:20 +00:00
apiVersion: v1
kind: ConfigMap
metadata:
name: secrets-init
data:
initialize-secrets.py: |
#!/usr/bin/python
import os
import sys
for f in sys.argv[1:]:
with open(f"/config/{f}") as r:
c = r.read()
for k, v in os.environ.items():
if not k.startswith("SECRET_"):
continue
if v is not None:
c = c.replace(k, v)
print("replaced", k)
with open(f"/data/{f}", 'w') as w:
w.write(c)