[bitnami/keycloak] Support enabling health endpoints via environment variable (#40893)

Support enabling Keycloak health endpoints via environment variable

Signed-off-by: Damiano Albani <damiano.albani@gmail.com>
This commit is contained in:
Damiano Albani 2023-07-18 14:23:20 +02:00 committed by GitHub
parent 60a343c49f
commit 20a9416e08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View File

@ -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:-}"

View File

@ -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

View File

@ -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.