keycloak-operator
by Hostzero
Helm chartv0.14.0App 0.14.0
A Kubernetes operator for managing Keycloak resources
About this chart
Keycloak Operator Helm Chart
A Helm chart for deploying the Keycloak Operator to Kubernetes.
Prerequisites
- Kubernetes 1.25+
- Helm 3.0+
Installation
From OCI Registry (Recommended)
helm install keycloak-operator oci://ghcr.io/hostzero-gmbh/charts/keycloak-operator \
--namespace keycloak-operator \
--create-namespace
From local chart
helm install keycloak-operator ./charts/keycloak-operator \
--namespace keycloak-operator \
--create-namespace
Install with custom values
helm install keycloak-operator ./charts/keycloak-operator \
--namespace keycloak-operator \
--create-namespace \
--values my-values.yaml
Configuration
See values.yaml for the full list of configurable parameters.
Common Configuration Options
| Parameter | Description | Default |
|---|---|---|
replicaCount | Number of replicas | 1 |
image.repository | Container image repository | ghcr.io/hostzero-gmbh/keycloak-operator |
image.tag | Container image tag | Chart appVersion |
image.pullPolicy | Image pull policy | IfNotPresent |
resources.limits.cpu | CPU limit | 500m |
resources.limits.memory | Memory limit | 256Mi |
resources.requests.cpu | CPU request | 100m |
resources.requests.memory | Memory request | 128Mi |
leaderElection.enabled | Enable leader election | true |
metrics.enabled | Enable metrics endpoint | true |
metrics.serviceMonitor.enabled | Create ServiceMonitor | false |
logging.level | Log level (debug, info, error) | info |
logging.format | Log format (json, console) | json |
otel.enabled | Enable OTLP traces and logs | false |
crds.install | Install CRDs | true |
crds.keep | Keep CRDs on uninstall | true |
Usage
Create a Keycloak Instance Connection
First, create a secret with your Keycloak admin credentials:
kubectl create secret generic keycloak-credentials \
--from-literal=username=admin \
--from-literal=password=your-password
Then create a KeycloakInstance resource:
apiVersion: keycloak.hostzero.com/v1beta1
kind: KeycloakInstance
metadata:
name: my-keycloak
spec:
baseUrl: https://keycloak.example.com
auth:
passwordGrant:
secretRef:
name: keycloak-credentials
Create a Realm
apiVersion: keycloak.hostzero.com/v1beta1
kind: KeycloakRealm
metadata:
name: my-realm
spec:
instanceRef:
name: my-keycloak
definition:
realm: my-realm
enabled: true
displayName: My Realm
Create a Client
apiVersion: keycloak.hostzero.com/v1beta1
kind: KeycloakClient
metadata:
name: my-app
spec:
realmRef:
name: my-realm
definition:
clientId: my-app
enabled: true
protocol: openid-connect
publicClient: false
clientSecretRef:
name: my-app-credentials
Uninstallation
helm uninstall keycloak-operator -n keycloak-operator
Note: By default, CRDs are kept when uninstalling. To remove them:
kubectl delete crd keycloakinstances.keycloak.hostzero.com
kubectl delete crd keycloakrealms.keycloak.hostzero.com
kubectl delete crd keycloakclients.keycloak.hostzero.com
kubectl delete crd keycloakusers.keycloak.hostzero.com
kubectl delete crd keycloakclientscopes.keycloak.hostzero.com
kubectl delete crd keycloakgroups.keycloak.hostzero.com
kubectl delete crd keycloakidentityproviders.keycloak.hostzero.com
Development
Lint the chart
helm lint ./charts/keycloak-operator
Template rendering
helm template keycloak-operator ./charts/keycloak-operator
Package the chart
helm package ./charts/keycloak-operator
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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartkeycloak-operator is pinned at v0.14.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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