Skip to content

Using ConfigMaps to import a Keycloak Realm

Overview

If you need to import a keycloak realm you need need a configMap .

Note: You can not configure from-file option in your Yaml File . To create a Configmap from a realm export file you can use:

  • kubectl command line tool
  • kustomize tool
  • or you can use helm charts.

In this sample we will use kubectl to configure a configMap

# ls realm-config
  RBAC-realm.json

#  kubectl create ns keycloak-oidc-ns
  namespace/keycloak-oidc-ns created

#  kubectl create configmap keycloak-oidc-configmap  --from-file=realm-config -n keycloak-oidc-ns
  configmap/keycloak-oidc-configmap created

Verify config Map:
#  kubectl describe configmap keycloak-oidc-configmap  -n keycloak-oidc-ns | more
  Name:         keycloak-oidc-configmap
  Namespace:    keycloak-oidc-ns
  Labels:       <none>
  Annotations:  <none>

  Data
  ====
  RBAC-realm.json:
  ----
  {
    "id" : "RBAC",
 
    "realm" : "RBAC",
    "notBefore" : 1644491652,
    .. 

Mount Path and Volume Configuration for pod Deployment

  • Keycloak expects inport data in : /opt/keycloak/data/import
        volumeMounts:
          - name: keycloak-oidc-volume
            mountPath: /opt/keycloak/data/import
        ..
      volumes:
        - name: keycloak-oidc-volume
          configMap:
            name: keycloak-oidc-configmap

Links:

Published inKeycloak

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *