Files
cozystack/packages/system
Andrei Kvapil 5c7311dc7a fix(keycloak): use management port health endpoints for probes (#2162)
## Summary

- Fix Keycloak crashloop caused by misconfigured liveness/readiness
probes
- Add `KC_HEALTH_ENABLED=true` to activate health endpoints on
management port
- Switch probes from application port 8080 (`/`, `/realms/master`) to
management port 9000 (`/health/live`, `/health/ready`)

## Problem

Keycloak 26.x redirects all HTTP requests on port 8080 to the configured
`KC_HOSTNAME` (HTTPS). Since kubelet does not follow redirects, probes
fail with:

```
Probe terminated redirects, Response body:
```

After consecutive failures, kubelet kills the container → restart →
crashloop.

Additionally, `KC_HEALTH_ENABLED` was not set, so the dedicated health
endpoints on the management port (9000) returned 404 even though the
management interface was active (via `KC_METRICS_ENABLED=true`).

## Changes

- `packages/system/keycloak/templates/sts.yaml`:
- Add `KC_HEALTH_ENABLED=true` env var to activate `/health/live` and
`/health/ready`
  - Expose management port 9000 in container ports
- Liveness probe: `GET /health/live` on port 9000 (was `GET /` on 8080)
- Readiness probe: `GET /health/ready` on port 9000 (was `GET
/realms/master` on 8080)
  - Increase failure thresholds for better startup tolerance

## Test plan

- [x] Verified `/health/live` returns `{"status":"UP"}` (HTTP 200) on
port 9000
- [x] Verified `/health/ready` returns
`{"status":"UP","checks":[{"name":"Keycloak database connections async
health check","status":"UP"}]}` (HTTP 200)
- [x] Confirmed 0 restarts after 10+ minutes
- [x] Confirmed no more `ProbeWarning` or `Killing` events

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-03-10 08:15:18 +01:00
..
2026-03-06 12:03:56 +00:00
2026-03-06 12:03:56 +00:00
2026-03-06 12:03:56 +00:00
2026-03-06 12:03:56 +00:00
2026-01-20 03:24:32 +01:00
2026-03-06 12:03:56 +00:00
2026-03-06 12:03:56 +00:00
2026-02-10 22:16:11 +01:00
2026-03-06 12:03:56 +00:00
2026-03-06 12:03:56 +00:00
2026-03-06 12:03:56 +00:00
2026-03-06 12:03:56 +00:00
2026-02-10 20:19:03 +01:00
2026-01-15 23:32:41 +00:00
2026-01-20 03:24:32 +01:00
2026-02-17 22:54:12 +01:00
2026-01-20 03:24:32 +01:00
2026-03-06 12:03:56 +00:00