salmon-helicopter-2455
04/04/2024, 9:25 AMmagnificent-energy-493
initContainers:
- name: init-db
image: postgres:9.6
command: ['sh', '-c', 'psql -h $DB_HOST -U $DB_USER -c "CREATE DATABASE keto;"']
env:
- name: DB_HOST
valueFrom:
secretKeyRef:
name: db-secrets
key: host
- name: DB_USER
valueFrom:
secretKeyRef:
name: db-secrets
key: user
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-secrets
key: password
In this example, db-secrets
is a Kubernetes Secret that contains your database credentials. The init container uses these credentials to connect to your database and create the Keto database.
Please note that this is a simplified example and you might need to adjust it according to your specific setup and requirements. For instance, you might need to handle the case where the database already exists.salmon-helicopter-2455
04/07/2024, 11:53 AM