keycloak-operator

by Ad Noctem Collective

Helm chartv0.6.0App 26.8.2MITVerified publisher

Keycloak is an open source software product to allow single sign-on with identity and access management

About this chart

Ad Noctem Collective - Keycloak Operator Helm Chart

Keycloak is an open source software product to allow single sign-on with identity and access management aimed at modern applications and services. It supports various protocols such as OpenID, OAuth version 2.0 and SAML and provides features such as user management, two-factor authentication, permissions and roles management, creating token services, etc. The Keycloak Operator will allow you to deploy dedicated instances of Keycloak at will using the newly registered Keycloak CustomResourceDefinition. This Helm chart packages the official upstream manifests and closely tracks these for changes. Keycloak also provides an experimental upstream Helm chart as of 26.8.0; this chart remains independently maintained. The Operator is available as a single Docker image on quay.io.

Head to the Keycloak GitHub Repository for in-depth documentation.

✨ TL;DR

Helm Repository Installation

helm repo add adnoctem https://adnoctem.github.io/charts
helm install keycloak-operator adnoctem/keycloak-operator --version X.Y.Z

OCI Installation

helm install oci://ghcr.io/adnoctem/charts/keycloak-operator:X.Y.Z

Introduction

This chart bootstraps a Keycloak Operator Deployment on a Kubernetes cluster using the Helm package manager. For cluster networking a Service manifest is also created. The chart creates the RBAC roles (ClusterRoles) keycloakrealmimportcontroller-cluster-role, keycloakcontroller-cluster-role, keycloakoidcclientcontroller-cluster-role and keycloaksamlclientcontroller-cluster-role, each bound to the operator's ServiceAccount via a namespace-scoped RoleBinding. These are enabled by default.

[!IMPORTANT] Helm does not upgrade or delete CRDs on helm upgrade (see the Helm documentation) - before upgrading this chart, apply its versioned CRDs to your cluster yourself, after reviewing the migration steps below. Use server-side apply (kubectl apply --server-side -f charts/keycloak-operator/crds/ from this repository) to avoid the client-side annotation size limit on these large schemas. This is required for the new operator to work correctly. This matters most between major CRD schema changes, and whenever new CRDs are added (see the Upgrading notes below).

The chart supports configuring the Kubernetes manifests created for the Operator, however modifications are somewhat discouraged, since the official release for vanilla Kubernetes uses static manifests. The Operator itself does not offer any sort of configuration (to my knowledge). I will try to ensure the chart always matches the upstream deployment at the given versions.

After deployment the Operator gives you access to the Keycloak CR making the deployment of Keycloak (even as a cluster) as simple as:

kubectl apply -f - <<EOF
apiVersion: k8s.keycloak.org/v2alpha1
kind: Keycloak
metadata:
  name: example-kc
spec:
  instances: 1
  db:
    vendor: postgres
    host: postgres-db
    usernameSecret:
      name: keycloak-db-secret
      key: username
    passwordSecret:
      name: keycloak-db-secret
      key: password
  http:
    tlsSecret: example-tls-secret
  hostname:
    hostname: test.keycloak.org
  proxy:
    headers: xforwarded
EOF

Upgrading

To 0.6.0 (Keycloak Operator 26.8.1 -> 26.8.2)

This release upgrades the operator and its default managed Keycloak image to 26.8.2. Existing chart values remain compatible, and all four bundled CRD schemas are unchanged. The managed server introduces breaking security fixes; back up its database and custom resources, and review the tagged upstream migration guide.

Plan downtime for this upgrade. The migration adds a client-registration policy provider that older 26.8.x nodes cannot use, so a rolling server upgrade is unsupported. Before upgrading the operator, set each managed Keycloak resource's spec.update.strategy to RecreateOnImageChange (the default), including resources currently using Auto or Explicit. The operator then stops the old server pods before changing their image. Use a new image tag when upgrading a custom image; resources with an explicit spec.image must be updated separately. See the versioned operator update guide for update-strategy behavior.

Review these integrations before allowing application traffic again:

  • Admin API clients: assign the new built-in kc-admin-api client scope to custom clients and service accounts that call the Admin REST API. When assigned as an optional scope, request it when obtaining tokens. New tokens must include both this scope and the Admin API audience it supplies, or requests receive HTTP 401. The built-in admin-cli and security-admin-console clients receive the scope automatically during migration.
  • Protocol mappers and client registration: mapper creation, modification and deletion now require realm management permission unless a realm administrator explicitly permits mapper types for delegated client administrators. Dynamic Client Registration additionally requires those types in its policy allowlist; both lists must permit each type. Existing disallowed mappers may remain unchanged. Registration policies also block changes to realm default roles and enabling full scope through authenticated registration; move that management to the Admin REST API. Adjust provisioning scripts and permissions before retrying rejected requests.
  • SAML integrations: upstream broker assertions must contain valid bearer subject confirmation and its data. Assertions with ProxyRestriction are rejected by default; arrange compatible assertions with the provider. SAML adapters must use the actual realm URL as the IdP entityID, replacing old idp placeholders; download a fresh adapter configuration. Back-channel logout with SessionIndex requires client signatures and a configured signing certificate, or switch to browser-based logout. SOAP requests now have a 120,000-byte limit; review spi-login-protocol--saml--max-soap-message-request-size if necessary. SAML 1.1 parsing is disabled by default; migrate integrations to supported SAML 2.0.
  • Identity linking and organizations: automatic account linking requires verified email or a trusted provider. Enable Trust Email only when the provider establishes address ownership. Organization domain-based membership can now require local email verification even when realm-wide verification is off; configure and test SMTP and first-login flows. An OIDC email_verified=false value still requires local verification even with Trust Email. Review memberships previously granted from unverified addresses and onboarding that relies on IMPORT mappers; those mappers are not replayed when verification must be retried in another authentication session.
  • Token exchange and CIBA: exchanged access and ID tokens now expire no later than the subject token. Review clients that assume a fresh full token lifetime. Rename custom CIBA form parameters that use reserved protocol claim names such as sub, aud or exp; required claims inside signed request objects remain supported.
  • Administration and operations: client-session statistics now include only clients the caller can view. Grant the appropriate client-view permissions where needed. Stop updating the internal admin-permissions client through the Admin REST API; manage the realm's permissions and policies instead. Explicitly import self-signed server certificates into custom kcadm/kcreg truststores. Review user-storage sync periods if they were shortened to compensate for the previous doubled interval.

