Set up new extensions in Keycloak kubernetes helm charts

8/20/2020

I have a Kubernetes cluster on Azure, where I use Helm to make it easier to manage micro-services and other tools on it, and Keycloak is one of them.

I need to use magic link authenticator in one of my apps, I'm aware that I need to add an extension in my Keycloak chart, but I don't know how.

In the image repository I'm using, they explain how to add custom themes, via extraInitContainers param on chart configuration. I think I can achieve what I want through it.

In this tutorial they say that's the extension, but I have no idea how to add this to my Keycloak instance on k8s by using helm charts. How do I achieve that?

Just more info about my config, I'm running louketo-proxy(as a side car) on some apps where I want to protect.

-- bck
authentication
keycloak
kubernetes
kubernetes-helm

1 Answer

2/5/2021

To publish a theme with original image, first create an archive with the thema.

Create a file custom-themes-values.yml with a content:

extraInitContainers: |
  - name: theme-provider
    image: busybox
    imagePullPolicy: IfNotPresent
    command:
      - sh
    args:
      - -c
      - |
        echo "wgetting theme from maven..."
        wget -O /theme/keycloak-theme.jar  https://repo1.maven.org/maven2/org/acme/keycloak-theme/1.0.0/keycloak-theme-1.0.0.jar
    volumeMounts:
      - name: theme
        mountPath: /theme

extraVolumeMounts: |
  - name: theme
    mountPath: /opt/jboss/keycloak/standalone/deployments

extraVolumes: |
  - name: theme
    emptyDir: {}

Run with:

helm install keycloak codecentric/keycloak --values custom-themes-values.yml

ps: This example the theme was publish into maven repository, but you can copy a local file to.

This way you can adapt to magic-link.

-- Alisson Gomes
Source: StackOverflow