Skip to content

Commit

Permalink
update setup of database
Browse files Browse the repository at this point in the history
  • Loading branch information
leiicamundi committed Oct 15, 2024
1 parent f00dc14 commit 0760f39
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
apiVersion: batch/v1
kind: Job
metadata:
name: create-irsa-user-db
name: create-setup-user-db
labels:
app: create-irsa-user-db
app: create-setup-user-db
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: create-irsa-user-db
- name: create-setup-user-db
image: amazonlinux:latest
command:
- sh
Expand All @@ -22,7 +22,7 @@ spec:
set -o pipefail
echo "Installing dependencies..."
yum install -y postgresql15 unzip awscli-2
yum install -y postgresql15
echo "Create keycloak user and associated database"
psql -h $AURORA_ENDPOINT -p $AURORA_PORT "sslmode=require dbname=$AURORA_DB_NAME user=$AURORA_USERNAME password=$AURORA_PASSWORD" \
Expand Down Expand Up @@ -50,70 +50,70 @@ spec:
- name: AURORA_ENDPOINT
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: AURORA_ENDPOINT
- name: AURORA_PORT
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: AURORA_PORT
- name: AURORA_DB_NAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: AURORA_DB_NAME
- name: AURORA_USERNAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: AURORA_USERNAME
- name: AURORA_PASSWORD
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: AURORA_PASSWORD
- name: DB_KEYCLOAK_NAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: DB_KEYCLOAK_NAME
- name: DB_KEYCLOAK_USERNAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: DB_KEYCLOAK_USERNAME
- name: CAMUNDA_KEYCLOAK_SERVICE_ACCOUNT_NAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: CAMUNDA_KEYCLOAK_SERVICE_ACCOUNT_NAME
- name: DB_IDENTITY_NAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: DB_IDENTITY_NAME
- name: DB_IDENTITY_USERNAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: DB_IDENTITY_USERNAME
- name: CAMUNDA_IDENTITY_SERVICE_ACCOUNT_NAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: CAMUNDA_IDENTITY_SERVICE_ACCOUNT_NAME
- name: DB_WEBMODELER_NAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: DB_WEBMODELER_NAME
- name: DB_WEBMODELER_USERNAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: DB_WEBMODELER_USERNAME
- name: CAMUNDA_WEBMODELER_SERVICE_ACCOUNT_NAME
valueFrom:
secretKeyRef:
name: irsa-db-secret
name: setup-db-secret
key: CAMUNDA_WEBMODELER_SERVICE_ACCOUNT_NAME
116 changes: 116 additions & 0 deletions examples/camunda-8.6/setup-postgres-create-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
# this manifest creates the database
apiVersion: batch/v1
kind: Job
metadata:
name: create-setup-user-db
labels:
app: create-setup-user-db
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: create-setup-user-db
image: amazonlinux:latest
command:
- sh
- -c
- |
/bin/bash <<'EOF'
set -o pipefail
echo "Installing dependencies..."
yum install -y postgresql15
echo "Create keycloak user and associated database"
psql -h $AURORA_ENDPOINT -p $AURORA_PORT "sslmode=require dbname=$AURORA_DB_NAME user=$AURORA_USERNAME password=$AURORA_PASSWORD" \
-c "CREATE DATABASE \"${DB_KEYCLOAK_NAME}\";" \
-c "CREATE USER \"${DB_KEYCLOAK_USERNAME}\" WITH PASSWORD '${DB_KEYCLOAK_PASSWORD}';" \
-c "GRANT ALL PRIVILEGES ON DATABASE \"${DB_KEYCLOAK_NAME}\" TO \"${DB_KEYCLOAK_USERNAME}\";"
echo "Create identity user and associated database"
psql -h $AURORA_ENDPOINT -p $AURORA_PORT "sslmode=require dbname=$AURORA_DB_NAME user=$AURORA_USERNAME password=$AURORA_PASSWORD" \
-c "CREATE DATABASE \"${DB_IDENTITY_NAME}\";" \
-c "CREATE USER \"${DB_IDENTITY_USERNAME}\" WITH PASSWORD '${DB_IDENTITY_PASSWORD}';" \
-c "GRANT ALL PRIVILEGES ON DATABASE \"${DB_IDENTITY_NAME}\" TO \"${DB_IDENTITY_USERNAME}\";"
echo "Create webmodeler user and associated database"
psql -h $AURORA_ENDPOINT -p $AURORA_PORT "sslmode=require dbname=$AURORA_DB_NAME user=$AURORA_USERNAME password=$AURORA_PASSWORD" \
-c "CREATE DATABASE \"${DB_WEBMODELER_NAME}\";" \
-c "CREATE USER \"${DB_WEBMODELER_USERNAME}\" WITH PASSWORD '${DB_WEBMODELER_PASSWORD}';" \
-c "GRANT ALL PRIVILEGES ON DATABASE \"${DB_WEBMODELER_NAME}\" TO \"${DB_WEBMODELER_USERNAME}\";"
EOF
env:
- name: AURORA_ENDPOINT
valueFrom:
secretKeyRef:
name: setup-db-secret
key: AURORA_ENDPOINT
- name: AURORA_PORT
valueFrom:
secretKeyRef:
name: setup-db-secret
key: AURORA_PORT
- name: AURORA_DB_NAME
valueFrom:
secretKeyRef:
name: setup-db-secret
key: AURORA_DB_NAME
- name: AURORA_USERNAME
valueFrom:
secretKeyRef:
name: setup-db-secret
key: AURORA_USERNAME
- name: AURORA_PASSWORD
valueFrom:
secretKeyRef:
name: setup-db-secret
key: AURORA_PASSWORD
- name: DB_KEYCLOAK_NAME
valueFrom:
secretKeyRef:
name: setup-db-secret
key: DB_KEYCLOAK_NAME
- name: DB_KEYCLOAK_USERNAME
valueFrom:
secretKeyRef:
name: setup-db-secret
key: DB_KEYCLOAK_USERNAME
- name: DB_KEYCLOAK_PASSWORD
valueFrom:
secretKeyRef:
name: setup-db-secret
key: DB_KEYCLOAK_PASSWORD
- name: DB_IDENTITY_NAME
valueFrom:
secretKeyRef:
name: setup-db-secret
key: DB_IDENTITY_NAME
- name: DB_IDENTITY_USERNAME
valueFrom:
secretKeyRef:
name: setup-db-secret
key: DB_IDENTITY_USERNAME
- name: DB_IDENTITY_PASSWORD
valueFrom:
secretKeyRef:
name: setup-db-secret
key: DB_IDENTITY_PASSWORD
- name: DB_WEBMODELER_NAME
valueFrom:
secretKeyRef:
name: setup-db-secret
key: DB_WEBMODELER_NAME
- name: DB_WEBMODELER_USERNAME
valueFrom:
secretKeyRef:
name: setup-db-secret
key: DB_WEBMODELER_USERNAME
- name: DB_WEBMODELER_PASSWORD
valueFrom:
secretKeyRef:
name: setup-db-secret
key: DB_WEBMODELER_PASSWORD

0 comments on commit 0760f39

Please sign in to comment.