Skip to content

Commit

Permalink
add persistent sessions as provisioning config and part of CI
Browse files Browse the repository at this point in the history
Signed-off-by: Kamesh Akella <[email protected]>
  • Loading branch information
kami619 authored and mhajas committed May 2, 2024
1 parent 5e38fbd commit b280a6c
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/actions/keycloak-create-deployment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ inputs:
disableStickySessions:
description: 'Disable sticky session in OpenShift Route'
default: 'true'
enablePersistentSessions:
description: 'Enable persistent sessions to DB'
default: 'false'
image:
description: 'Keycloak Image'
podMemoryRequests:
Expand Down Expand Up @@ -49,6 +52,7 @@ runs:
KC_NAMESPACE_PREFIX: ${{ inputs.projectPrefix }}
KC_INSTANCES: ${{ inputs.replicas }}
KC_DISABLE_STICKY_SESSION: ${{ inputs.disableStickySessions }}
KC_PERSISTENT_SESSIONS: ${{ inputs.enablePersistentSessions }}
KC_CONTAINER_IMAGE: ${{ inputs.image }}
KC_MEMORY_REQUESTS_MB: ${{ inputs.podMemoryRequests }}
KC_MEMORY_LIMITS_MB: ${{ inputs.podMemoryLimit }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rosa-multi-az-cluster-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ jobs:
KC_CPU_REQUESTS: 6
KC_INSTANCES: 3
KC_DISABLE_STICKY_SESSION: true
KC_PERSISTENT_SESSIONS: false
KC_MEMORY_REQUESTS_MB: 3000
KC_MEMORY_LIMITS_MB: 4000
KC_DB_POOL_INITIAL_SIZE: 30
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rosa-scaling-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ env:
KC_CPU_REQUESTS: 6
KC_INSTANCES: 3
KC_DISABLE_STICKY_SESSION: true
KC_PERSISTENT_SESSIONS: false
KC_MEMORY_REQUESTS_MB: 3000
KC_MEMORY_LIMITS_MB: 4000
KC_DB_POOL_INITIAL_SIZE: 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Deploy OpenShift and ROSA as described in xref:kubernetes-guide::prerequisite/pr
KC_CPU_REQUESTS=6
KC_INSTANCES=3
KC_DISABLE_STICKY_SESSION=true
KC_PERSISTENT_SESSIONS=false
KC_MEMORY_REQUESTS_MB=3000
KC_MEMORY_LIMITS_MB=4000
KC_DB_POOL_INITIAL_SIZE=30
Expand Down
4 changes: 4 additions & 0 deletions doc/kubernetes/modules/ROOT/pages/customizing-deployment.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ Available options:
+
NOTE: This option is implemented only for OpenShift deployments.

[[KC_PERSISTENT_SESSIONS,KC_PERSISTENT_SESSIONS]]
KC_PERSISTENT_SESSIONS::
We can enable the persistent sessions to be stored in the user-sessions and client-sessions into the target database in use. By default, the `KC_PERSISTENT_SESSIONS` is set to `false` in our benchmark provisioning module, we need to override it to `true` to enable this feature. Please note that, there will be a tax on the endpoint performance when you enable this feature and this is as designed, to provide better resiliency for Keycloak.

== Available Benchmark options

The following configuration options are available to configure the helper applications.
Expand Down
4 changes: 4 additions & 0 deletions provision/common/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ vars:
KC_REMOTE_STORE_HOST: '{{default "localhost" .KC_REMOTE_STORE_HOST}}'
KC_REMOTE_STORE_PORT: '{{default "11222" .KC_REMOTE_STORE_PORT}}'
KC_DISABLE_STICKY_SESSION: '{{default "false" .KC_DISABLE_STICKY_SESSION}}'
KC_PERSISTENT_SESSIONS: '{{default "false" .KC_PERSISTENT_SESSIONS}}'
MULTI_AZ: '{{default "false" .MULTI_AZ}}'
ENV_DATA_JSON_PATH: "{{.ROOT_DIR}}/../environment_data.json"
KC_REPOSITORY: '{{default "" .KC_REPOSITORY}}'
Expand Down Expand Up @@ -70,13 +71,15 @@ tasks:
- echo {{.KC_REMOTE_STORE_HOST}} > .task/var-KC_REMOTE_STORE_HOST
- echo {{.KC_REMOTE_STORE_PORT}} > .task/var-KC_REMOTE_STORE_PORT
- echo {{.KC_DISABLE_STICKY_SESSION}} > .task/var-KC_DISABLE_STICKY_SESSION
- echo {{.KC_PERSISTENT_SESSIONS}} > .task/var-KC_PERSISTENT_SESSIONS
- echo {{.KC_HOSTNAME_OVERRIDE}} > .task/var-KC_HOSTNAME_OVERRIDE
- echo {{.KC_HEALTH_HOSTNAME}} > .task/var-KC_HEALTH_HOSTNAME
- |
jq -n --arg cpu_requests_per_pod "{{ .KC_CPU_REQUESTS }}" \
--arg cpu_limits_per_pod "{{ .KC_CPU_LIMITS }}" \
--arg num_of_pods "{{ .KC_INSTANCES }}" \
--argjson sticky_sessions "{{ .KC_DISABLE_STICKY_SESSION }}" \
--argjson persistent_sessions "{{ .KC_PERSISTENT_SESSIONS }}" \
--arg mem_req_per_pod "{{ .KC_MEMORY_REQUESTS_MB }}" \
--arg mem_limit_per_pod "{{ .KC_MEMORY_LIMITS_MB }}" \
--arg db_pool_init "{{ .KC_DB_POOL_INITIAL_SIZE }}" \
Expand Down Expand Up @@ -134,6 +137,7 @@ tasks:
- test "{{.KC_REMOTE_STORE_HOST}}" == "$(cat .task/var-KC_REMOTE_STORE_HOST)"
- test "{{.KC_REMOTE_STORE_PORT}}" == "$(cat .task/var-KC_REMOTE_STORE_PORT)"
- test "{{.KC_DISABLE_STICKY_SESSION}}" == "$(cat .task/var-KC_DISABLE_STICKY_SESSION)"
- test "{{.KC_PERSISTENT_SESSIONS}}" == "$(cat .task/var-KC_PERSISTENT_SESSIONS)"
- test "{{.KC_HOSTNAME_OVERRIDE}}" == "$(cat .task/var-KC_HOSTNAME_OVERRIDE)"
- test "{{.KC_HEALTH_HOSTNAME}}" == "$(cat .task/var-KC_HEALTH_HOSTNAME)"

Expand Down
1 change: 1 addition & 0 deletions provision/keycloak-tasks/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ vars:
KC_REMOTE_STORE_HOST: '{{default "localhost" .KC_REMOTE_STORE_HOST}}'
KC_REMOTE_STORE_PORT: '{{default "11222" .KC_REMOTE_STORE_PORT}}'
KC_DISABLE_STICKY_SESSION: '{{default "false" .KC_DISABLE_STICKY_SESSION}}'
KC_PERSISTENT_SESSIONS: '{{default "false" .KC_PERSISTENT_SESSIONS}}'

tasks:
default:
Expand Down
3 changes: 2 additions & 1 deletion provision/keycloak-tasks/Utils.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ tasks:
PRODUCT: '{{ default "keycloak-operator" .KC_OPERATOR_NAME }}'
CHANNEL: '{{ .KC_OPERATOR_CHANNEL }}'
VERSION: '{{ .KC_OPERATOR_VERSION }}'

install-keycloak-operator:
desc: "Install the Keycloak operator"
internal: true
Expand Down Expand Up @@ -255,6 +255,7 @@ tasks:
--set namespace={{.NAMESPACE}}
--set keycloakAdminPassword="{{.KC_ADMIN_PASSWORD}}"
--set disableIngressStickySession={{ .KC_DISABLE_STICKY_SESSION }}
--set persistentSessions={{ .KC_PERSISTENT_SESSIONS }}
--set nodePortsEnabled=false
../minikube/keycloak
preconditions:
Expand Down
3 changes: 3 additions & 0 deletions provision/minikube/keycloak/templates/keycloak.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ spec:
features:
enabled:
- multi-site # <3>
{{- if .Values.persistentSessions }}
- persistent-user-sessions
{{- end }}
{{- if .Values.infinispan.customConfig }}
# tag::keycloak-ispn[]
cache:
Expand Down
1 change: 1 addition & 0 deletions provision/minikube/keycloak/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ keycloakAdminPassword: admin
disableIngressStickySession: false
jvmDebug: true
predefinedAdmin: true
persistentSessions: false
infinispan:
jgroupsTls: false
customConfig: false
Expand Down
1 change: 1 addition & 0 deletions provision/openshift/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ tasks:
--set namespace={{.KC_NAMESPACE_PREFIX}}keycloak
--set keycloakAdminPassword="{{.KC_ADMIN_PASSWORD}}"
--set disableIngressStickySession={{ .KC_DISABLE_STICKY_SESSION }}
--set persistentSessions={{ .KC_PERSISTENT_SESSIONS }}
--set nodePortsEnabled=false
../minikube/keycloak
- >
Expand Down

0 comments on commit b280a6c

Please sign in to comment.