Search code examples
kuberneteskeycloakkeycloak-operator

How to use custom themes on Keycloak Operator (v13.0.0)?


I was installing Keycloak using Operator (version 13.0.0). The updated code has theme related stuff github repository and supports custom theme integration quite well. All we need an URL where the custom theme is located. I tried it and worked flawlessly.

However, what if we have themes in some local directory, not on some public URL. How do we suppose to upload the theme in the Keycloak then?

I've tried using the File URL and file paths as well but didn't work for me.

The Keycloak.yaml

apiVersion: keycloak.org/v1alpha1
kind: Keycloak
metadata:
  name: keycloak-test
  labels:
    app: keycloak-test
spec:
  instances: 1
  extensions:
    - https://SOME-PUBLIC-URL/keycloak-themes.jar                    
  externalAccess:
    enabled: False
  podDisruptionBudget:
    enabled: True

Solution

  • We can add custom keycloak themes in keycloak operator (v13.0.0) using the below steps:

    1. Create a jar file for your custom theme using step shown here Deploying Keycloak Themes
    2. Create a kubernetes configmap of the jar using the following command
    kubectl create cm customtheme --from-file customtheme.jar
    
    1. To use above configmap update Keycloak.yaml and add the following code block
      keycloakDeploymentSpec:
        experimental:
          volumes:
            defaultMode: 0777
            items:
              - name: customtheme
                mountPath: /opt/jboss/keycloak/standalone/deployments/custom-themes
                subPath: customtheme.jar
                configMaps:
                  - customtheme
    

    Note: Make sure the size of theme is less than 1MB.