apiVersion: v1
kind: Secret
metadata:
  name: database-secret
type: Opaque
stringData:
  password: mypass1234
  init-user-db.sh: |
    #!/bin/bash
    set -e
    psql -v ON_ERROR_STOP=1 --username postgres --dbname "$POSTGRES_DB" <<-EOSQL
        CREATE USER customers WITH PASSWORD 'customers';
        CREATE DATABASE customers;
        GRANT ALL PRIVILEGES ON DATABASE customers TO customers;

        CREATE USER orders WITH PASSWORD 'orders';
        CREATE DATABASE orders;
        GRANT ALL PRIVILEGES ON DATABASE orders TO orders;

        CREATE USER products WITH PASSWORD 'products';
        CREATE DATABASE products;
        GRANT ALL PRIVILEGES ON DATABASE products TO products;
    EOSQL
