Skip to content

Commit

Permalink
keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzheng422 committed Oct 10, 2024
1 parent b585e42 commit 02228af
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
48 changes: 35 additions & 13 deletions redhat/ocp4/4.15/2024.08.rhdh.book.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,30 @@ We will use keycloak to manage the user, and use it as the oauth2 provider for t
oc new-project demo-keycloak



oc delete -f ${BASE_DIR}/data/install/keycloak-db-pvc.yaml -n demo-keycloak

cat << EOF > ${BASE_DIR}/data/install/keycloak-db-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgresql-db-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
EOF

oc create -f ${BASE_DIR}/data/install/keycloak-db-pvc.yaml -n demo-keycloak



oc delete -f ${BASE_DIR}/data/install/keycloak-db.yaml -n demo-keycloak

cat << EOF > ${BASE_DIR}/data/install/keycloak-db.yaml
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand All @@ -526,6 +547,7 @@ spec:
containers:
- name: postgresql-db
image: postgres:15
args: ["-c", "max_connections=1000"]
volumeMounts:
- mountPath: /data
name: cache-volume
Expand All @@ -540,18 +562,8 @@ spec:
value: keycloak
volumes:
- name: cache-volume
ephemeral:
volumeClaimTemplate:
metadata:
labels:
app: postgresql-db
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
# storage size does not matter for hostpath, becuase it will use all of the disk free space.
# but it must be set to actual required size for other storage class
storage: 1Gi
persistentVolumeClaim:
claimName: postgresql-db-pvc
---
apiVersion: v1
kind: Service
Expand Down Expand Up @@ -624,8 +636,18 @@ oc get secret example-kc-initial-admin -n demo-keycloak -o jsonpath='{.data.user
# admin

oc get secret example-kc-initial-admin -n demo-keycloak -o jsonpath='{.data.password}' | base64 --decode && echo
# b60d1b2c0cdc4b10a3e7b46f234286e8
# 51a3bf077ab5465e84c51729c6a29f27


# in postgresql pod terminal
psql -U testuser -d keycloak
# Type "help" for help.

# keycloak=# SHOW max_connections;
# max_connections
# -----------------
# 1000
# (1 row)
```

Base on the demo requirement, we need to create a realm named `RHDH`, which will be used for rhdh later.
Expand Down
6 changes: 4 additions & 2 deletions redhat/ocp4/4.15/2024.10.keycloak.performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ export PATH=/opt/keycloak/bin:$PATH

```yaml
spec:
http:
httpEnabled: true
cache:
configMapFile:
key: keycloak.cache-ispn.xml
Expand Down Expand Up @@ -517,7 +519,7 @@ oc apply -f ${BASE_DIR}/data/install/keycloak-script-create-users.yaml -n demo-k
```bash

TOTAL_USERS=50000
NUM_JOBS=5
NUM_JOBS=10
USERS_PER_JOB=$((TOTAL_USERS / NUM_JOBS))

for job_id in $(seq 1 $NUM_JOBS); do
Expand Down Expand Up @@ -567,7 +569,7 @@ spec:
name: keycloak-script-config-${job_id}
backoffLimit: 4
EOF

oc delete -n demo-keycloak -f ${BASE_DIR}/data/install/keycloak-script-create-users-${job_id}.yaml
oc apply -f ${BASE_DIR}/data/install/keycloak-script-create-users-${job_id}.yaml -n demo-keycloak
done

Expand Down

0 comments on commit 02228af

Please sign in to comment.