Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ClusterKeycloakInstance

ClusterKeycloakInstance is the cluster-scoped counterpart of KeycloakInstance. Resources in any namespace can reference it, making it useful for a shared Keycloak server on a multi-tenant platform.

Example

Password grant

apiVersion: keycloak.hostzero.com/v1beta1
kind: ClusterKeycloakInstance
metadata:
  name: central-keycloak
spec:
  baseUrl: https://keycloak.example.com
  auth:
    passwordGrant:
      secretRef:
        name: keycloak-admin
        namespace: keycloak-system

Service-account client

apiVersion: keycloak.hostzero.com/v1beta1
kind: ClusterKeycloakInstance
metadata:
  name: central-keycloak
spec:
  baseUrl: https://keycloak.example.com
  auth:
    clientCredentials:
      secretRef:
        name: keycloak-operator-client
        namespace: keycloak-system

Authentication

Same rules as KeycloakInstance: exactly one of auth.passwordGrant / auth.clientCredentials; passwords and client secrets always live in a Secret; username / clientId may be inlined.

The only difference: secretRef.namespace is required because the resource is cluster-scoped.

TLS

spec.tls mirrors the namespaced KeycloakInstance.spec.tls shape, with one difference: every namespace field is required.

spec:
  tls:
    caCert:
      configMapRef:
        name: keycloak-ca
        namespace: keycloak-system
        # key defaults to "ca.crt"
    # insecureSkipVerify: true  # disables verification, ignores caCert

Exactly one of caCert.secretRef / caCert.configMapRef may be set; setting both is rejected by admission.

Spec

FieldTypeDescriptionRequired
baseUrlstringURL of the Keycloak serverYes
auth.passwordGrant / auth.clientCredentialsobjectAuthentication method (exactly one)Yes
auth.passwordGrant.usernamestringInline admin username (overrides secretRef.usernameKey)No
auth.passwordGrant.secretRef.namestringName of the credentials SecretYes
auth.passwordGrant.secretRef.namespacestringNamespace of the credentials SecretYes
auth.passwordGrant.secretRef.usernameKeystringSecret key for the usernameNo (default username)
auth.passwordGrant.secretRef.passwordKeystringSecret key for the passwordNo (default password)
auth.clientCredentials.clientIdstringInline client id (overrides secretRef.clientIdKey)No
auth.clientCredentials.secretRef.namestringName of the client-credentials SecretYes
auth.clientCredentials.secretRef.namespacestringNamespace of the client-credentials SecretYes
auth.clientCredentials.secretRef.clientIdKeystringSecret key for the client idNo (default client-id)
auth.clientCredentials.secretRef.clientSecretKeystringSecret key for the client secretNo (default client-secret)
realmstringAdmin realm nameNo (default master)
tls.caCert.secretRef / tls.caCert.configMapRefobjectPEM-encoded CA bundle source (exactly one)No
tls.insecureSkipVerifyboolDisable TLS verification (overrides caCert)No (default false)
token.*objectToken cache configurationNo

Comparison with KeycloakInstance

AspectKeycloakInstanceClusterKeycloakInstance
ScopeNamespacedCluster
Secret namespaceOptional (defaults to same as resource)Required
Accessible fromSame namespace onlyAny namespace
Short namekcickci

Migrating from the pre-auth shape

The legacy spec.credentials / spec.client blocks have been replaced by spec.auth. Migrate existing manifests as shown in the KeycloakInstance migration guide; the only difference is that secretRef.namespace must always be set for cluster-scoped resources.