How to configure Keycloak Helm Chart

Viewed 6496

I am trying to convert docker-compose.yaml Keycloak to Char values, I'm stuck with this a bit:

Docker-compose config looks like this:

  keycloak:
    container_name: keycloak
    image: jboss/keycloak:10.0.0
    hostname: keycloak
    command:
      [
        '-b',
        '0.0.0.0',
        '-Djboss.socket.binding.port-offset=1000',
        '-Dkeycloak.migration.action=import',
        '-Dkeycloak.migration.provider=dir',
        '-Dkeycloak.migration.dir=/keycloak',
        '-Dkeycloak.migration.strategy=IGNORE_EXISTING',
      ]
    volumes:
      - ./keycloak:/realm-config
    environment:
      KEYCLOAK_USER: admin@example.com
      KEYCLOAK_PASSWORD: password
    networks:
      keycloak:
        aliases:
          - keycloak.localtest.me
    ports:
      - 9080:9080/tcp

What I'm trying to do with Chart values:

keycloak:
  basepath: auth
  username: admin
  password: password
  route:
    tls:
      enabled: false
  extraEnv: |
    - name: PROXY_ADDRESS_FORWARDING
      value: "true"
    - name: KEYCLOAK_IMPORT
      value: /keycloak/master-realm.json
    - name: JAVA_OPTS
      value: >-
        -Djboss.socket.binding.port-offset=1000
  extraVolumes: |
    - name: realm-secret
      secret:
        secretName: realm-secret
  extraVolumeMounts: |
    - name: realm-secret
      mountPath: "../keycloak/"
      readOnly: true
  ingress:
    enabled:    true
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/use-regex: "true"
    path: /auth/?(.*)
    hosts:
      - keycloak.localtest.me

I don't quite understand where to put this from docker-compose.yaml:

    command:
      [
        '-b',
        '0.0.0.0',
        '-Djboss.socket.binding.port-offset=1000',
        '-Dkeycloak.migration.action=import',
        '-Dkeycloak.migration.provider=dir',
        '-Dkeycloak.migration.dir=/realm-config',
        '-Dkeycloak.migration.strategy=IGNORE_EXISTING',
      ]

P.S I'm trying to run a k8s example for https://github.com/oauth2-proxy/oauth2-proxy/tree/master/contrib/local-environment There they have k8s demo with Dex, and I want to adapt it with Keycloak.

1 Answers

You can use kompose tool to directly convert docker compose to kubernetes files. If you want to make a helm chart just replace with templates and provide values in chart values. Also Kubernetes deployment has command field in yaml.

as you can see in github.com/codecentric/helm-charts/blob/master/charts/keycloak/… command is set by .Values.command

So in file github.com/codecentric/helm-charts/blob/master/charts/keycloak/… replace command : [] with your docker-compose command.

Related