---
title: Deploy Keycloak with AI on Blossom
url: "/deploy/keycloak/"
canonical_url: https://blossom88.com/deploy/keycloak/
markdown_url: https://blossom88.com/deploy/keycloak.md
summary: Deploy Keycloak with AI on Blossom. Give your apps a shared OpenID Connect
  sign-in and store users, clients and realms in managed PostgreSQL.
categories:
- deployment
- identity
stack:
- Java
- Quarkus
- PostgreSQL
---

# Deploy Keycloak with AI on Blossom

[Keycloak](https://www.keycloak.org/) gives your apps a common sign-in service.
Manage users and client applications in one place, then connect each app
through OpenID Connect.

| Part | Purpose |
|---|---|
| Keycloak | Handles sign-in, issues tokens and provides the admin console |
| Managed PostgreSQL | Stores realms, clients, users and signing configuration |

This setup uses the [Apache 2.0 Keycloak distribution](https://github.com/keycloak/keycloak/blob/main/LICENSE.txt).
Your users reach the sign-in endpoints. The admin console stays behind
Blossom Account access and Keycloak's own sign-in.

![Keycloak's sample realm prompts a user to sign in.](/deploy/assets/images/keycloak/sign-in.webp)

<details class="optional-reading" markdown="1">
<summary>Deployment setup and commands</summary>

Check the current [Keycloak container](https://www.keycloak.org/server/containers)
and [PostgreSQL](https://www.keycloak.org/server/db) requirements. Pin a
compatible official Keycloak image index. Create a prebuilt-image Environment
and link a managed PostgreSQL Database as `DATABASE_URL`.

    blossom profile:show
    blossom app:create --data app.yml
    blossom environment:create --data environment.yml
    blossom database_instance:create --data postgres.yml --follow
    blossom environment_link:create --data postgres-link.yml

Start Keycloak with `kc.sh start` on port `8080`. Translate the linked URL
into `KC_DB_URL` (the JDBC URL), `KC_DB_USERNAME` and `KC_DB_PASSWORD`
at startup. Set `KC_DB=postgres`, `KC_HTTP_ENABLED=true` and
`KC_PROXY_HEADERS=xforwarded` for Blossom's HTTPS proxy. Use the HTTPS
Service URL as `KC_HOSTNAME`, which establishes the public issuer. Configure
the native `/health/ready` check on the Service port with
`KC_HEALTH_ENABLED=true` and `KC_HTTP_MANAGEMENT_HEALTH_ENABLED=false`.
Allow time for first startup.

Use Blossom Account access with public exceptions for `/realms/*` and
`/resources/*`. Keycloak handles the protocol and user authentication on
those paths. Keep `/admin/` and the administration API behind the gate.
Keep the temporary bootstrap username and password in private runtime
variables. Create an administrator for ongoing use before removing the
bootstrap account and its variables.

    blossom service:create --data service.yml
    blossom env_var:push --environment environment-100 --file .env.production
    blossom environment:deploy --id environment-100 --follow

</details>

## Ask Your Agent

> **Ask your AI agent:** Deploy Keycloak on Blossom and help me add sign-in to my first app.
>
> Follow this guide: https://blossom88.com/deploy/keycloak/

[Install the Blossom CLI and skill](https://docs.blossom88.com/learn/getting-started/install/) on your agent's machine and choose a Blossom Cloud Location when you log in. You can also use [Blossom BYOC (bring your own cloud)](https://docs.blossom88.com/learn/getting-started/choose-your-cloud/#blossom-byoc).

## Connect an App

Create a realm, a test user and an OpenID Connect client. Give your app the
realm issuer, client ID and exact callback URL. Use Authorization Code with PKCE
for a public client. Sign in, then check that the app receives the expected
identity. Keep the issuer and database stable across updates.

## What You Get

- An HTTPS issuer for OpenID Connect
- An admin console protected by Blossom Account access and Keycloak sign-in
- Users, clients and realms kept in managed PostgreSQL
