keycloak-operator

by Ad Noctem Collective

Helm chartv0.1.2App 26.0.6MIT

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

About this chart

FMJ Studios - 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. Unfortunately the Keycloak Project does not provide a way to install the Operator via a Helm Chart, thus making it challenging to manage. This Helm Chart is built from the official upstream sources and closely tracks these for changes. It delivers all of these features within a single Docker image available on quay.io.

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

✨ TL;DR

Helm Repository Installation

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

OCI Installation

helm install oci://ghcr.io/fmjstudios/helm/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 and (Roles) keycloak-operator-role. These are enabled by default.

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

Parameters

Image parameters

NameDescriptionValue
image.registryThe Docker registry to pull the image fromquay.io
image.repositoryThe registry repository to pull the image fromkeycloak/keycloak-operator
image.tagThe image tag to pull26.0.6
image.digestThe image digest to pull""
image.pullPolicyThe Kubernetes image pull policyIfNotPresent
image.pullSecretsA list of secrets to use for pulling images from private registries[]

Name overrides

NameDescriptionValue
nameOverrideString to partially override kcOperator.fullname""
fullnameOverrideString to fully override kcOperator.fullname""

Service parameters

NameDescriptionValue
service.typeThe type of service to createClusterIP
service.portThe port to use on the service80
service.nodePortThe Node port to use on the service30080
service.annotationsAnnotations for the service resource{}
service.labelsLabels for the service resource{}
service.externalTrafficPolicyThe external traffic policy for the serviceCluster
service.internalTrafficPolicyThe internal traffic policy for the serviceCluster
service.clusterIPDefine a static cluster IP for the service""
service.loadBalancerIPSet the Load Balancer IP""
service.loadBalancerClassDefine Load Balancer class if service type is LoadBalancer (optional, cloud specific)""
service.loadBalancerSourceRangesService Load Balancer source ranges[]
service.externalIPsService External IPs[]
service.sessionAffinitySession Affinity for Kubernetes service, can be "None" or "ClientIP"None
service.sessionAffinityConfigAdditional settings for the sessionAffinity{}
service.ipFamilyPolicyThe ipFamilyPolicy{}

RBAC parameters

NameDescriptionValue
rbac.createWhether to create RBAC resourcestrue

Service Account parameters

NameDescriptionValue
serviceAccount.createWhether a service account should be createdtrue
serviceAccount.automountWhether to automount the service account tokentrue
serviceAccount.annotationsAnnotations to add to the service account{}
serviceAccount.nameA custom name for the service account, otherwise kcOperator.fullname is used""

Liveness Probe parameters

NameDescriptionValue
livenessProbe.enabledEnable or disable the use of liveness probestrue
livenessProbe.initialDelaySecondsConfigure the initial delay seconds for the liveness probe5
livenessProbe.timeoutSecondsConfigure the initial delay seconds for the liveness probe10
livenessProbe.periodSecondsConfigure the seconds for each period of the liveness probe10
livenessProbe.successThresholdConfigure the success threshold for the liveness probe1
livenessProbe.failureThresholdConfigure the failure threshold for the liveness probe3

Readiness Probe parameters

NameDescriptionValue
readinessProbe.enabledEnable or disable the use of readiness probestrue
readinessProbe.initialDelaySecondsConfigure the initial delay seconds for the readiness probe5
readinessProbe.timeoutSecondsConfigure the initial delay seconds for the readiness probe10
readinessProbe.periodSecondsConfigure the seconds for each period of the readiness probe10
readinessProbe.successThresholdConfigure the success threshold for the readiness probe1
readinessProbe.failureThresholdConfigure the failure threshold for the readiness probe3

Startup Probe parameters

NameDescriptionValue
startupProbe.enabledEnable or disable the use of readiness probestrue
startupProbe.initialDelaySecondsConfigure the initial delay seconds for the startup probe5
startupProbe.timeoutSecondsConfigure the initial delay seconds for the startup probe10
startupProbe.periodSecondsConfigure the seconds for each period of the startup probe10
startupProbe.successThresholdConfigure the success threshold for the startup probe1
startupProbe.failureThresholdConfigure the failure threshold for the startup probe3

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.1.2 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