Skip to content

Commit

Permalink
[bitnami/keycloak] Support enabling health endpoints via environment …
Browse files Browse the repository at this point in the history
…variable (#40893)

Support enabling Keycloak health endpoints via environment variable

Signed-off-by: Damiano Albani <damiano.albani@gmail.com>
  • Loading branch information
dalbani authored Jul 18, 2023
1 parent 60a343c commit 20a9416
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:-}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions bitnami/keycloak/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 20a9416

Please sign in to comment.