To 0.5.0 (Keycloak Operator 26.8.0 -> 26.8.1)

This release upgrades the operator and its default managed Keycloak image to 26.8.1. Back up the Keycloak database and review the tagged upstream migration guide before upgrading. Existing chart values remain compatible, but the managed server includes security changes that can require configuration changes:

  • SMTP with Enable StartTLS now requires a successful TLS upgrade. Verify that the SMTP server supports STARTTLS; email delivery fails instead of falling back to plaintext.
  • X.509 key usage and extended key usage checks now also validate non-critical extensions. Check certificates against your authenticator's configured purposes. CRL files must resolve inside Keycloak's conf directory; move or mount external files there and use a relative CRL path. HTTP CRL and OCSP responses now share the default 10 MB HTTP response limit; review it if your PKI serves larger responses.
  • OIDC identity-provider backchannel logout always validates signatures. Configure the provider's JWKS URL or validating public key even when Validate Signatures is disabled.
  • Identity-provider updates that change the client ID, authentication method or secret destination must supply the actual client secret again, rather than the masked value returned by the API. Update provisioning scripts accordingly. An existing identity provider's providerId can no longer be changed through an update.
  • Direct Kerberos username/password authentication now validates a service ticket against the configured local keytab. Verify the service principal and keytab; browser SPNEGO authentication is unaffected.
  • Use the protocol-agnostic client-registration endpoint or Admin REST API when managing clients of another protocol. Replace semicolons used as query-parameter separators with ampersands.
  • Conditional OTP's Skip OTP for Header rule now requires reverse-proxy headers and a trusted proxy. Configure both and ensure the proxy overwrites client-supplied headers before relying on this rule.

To 0.4.0 (Keycloak Operator 26.7.3 -> 26.8.0)

This release updates the Operator and its default managed Keycloak image to 26.8.0. Back up the Keycloak database and your custom resources, and review the [versioned upstream migration guide][upgrading_2680] before upgrading. Existing Keycloak resources without an explicit spec.image follow the Operator's new default server image; plan for the server's database migrations as well as the Operator update.

Complete these steps before upgrading the Operator:

  1. Update realm-import manifests that link identity providers to organizations. In both spec.realm.identityProviders and nested spec.realm.organizations[].identityProviders, replace the removed organizationId field with an organizationLinks list. To preserve an existing managed association:

    organizationLinks:
      - organizationId: "your-organization-id"
        autoMembership: true
        membershipType: MANAGED
    

    The server migrates existing database links automatically, but your saved import manifests must use the new schema; Kubernetes can prune the removed field. Domain routing now uses each organization's domains[].identityProviderAlias and domains[].autoRedirect. Review domain routing and membership settings after the server migration. New organization links default to unmanaged membership.

  2. Label Secrets referenced by OIDC client resources. Each Secret used by KeycloakOIDCClient.spec.client.auth.secretRef needs operator.keycloak.org/kind: KeycloakOIDCClient. Without it, the Operator reports the Secret as missing. Apply the label in the client's namespace:

    kubectl label secret <secret-name> -n <namespace> \
      operator.keycloak.org/kind=KeycloakOIDCClient --overwrite
    
  3. Review admin TLS certificates for declarative client management. The Operator now rejects a CA certificate that does not cover the internal Service hostname in its admin TLS trust path. Configure an appropriate server certificate for the Service address. Explicitly trusted leaf certificates with an external hostname remain supported for TLS passthrough; that exception does not apply to CA certificates. See the [tagged controller implementation][client_controller_2680].

  4. Apply all four versioned CRDs before the Helm upgrade. The Keycloak and realm-import schemas changed; the OIDC and SAML client schemas are unchanged but remain required:

    helm show crds adnoctem/keycloak-operator --version 0.4.0 | \
      kubectl apply --server-side -f -
    

The Operator now sets a stable cache node name from the Keycloak Pod name. If you use the stateless feature, enable it explicitly (the preview feature set no longer enables it) and set a unique cache-embedded-cluster-name through the Keycloak CR's spec.additionalOptions; the server refuses to start with the default ISPN name. Login-failure tracking now uses th

Deploy keycloak-operator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has keycloak-operator on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartkeycloak-operator is pinned at v0.6.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply