From 20a9416e086b5978ba5b97ab2ddb7ba767dde11f Mon Sep 17 00:00:00 2001 From: Damiano Albani Date: Tue, 18 Jul 2023 14:23:20 +0200 Subject: [PATCH] [bitnami/keycloak] Support enabling health endpoints via environment variable (#40893) Support enabling Keycloak health endpoints via environment variable Signed-off-by: Damiano Albani --- .../rootfs/opt/bitnami/scripts/keycloak-env.sh | 2 ++ .../rootfs/opt/bitnami/scripts/libkeycloak.sh | 17 ++++++++++++++++- bitnami/keycloak/README.md | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/bitnami/keycloak/21/debian-11/rootfs/opt/bitnami/scripts/keycloak-env.sh b/bitnami/keycloak/21/debian-11/rootfs/opt/bitnami/scripts/keycloak-env.sh index 1e811e9056b7..6bf20238bcb7 100644 --- a/bitnami/keycloak/21/debian-11/rootfs/opt/bitnami/scripts/keycloak-env.sh +++ b/bitnami/keycloak/21/debian-11/rootfs/opt/bitnami/scripts/keycloak-env.sh @@ -37,6 +37,7 @@ keycloak_env_vars=( KEYCLOAK_CACHE_STACK KEYCLOAK_EXTRA_ARGS KEYCLOAK_ENABLE_STATISTICS + KEYCLOAK_ENABLE_HEALTH_ENDPOINTS KEYCLOAK_ENABLE_HTTPS KEYCLOAK_HTTPS_TRUST_STORE_FILE KEYCLOAK_HTTPS_TRUST_STORE_PASSWORD @@ -128,6 +129,7 @@ export KEYCLOAK_CACHE_TYPE="${KEYCLOAK_CACHE_TYPE:-ispn}" export KEYCLOAK_CACHE_STACK="${KEYCLOAK_CACHE_STACK:-}" export KEYCLOAK_EXTRA_ARGS="${KEYCLOAK_EXTRA_ARGS:-}" export KEYCLOAK_ENABLE_STATISTICS="${KEYCLOAK_ENABLE_STATISTICS:-false}" +export KEYCLOAK_ENABLE_HEALTH_ENDPOINTS="${KEYCLOAK_ENABLE_HEALTH_ENDPOINTS:-false}" export KEYCLOAK_ENABLE_HTTPS="${KEYCLOAK_ENABLE_HTTPS:-false}" KEYCLOAK_HTTPS_TRUST_STORE_FILE="${KEYCLOAK_HTTPS_TRUST_STORE_FILE:-"${KC_HTTPS_TRUST_STORE_FILE:-}"}" export KEYCLOAK_HTTPS_TRUST_STORE_FILE="${KEYCLOAK_HTTPS_TRUST_STORE_FILE:-}" diff --git a/bitnami/keycloak/21/debian-11/rootfs/opt/bitnami/scripts/libkeycloak.sh b/bitnami/keycloak/21/debian-11/rootfs/opt/bitnami/scripts/libkeycloak.sh index 840deedc824f..4fe71084e63b 100644 --- a/bitnami/keycloak/21/debian-11/rootfs/opt/bitnami/scripts/libkeycloak.sh +++ b/bitnami/keycloak/21/debian-11/rootfs/opt/bitnami/scripts/libkeycloak.sh @@ -84,7 +84,7 @@ keycloak_validate() { check_allowed_port KEYCLOAK_HTTP_PORT check_allowed_port KEYCLOAK_HTTPS_PORT - for var in KEYCLOAK_ENABLE_HTTPS KEYCLOAK_ENABLE_STATISTICS; do + for var in KEYCLOAK_ENABLE_HTTPS KEYCLOAK_ENABLE_STATISTICS KEYCLOAK_ENABLE_HEALTH_ENDPOINTS; do if ! is_true_false_value "${!var}"; then print_validation_error "The allowed values for $var are [true, false]" fi @@ -178,6 +178,20 @@ keycloak_configure_metrics() { keycloak_conf_set "metrics-enabled" "$KEYCLOAK_ENABLE_STATISTICS" } +######################## +# Enable health endpoints +# Globals: +# KEYCLOAK_* +# Arguments: +# None +# Returns: +# None +######################### +keycloak_configure_health_endpoints() { + info "Enabling health endpoints" + keycloak_conf_set "health-enabled" "$KEYCLOAK_ENABLE_HEALTH_ENDPOINTS" +} + ######################## # Configure hostname # Globals: @@ -303,6 +317,7 @@ keycloak_initialize() { fi keycloak_configure_database keycloak_configure_metrics + keycloak_configure_health_endpoints keycloak_configure_http keycloak_configure_hostname keycloak_configure_cache diff --git a/bitnami/keycloak/README.md b/bitnami/keycloak/README.md index 7b80a716ccc9..175cdab37025 100644 --- a/bitnami/keycloak/README.md +++ b/bitnami/keycloak/README.md @@ -210,6 +210,11 @@ volumes: The Bitnami Keycloak container can activate different set of statistics (database, jgroups and http) by setting the environment variable `KEYCLOAK_ENABLE_STATISTICS=true`. +### Enabling health endpoints + +The Bitnami Keycloak container can activate several endpoints providing information about the health of Keycloak, by setting the environment variable `KEYCLOAK_ENABLE_HEALTH_ENDPOINTS=true`. +See [the official documentation](https://www.keycloak.org/server/health) for more information about these endpoints. + #### Full configuration The image looks for configuration files in the `/bitnami/keycloak/configuration/` directory, this directory can be changed by setting the KEYCLOAK_MOUNTED_CONF_DIR environment variable.