Overview
This template provides a production‑ready Keycloak stack as a Monk runnable. You can:- Run it directly to get a managed Keycloak instance with integrated PostgreSQL database
- Inherit it in your own runnable to seamlessly add authentication and authorization capabilities to your stack
What this template manages
- Keycloak server container (development mode, configurable tag)
- PostgreSQL database (user and configuration storage)
- Network service on port 8080
- Admin console with customizable realm settings
- Authentication flows and identity brokering
- Database connection and credential management
Quick start (run directly)
- Load templates
- Run Keycloak stack with defaults
- Customize credentials (recommended via inheritance)
variables. Secrets added with monk secrets add will not affect this runnable unless you inherit it and reference those secrets.
- Preferred: inherit and replace variables with
secret("...")as shown below. - Alternative: fork/clone and edit the
variablesinkeycloak/stack.yml, thenmonk load MANIFESTand run.
http://localhost:8080 (or the runnable hostname inside Monk networks) using the configured admin credentials.
Important: Default credentials are admin/admin for Keycloak admin and monk/monk for database. Change these in production!
Configuration
Key variables you can customize in this template:Use by inheritance (recommended for apps)
Inherit the Keycloak stack in your application and declare a connection. Example:Stack components
keycloak/keycloak- Keycloak server (port 8080)keycloak/postgres- PostgreSQL database (port 5432, internal)
Ports and connectivity
- Service:
keycloakon TCP port8080 - Admin console:
http://\<hostname>:8080/admin - From other runnables in the same process group, use
connection-hostname("\<connection-name>")to resolve the Keycloak host.
HTTPS Configuration
By default, Keycloak requires HTTPS for production use. If running on HTTP (development), you may need to disable the HTTPS requirement:Features
- Single Sign-On (SSO) - Authenticate once, access multiple services
- Identity brokering and social login - Google, Facebook, GitHub, and more
- User federation - LDAP and Active Directory integration
- OAuth 2.0 and OpenID Connect - Industry-standard protocols
- Fine-grained authorization - Role-based and attribute-based access control
- Admin console - Web-based management interface
- Account management - Self-service user profile and password management
- Two-factor authentication - OTP, WebAuthn, and more
- Brute-force protection - Built-in security measures
Related templates
- See other templates in this repository for complementary services
- Combine with monitoring tools (
prometheus-grafana/) for observability - Integrate with your application stack as needed
- For PostgreSQL alternatives, see
postgresql/template in this repository
Troubleshooting
- If you changed
kc_passbut Keycloak has existing data, authentication may fail. Reset the database or update credentials inside Keycloak to match. - Ensure the database connection is healthy before Keycloak starts (handled automatically via
dependsdirective). - For HTTPS errors in development, run the
disable-admin-httpsaction as shown above. - Check logs:
- View individual component logs: