### Start Minikube with Podman Driver Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/other.adoc Starts a minikube instance using the Podman driver and CRI-O container runtime. This is suitable for lightweight installations. ```shell minikube start --driver=podman --container-runtime=cri-o ``` -------------------------------- ### Verify Keycloak Benchmark Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/installation-minikube.adoc Execute this script after installation to confirm that all services are running and to get a list of available URLs. ```shell ./isup.sh ``` -------------------------------- ### Start Minikube in Default Mode Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/other.adoc Starts a minikube instance with default settings. This is the simplest way to get a local Kubernetes cluster running. ```shell minikube start ``` -------------------------------- ### Start Webserver to Preview Site with Yarn Serve Source: https://github.com/keycloak/keycloak-benchmark/blob/main/antora/README.adoc Start a minimal webserver to preview the documentation site locally. Access it at http://localhost:5000/keycloak-benchmark/. ```bash yarn serve ``` -------------------------------- ### Verify dataset provider installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/dataset/modules/ROOT/pages/installation/installation-quarkus.adoc Access the specified URL to verify the installation. A successful installation will show a status message. ```http http://example.org/realms/master/dataset/status ``` ```json {"status":"No task in progress. New task can be started"} ``` -------------------------------- ### Install Custom Providers Source: https://github.com/keycloak/keycloak-benchmark/blob/main/benchmark/src/main/content/results/README.md Run this command after placing custom provider JAR files in the appropriate directory to complete the installation. ```bash ${keycloak.home.dir}/bin/kc.sh config ``` -------------------------------- ### Verify Task Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-task.adoc Run this command to verify that Task has been installed correctly and to check its version. The output should display the installed Task version. ```bash task --version ``` -------------------------------- ### Example Benchmark Command Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/run/running-benchmark-ansible.adoc A comprehensive example of the benchmark script execution, specifying region, scenario, server URL, user load, measurement duration, and realm configuration. ```bash ./benchmark.sh eu-west-1 --scenario=keycloak.scenario.authentication.ClientSecret \ --server-url=https://keycloak-runner-keycloak.apps.....openshiftapps.com \ --users-per-sec=1000 \ --measurement=600 \ --realm-name=realm-0 \ --clients-per-realm=10000 ``` -------------------------------- ### Verify minikube Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-minikube.adoc Run this command to confirm that minikube has been installed correctly and to check its version. ```bash minikube version ``` -------------------------------- ### Install NPM Dependencies with Yarn Source: https://github.com/keycloak/keycloak-benchmark/blob/main/antora/README.adoc Run this command to install all necessary NPM dependencies for building the documentation site. ```bash yarn install ``` -------------------------------- ### Verify yq Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-yq.adoc Run this command to confirm that yq has been successfully installed and is accessible from your command line. The output should display the installed version of yq. ```bash yq --version ``` -------------------------------- ### Setup Users and Clients via dataset-import.sh Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/scenario/list-sessions.adoc Utilize the dataset-import.sh script to set up realms, users, and clients for scenario testing. ```bash ./dataset-import.sh -a create-realms -r 1 -c 5 -u 30 ``` -------------------------------- ### Enable and Start Libvirtd Service Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/other.adoc Enables and starts the libvirtd service, then adds the current user to the libvirt group. This is a prerequisite for using drivers like KVM2 on Linux. ```bash sudo systemctl enable libvirtd sudo systemctl start libvirtd sudo usermod -a -G libvirt $USER ``` -------------------------------- ### Test AWS CLI Setup Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-awscli.adoc Verify your AWS CLI installation and configuration by running this command. It should output your AWS account ID, ARN, and User ID. ```bash aws sts get-caller-identity ``` -------------------------------- ### Configure and Start Minikube with Persistent Settings Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/other.adoc Stops minikube, sets persistent configuration for memory and CPU, and then starts minikube. This method applies the settings to future minikube instances. ```shell minikube stop minikube config set memory 8192 minikube config set cpus 4 minikube start ``` -------------------------------- ### Observe minikube Pods Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/installation-minikube.adoc Run this command in a separate window to monitor the startup of Pods. Press Ctrl+C to stop watching. ```shell kubectl get pods -A -w ``` -------------------------------- ### Install Python Libraries for Performance Analysis Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/perf-insights.adoc Installs the necessary Python libraries required for the performance analysis script. Ensure you have Python 3 and pip installed. ```bash pip3 install -U -r requirements.txt ``` ```bash python3 -m pip check ``` -------------------------------- ### Setup Users and Clients via REST API Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/scenario/list-sessions.adoc Create realms, users, and clients using the Keycloak REST API for scenario testing. ```bash curl 'https://keycloak-server/realms/master/dataset/create-realms?realm-name=realm-0&count=1&clients-per-realm=30&users-per-realm=200' ``` -------------------------------- ### Run Basic Get Scenario Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/scenario/basic-get.adoc Execute the basic GET scenario using the benchmark CLI. Ensure the target URL is provided via the --basic-url option. The --log-http-on-failure flag is useful for debugging. ```bash bin/kcb.sh \ --scenario=keycloak.scenario.basic.Get \ --basic-url=http://localhost:8080/ \ --log-http-on-failure ``` -------------------------------- ### Install AWS CLI Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-awscli.adoc Download, unzip, and install the AWS CLI version 2. Ensure you have unzip installed. This command installs the AWS CLI to /usr/local/aws-cli and creates symlinks in /usr/local/bin. ```bash curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install ``` -------------------------------- ### Example Ansible Playbook for aws_ec2 Role Source: https://github.com/keycloak/keycloak-benchmark/blob/main/ansible/roles/aws_ec2/README.md This playbook demonstrates how to include and use the `aws_ec2_client` role. Ensure the role is correctly installed and accessible. ```yaml - hosts: localhost connection: local roles: [aws_ec2_client] ``` -------------------------------- ### Grafana Snapshot Time Window Example (Ansible) Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/grafana.adoc Example log output indicating the input format for the `snapGrafana.py` script when using the Ansible module. ```bash INFO: Input for snapGrafana.py is from=1695382925487&to=1695383025382 ``` -------------------------------- ### Start Minikube with KVM2 Driver and CRI-O Runtime Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/other.adoc Starts minikube using the KVM2 driver and CRI-O container runtime, with specific Docker options for file descriptor limits. This configuration is optimized for Linux environments and can offer faster startup and lower resource usage. ```shell minikube start --driver=kvm2 --container-runtime=cri-o --docker-opt="default-ulimit=nofile=102400:102400" ``` -------------------------------- ### Running the aws_ec2 Role to Start Instances Source: https://github.com/keycloak/keycloak-benchmark/blob/main/ansible/roles/aws_ec2/README.md Execute this command to start previously stopped EC2 instances. The host inventory file will be re-created with updated public IP addresses. ```bash ansible-playbook aws_ec2.yml -e region= -e operation=start ``` -------------------------------- ### Verify kubectl Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-kubectl.adoc Run this command to verify that kubectl is installed correctly. It should display help information without attempting to connect to a cluster. ```bash kubectl --help ``` -------------------------------- ### Execute Task with Arguments Example Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/task.adoc Example of passing arguments to a task to retrieve the status of the last completed job for a dataset provider. ```bash task dataset-import -- -a status-completed ``` -------------------------------- ### Verify Helm Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-helm.adoc Run this command to check if Helm is installed correctly and to view its version information. ```bash helm version ``` -------------------------------- ### Grafana Snapshot Time Window Example (kcb.sh) Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/grafana.adoc Example JSON output from `result_grafana_inputs.json` file generated by `kcb.sh`, showing the `snap_grafana_time_window` key. ```json { "uuid": "108fdd0c-41b7-41d5-af66-8a41cff19a8f", "name": "Scenario 'keycloak.scenario.authentication.AuthorizationCode' with 2 users-per-sec", "grafana_input": { "start": { "epoch_seconds": 1695213772, "iso": "2023-09-20T08:42:52-04:00" }, "end": { "epoch_seconds": 1695213810, "iso": "2023-09-20T08:43:30-04:00" }, "input": { "scenario": "keycloak.scenario.authentication.AuthorizationCode", "snap_grafana_time_window": "from=1695213772731&to=1695213810554", "unit": "users-per-sec", "value": 2, "config": "-Drealm-name=test-realm" } } } ``` -------------------------------- ### Verify Java Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-java.adoc Confirm that Java is installed and accessible by executing the Java version command using the JAVA_HOME path. This verifies that the Java runtime environment is functional. ```bash $JAVA_HOME/bin/java --version ``` -------------------------------- ### Analyze Failed Task Run Example Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/task.adoc Example output demonstrating a failed _task_ run, specifically when a `kubectl` command within the `keycloak` task encounters a connection refused error. ```bash task: **[keycloak]** kubectl create namespace keycloak || true **[keycloak]** The connection to the server localhost:8080 was refused - did you specify the right host or port? task: **[keycloak]** kubectl -n keycloak apply ... **[keycloak]** The connection to the server localhost:8080 was refused - did you specify the right host or port? [tlsdisableagent] [INFO] Scanning for projects... [tlsdisableagent] [INFO] [tlsdisableagent] [INFO] ------------... ... task: Failed to run task "**keycloak**": exit status 1 ``` -------------------------------- ### Verify OC CLI Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-openshift.adoc Run this command to check if the oc client is installed and to verify its version against the OpenShift cluster's server version. ```bash oc version ``` -------------------------------- ### Available Infinispan Installation Tasks Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/openshift/installation-infinispan.adoc Lists the available tasks for provisioning Infinispan clusters on OpenShift, including single-cluster, cross-site single-cluster, and cross-site multi-cluster deployments, as well as their corresponding delete tasks. ```bash task: Available tasks for this project: * crossdc: Creates a cross-site enabled Infinispan deployment between 2 OCP clusters * crossdc-single: Creates a cross-site enabled Infinispan deployment between 2 namespaces * delete-crossdc: Deletes the Infinispan CR from cross-site deployment * delete-crossdc-single: Deletes the Infinispan CR in a cross-site deployment in a single OCP cluster * delete-infinispan: Deletes the Infinispan CR * single-cluster: Creates a single cluster Infinispan deployment ``` -------------------------------- ### Build Keycloak Benchmark Module Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/building-benchmark.adoc Use this command to build the keycloak-benchmark module from the source. Ensure you have Git and Java 21 installed, and the repository checked out. ```bash ./mvnw -am -pl benchmark clean install -DskipTests ``` -------------------------------- ### Install Ansible AWS Collections Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/run/running-benchmark-ansible.adoc Run this command to install the necessary Ansible collections for AWS EC2 management. ```bash ./aws_ec2.sh requirements ``` -------------------------------- ### Example .env file for ROSA Cluster Creation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-rosa.adoc This is an example of a .env file used to configure environment variables for the `rosa_create_cluster.sh` script. It specifies cluster name, OpenShift version, region, compute instance type, multi-AZ deployment, and replica count. ```bash CLUSTER_NAME=rosa-kcb VERSION=4.13.8 REGION=eu-central-1 COMPUTE_MACHINE_TYPE=c7g.2xlarge MULTI_AZ=false REPLICAS=3 ``` -------------------------------- ### Install Chaos Mesh using Task Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/cm-network.adoc Installs Chaos Mesh in the Kubernetes cluster. Requires Task and Helm. Defaults to the 'chaos-mesh' namespace. ```bash task install ``` -------------------------------- ### Available Tasks for Keycloak Benchmark Project Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/openshift/cross-site-rosa.adoc Lists the available tasks for the keycloak-benchmark project, including deployment and undeployment options for a cross-site setup. ```bash task: Available tasks for this project: * default: Deploys Infinispan, Aurora DB and Keycloak in a Cross-Site deployment using ROSA clusters * undeploy: Undeploy Infinispan and Keycloak in a Cross-Site deployment using ROSA clusters ``` -------------------------------- ### Install Single Infinispan Cluster Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/openshift/installation-infinispan.adoc Installs a single Infinispan cluster without cross-site functionality. Requires specifying the ROSA cluster name and the target OpenShift namespace. ```bash task single-cluster ROSA_CLUSTER_NAME=gh-keycloak OC_NAMESPACE=infinispan ``` -------------------------------- ### Apply Benchmark Role Source: https://github.com/keycloak/keycloak-benchmark/blob/main/ansible/roles/benchmark/README.md Example playbook to apply the benchmark role to hosts in the 'benchmark' group. ```yaml - hosts: benchmark roles: [benchmark] ``` -------------------------------- ### Test Dataset Module Installation (Quarkus) Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/docker-compose/PROVISION.md Accesses the dataset module's status endpoint to verify its installation in the containerized Keycloak Quarkus distribution. ```json {"status":"No task in progress. New task can be started"} ``` -------------------------------- ### Confirm Dataset Module Deployment (Legacy) Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/docker-compose/PROVISION.md Example log output confirming that the dataset module JAR has been successfully deployed to the Keycloak server. ```log 08:28:15,630 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed "keycloak-benchmark-dataset-0.7-SNAPSHOT.jar" (runtime-name : "keycloak-benchmark-dataset-0.7-SNAPSHOT.jar") ``` -------------------------------- ### Stop, Delete, and Start Minikube with Custom Resources Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/other.adoc Stops and deletes an existing minikube instance, then starts a new one with specified memory and CPU allocations. Useful for allocating more resources to the cluster. ```shell minikube stop minikube delete minikube start --memory 8192 --cpus 4 ``` -------------------------------- ### Generated Ansible Inventory Example Source: https://github.com/keycloak/keycloak-benchmark/blob/main/ansible/roles/aws_ec2/README.md This is an example of the Ansible host inventory file generated after creating instances. It includes details for connecting to the instances, such as the SSH user and private key file. ```yaml benchmark: children: "{{ cluster_name }}_{{ region }}": vars: ansible_user: ec2-user ansible_become: yes ansible_ssh_private_key_file: "{{ cluster_name }}_{{ region }}.pem" hosts: host-1-ip-address: host-2-ip-address: ... ``` -------------------------------- ### Create Realms with Dataset Import Script Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/dataset/modules/ROOT/pages/using-provider.adoc Example of creating 10 new realms using the dataset import script. This command can be used with various arguments to customize realm creation. ```bash ./dataset-import.sh -a create-realms -r 10 ``` -------------------------------- ### Start Legacy Keycloak with PostgreSQL Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/docker-compose/PROVISION.md Launches the Keycloak legacy distribution with a PostgreSQL database in detached mode using Docker Compose. Assumes you are in the `provision/docker-compose` directory. ```shell docker-compose -f keycloak/keycloak-legacy-postgres.yml up -d ``` -------------------------------- ### Configure JVM Options with the Agent Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/tlsdisableagent/README.adoc Add the agent to JVM options using KC_OPTS. This is an example for kcadm.sh. Gatling tests do not require this agent. ```bash export KC_OPTS="-javaagent:${PWD}/tlscheckdisable-agent.jar" ./kcadm.sh config credentials --server https://keycloak-keycloak....nip.io/ --realm master --user ... --password ... ``` -------------------------------- ### Start Quarkus Keycloak with PostgreSQL Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/docker-compose/PROVISION.md Launches the Keycloak Quarkus distribution with a PostgreSQL database in detached mode using Docker Compose. Assumes you are in the `provision/docker-compose` directory. ```shell docker-compose -f keycloak/keycloak-quarkus-postgres.yml up -d ``` -------------------------------- ### Start Network Delay with Task Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/cm-network.adoc Introduces an artificial network delay for Keycloak pods. The DELAY parameter specifies the egress delay, and PODS_ONLY can restrict the delay to inter-pod traffic. Requires Task and Helm. ```bash task start-delay ``` -------------------------------- ### Build and Deploy Custom Keycloak Image on OpenShift Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/custom-image-for-keycloak.adoc These commands are used to delete existing build configurations and imagestreams, create a new build configuration for Keycloak, and start the build process on OpenShift. Ensure you are in the correct directory and have the Keycloak distribution tarball available. ```bash oc delete buildconfig keycloak || true oc delete imagestream keycloak || true oc new-build --strategy docker --binary --image registry.access.redhat.com/ubi9 --name keycloak --build-arg=KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) oc start-build keycloak --from-dir . --follow ``` -------------------------------- ### Install Cross-Site Infinispan in Two OpenShift Clusters Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/openshift/installation-infinispan.adoc Deploys Infinispan clusters with cross-site enabled across two different OpenShift clusters. Requires specifying names for both ROSA clusters and the namespaces within each. ```bash task crossdc ROSA_CLUSTER_NAME_1=gh-keycloak ROSA_CLUSTER_NAME_2=gh-pruivo OC_NAMESPACE_1=infinispan OC_NAMESPACE_2=infinispan ``` -------------------------------- ### Initialize and Apply OpenTofu Remote State Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/opentofu/remote-state/README.md Execute these commands to set up the S3 bucket and DynamoDB table for OpenTofu remote state. This process should only be performed once. ```bash tofu init ``` ```bash tofu apply ``` -------------------------------- ### Speed up User Creation with Limited Unique Passwords Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/dataset/modules/ROOT/pages/using-provider.adoc Example of creating users while limiting the total number of unique passwords to speed up the process. Passwords are reused based on the user's index modulo the unique credential count. ```http .../realms/master/dataset/create-users?realm-name=realm-0&count=1000&unique-credential-count=10 ``` -------------------------------- ### Display Dataset Import Script Usage Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/dataset/modules/ROOT/pages/using-provider.adoc Run this command to receive a help description for the dataset import script, outlining available actions and their arguments. ```bash ./dataset-import.sh -a help ``` -------------------------------- ### Create EC2 Instances Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/run/running-benchmark-ansible.adoc Execute this command to provision EC2 instances for load generation in the specified region. This process takes approximately 5 minutes. ```bash ./aws_ec2.sh create ``` -------------------------------- ### Install Playwright Browsers for Grafana Script Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/grafana.adoc Installs the required browsers for the Playwright Python module if you encounter an 'Executable doesn't exist' error. ```bash playwright install ``` -------------------------------- ### Build and Load Custom Image with Docker for Minikube Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/custom-image-for-keycloak.adoc Build a custom Keycloak Docker image using Docker and load it into the Minikube environment. Ensure the Docker environment is configured for Minikube. ```bash cd quarkus/container cp ../dist/target/keycloak-*.tar.gz . eval $(minikube docker-env) docker build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t localhost/keycloak:local ``` -------------------------------- ### Build Dataset Provider with Maven Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/dataset/modules/ROOT/pages/building-provider.adoc Execute this command to build the dataset provider using Maven. This command verifies the project and specifically builds the 'dataset' module. ```bash ./mvnw clean verify -am -pl dataset ``` -------------------------------- ### Set OLM for Keycloak Operator Installation Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/openshift/installation-openshift.adoc Set this environment variable to true to install the Keycloak operator from the Operator Hub using the Operator Lifecycle Manager. ```shell KC_OPERATOR_OLM=true ``` -------------------------------- ### Run Benchmark with Custom Configuration Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/run/running-benchmark-cli.adoc Execute the benchmark script with a specified scenario, server URL, and realm name. This allows targeting a specific Keycloak instance and test configuration. ```bash ./kcb.sh --scenario=keycloak.scenario.authentication.AuthorizationCode --server-url=https://keycloak-keycloak.192.168.12.345.nip.io --realm-name=test-realm ``` -------------------------------- ### Initialize Benchmark Entities Script Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/preparing-keycloak.adoc Execute this script to create the necessary realm, client, and user entities for load testing. The script is located in the bin folder of the Keycloak Benchmark module. ```shell ./initialize-benchmark-entities.sh -r test-realm -c gatling -u user-0 ``` -------------------------------- ### Delete Single Infinispan Cluster Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/openshift/installation-infinispan.adoc Deletes a previously installed single Infinispan cluster. Requires the same variables used during installation: ROSA cluster name and OpenShift namespace. ```bash task delete-infinispan ROSA_CLUSTER_NAME=gh-keycloak OC_NAMESPACE=infinispan ``` -------------------------------- ### Build and Load Custom Image with Podman for Minikube Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/custom-image-for-keycloak.adoc Build a custom Keycloak Docker image using Podman and load it into the Minikube environment. This is useful for local development and testing. ```bash cd quarkus/container cp ../dist/target/keycloak-*.tar.gz . podman build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t keycloak:local podman image save keycloak:local | minikube image load --overwrite=true - ``` -------------------------------- ### Run Base Scenario Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/scenario/list-sessions.adoc Execute the ListSessions scenario with default settings for a specified duration. ```bash bin/kcb.sh \ --scenario=keycloak.scenario.admin.ListSessions \ --server-url=http://localhost:8080/ \ --measurement=30 \ --username=user-0 \ --client-id=client-0 \ --realm-name=test-realm \ --admin-username=admin \ --admin-password=admin \ --log-http-on-failure ``` -------------------------------- ### Run Keycloak-Benchmark with Parameters Source: https://github.com/keycloak/keycloak-benchmark/blob/main/ansible/roles/benchmark/README.md Command to execute the benchmark playbook, passing custom parameters to the kcb.sh script via the kcb_params variable. Note the required nested quoting for the parameters. ```bash ansible-playbook -i benchmark_${USER}_${region}.yml benchmark.yml \ -e "kcb_params='--scenario=VALUE --server-url=VALUE --concurrent-users=VALUE ... '" ``` -------------------------------- ### Start JFR recording in Keycloak container Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/manual-jfr.adoc Execute the `jcmd` command within the Keycloak container to start a Java Flight Recorder recording. Specify the duration, output filename, and settings profile. ```bash kubectl exec -n _namespace_ _pod_ -- jcmd 1 JFR.start duration=60s filename=/tmp/recording.jfr settings=/usr/lib/jvm/java/lib/jfr/profile.jfc ``` -------------------------------- ### Set JAVA_HOME Environment Variable Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-java.adoc Set the JAVA_HOME environment variable to point to your JDK installation directory. This is crucial for the provisioning automation to locate the correct Java version. If not set, the installation will attempt to find a JDK on the system's PATH. ```bash export JAVA_HOME=/usr/lib/jvm/java-17-openjdk... ``` -------------------------------- ### Configure Benchmark Execution (`env.yml`) Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/run/running-benchmark-ansible.adoc Specify benchmark-related configurations such as the path to the Keycloak benchmark zip file and the heap size for the JVM. ```yaml kcb_zip: ../benchmark/target/keycloak-benchmark-999.0.0-SNAPSHOT.zip kcb_heap_size: 1G ``` -------------------------------- ### Enable PostgreSQL Database Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/customizing-deployment.adoc Set the KC_DATABASE environment variable to 'postgres' to enable PostgreSQL as the Keycloak database. ```bash KC_DATABASE=postgres ``` -------------------------------- ### Get Cache Sizes Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/dataset/modules/ROOT/pages/clearing-caches.adoc Retrieves the count of items in all available caches and remote caches. ```APIDOC ## Get Cache Sizes ### Description Retrieves the count of items in all available caches and remote caches. This endpoint provides insight into the current state of the caches. ### Method GET ### Endpoint /realms/master/cache/sizes ### Request Example ``` http://localhost:8080/auth/realms/master/cache/sizes ``` ### Response Example (The source does not detail the response body structure, but it would likely contain cache names and their respective item counts.) ``` -------------------------------- ### Run Default Benchmark Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/run/running-benchmark-cli.adoc Execute the benchmark script with default settings. Assumes Keycloak is running on http://0.0.0.0:8080 and uses the default authentication scenario. ```bash ./kcb.sh ``` -------------------------------- ### Stop Minikube Instance Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/other.adoc Stops the currently running minikube instance. This can be used to pause the setup. ```bash minikube stop ``` -------------------------------- ### View Quarkus Keycloak Container Logs Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/docker-compose/PROVISION.md Retrieves logs for the PostgreSQL container within the Quarkus Keycloak setup. ```shell docker-compose -f keycloak/keycloak-quarkus-postgres.yml logs postgres ``` -------------------------------- ### View Legacy Keycloak Container Logs Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/docker-compose/PROVISION.md Retrieves logs for the PostgreSQL container within the legacy Keycloak setup. ```shell docker-compose -f keycloak/keycloak-legacy-postgres.yml logs postgres ``` -------------------------------- ### Build the TLS Check Disabling Agent Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/tlsdisableagent/README.adoc Run this script to build the agent. Ensure you have the necessary build tools installed. ```bash ./buildtlsagent.sh ``` -------------------------------- ### Run Task with Database Configuration Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/customizing-deployment.adoc Pass database configuration parameters directly on the command line when running the task command. ```bash task KC_DATABASE="postgres" ``` -------------------------------- ### Check Task Status Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/dataset/modules/ROOT/pages/using-provider.adoc Call this URL using the GET method to check if a dataset provisioning task is currently running. ```APIDOC ## GET /realms/master/dataset/status ### Description Checks the status of any ongoing dataset provisioning tasks. ### Method GET ### Endpoint /realms/master/dataset/status ### Response #### Success Response (200) - **status** (string) - Indicates if a task is in progress or if the system is ready for a new task. - **task-id** (object) - Present if a task is in progress, containing details like `startTimeMs` and `message`. ### Response Example ```json { "status": "Task in progress", "task-id": { "startTimeMs": "1662115169043", "message": "Creation of 1 realms from realm-6 to realm-6" } } ``` ```json { "status": "No task in progress. New task can be started" } ``` ``` -------------------------------- ### Manage OpenTofu Workspaces Source: https://github.com/keycloak/keycloak-benchmark/blob/main/provision/opentofu/README.md Commands for listing, creating, deleting, and selecting OpenTofu workspaces to isolate state. ```bash tofu workspace list ``` ```bash tofu workspace new/delete/select ``` -------------------------------- ### Task Help Information Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/task.adoc Displays help information about the _task_ tool. Can be combined with a task name. ```bash task -h ``` -------------------------------- ### Get Aurora Cluster Endpoint Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/storage/aurora-regional-postgres.adoc Execute this script to obtain the exposed endpoint of the Aurora writer instances, which is required for the KC_DATABASE_URL configuration. ```bash ./provision/aws/rds/aurora_endpoint.sh AURORA_CLUSTER= # The name of the Aurora cluster instance AURORA_REGION= # The AWS region hosting the Aurora cluster ``` -------------------------------- ### Get Cache Sizes Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/dataset/modules/ROOT/pages/clearing-caches.adoc This endpoint retrieves the count of items in all available caches and remote caches. It is useful for monitoring cache usage. ```http http://localhost:8080/auth/realms/master/cache/sizes ``` -------------------------------- ### List Available Kubernetes Contexts Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-openshift.adoc View all available cluster contexts configured for kubectl. ```bash kubectl config get-contexts ``` -------------------------------- ### Verify JAVA_HOME Variable Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/prerequisite/prerequisite-java.adoc Check if the JAVA_HOME environment variable is set correctly by echoing its value. This command should display the path to your JDK installation. ```bash echo $JAVA_HOME ``` -------------------------------- ### Configure multiple realms Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/configuration.adoc Specify the number of realms to run the benchmark against. Defaults to 1. ```bash --realms=1 ``` -------------------------------- ### Build Custom Keycloak Image with Podman Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/pages/util/custom-image-for-keycloak.adoc Build a custom Keycloak container image using Podman. This involves copying the Keycloak distribution tarball, building the image with the specified build arguments, logging into the container registry, and pushing the image. ```bash cd quarkus/container cp ../dist/target/keycloak-*.tar.gz . IMAGE_NAME=quay.io/namespace/repository:tag podman build --build-arg KEYCLOAK_DIST=$(ls keycloak-*.tar.gz) . -t $IMAGE_NAME podman login quay.io podman push $IMAGE_NAME ``` -------------------------------- ### Start EC2 Instances Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/run/running-benchmark-ansible.adoc Command to restart previously stopped EC2 instances. The host inventory file will be updated with new IP addresses. ```bash ./aws_ec2.sh start ``` -------------------------------- ### Upgrade Bash on macOS using Homebrew Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/partials/isup-bash-version-macos.adoc Use these commands to update Homebrew and install the latest Bash version. This is necessary if your current version is below 4. ```shell brew update brew install bash ``` -------------------------------- ### Run Benchmark Script Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/benchmark/modules/ROOT/pages/run/running-benchmark-ansible.adoc Execute the main benchmark script with a region and scenario parameters. This script handles the distribution of load across instances. ```bash ./benchmark.sh ... ``` -------------------------------- ### Check Last Completed Task Result Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/dataset/modules/ROOT/pages/using-provider.adoc Call this URL using the GET method to retrieve the results of the last completed dataset provisioning task. ```APIDOC ## GET /realms/master/dataset/status-completed ### Description Retrieves the results of the most recently completed dataset provisioning task. ### Method GET ### Endpoint /realms/master/dataset/status-completed ### Response #### Success Response (200) - **status** (string) - Indicates the status of the previous task (e.g., "previous task completed"). - **task** (object) - Contains details of the completed task, including `success` (boolean), `startTimeMs`, `message`, and `endTimeMs`. #### Error Response (404) - **status** (string) - "No completed task" ### Response Example ```json { "status": "previous task completed", "task": { "success": "true", "startTimeMs": "1662115169043", "message": "Creation of 1 realms from realm-1 to realm-1", "endTimeMs": "1662115173323" } } ``` ```json { "status": "No completed task" } ``` ``` -------------------------------- ### Check Bash Version on macOS Source: https://github.com/keycloak/keycloak-benchmark/blob/main/doc/kubernetes/modules/ROOT/partials/isup-bash-version-macos.adoc Run this command to display your current installed Bash version. Ensure it is version 4 or higher for compatibility with the `isup.sh` script. ```shell bash --version ```