Skip to content

Commit

Permalink
init keyclock db before installation
Browse files Browse the repository at this point in the history
  • Loading branch information
robertchoi80 committed Oct 6, 2023
1 parent e4501f4 commit 25940d5
Showing 1 changed file with 55 additions and 6 deletions.
61 changes: 55 additions & 6 deletions tks-admin-cluster/tks-install-admin-tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ spec:
value: false
- name: keycloak_url
value: ""
# TODO: check if this is necessary
volumes:
- name: config
- name: admin-kubeconfig
secret:
secretName: tks-admin-kubeconfig-secret
templates:
Expand All @@ -33,15 +34,22 @@ spec:
template: installApps
arguments:
parameters:
## If value-override for admin-cluster is different from that of user-cluster,
## then the ingress-nginx should be copied to tks-admin-tools group.
- name: list
value: |
[
## If value-override for admin-cluster is different from that of user-cluster,
## then the ingress-nginx should be copied to tks-admin-tools group.
{ "app_group": "tks-cluster", "path": "ingress-nginx", "namespace": "ingress-nginx", "target_cluster": "" },
{ "app_group": "tks-cluster", "path": "ingress-nginx", "namespace": "ingress-nginx", "target_cluster": "" }
]
when: "{{workflow.parameters.install-nginx}} == true"

- - name: init-keycloak-db
template: init-keycloak-db
arguments:
parameters:
- name: db_password
value: "tacopassword"

- - name: install-keycloak
templateRef:
name: create-application
Expand Down Expand Up @@ -88,6 +96,47 @@ spec:
{ "app_group": "tks-admin-tools", "path": "harbor", "namespace": "harbor", "target_cluster": "" }
]
#######################
# Template Definition #
#######################
- name: init-keycloak-db
inputs:
parameters:
- name: db_host
value: "postgres.tks-db"
- name: db_user
value: "bn_keycloak"
- name: db_password
value: "password"
- name: db_dbname
value: "bitnami_keycloak"
container:
name: init-keycloak-db
image: jbergknoff/postgresql-client
env:
# postgres admin username
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_HOST
value: "{{ inputs.parameters.db_host }}"
- name: POSTGRES_ADMIN_PW
valueFrom:
secretKeyRef:
name: argo-postgres-config
key: postgres-password
command:
- /bin/bash
- "-exc"
- |
# config for new keycloak DB
NEW_USER="{{ inputs.parameters.db_user }}"
NEW_DB="{{ inputs.parameters.db_dbname }}"
NEW_USER_PASSWORD="{{ inputs.parameters.db_password }}"
# psql 명령어를 사용하여 사용자와 데이터베이스를 생성하고 권한을 부여
export PGPASSWORD=$POSTGRES_ADMIN_PW
psql -h $POSTGRES_HOST -U $POSTGRES_USER -d postgres <<EOF
CREATE USER $NEW_USER WITH PASSWORD '$NEW_USER_PASSWORD';
CREATE DATABASE $NEW_DB WITH OWNER = $NEW_USER;
GRANT ALL PRIVILEGES ON DATABASE $NEW_DB TO $NEW_USER;
EOF

0 comments on commit 25940d5

Please sign in to comment.