charts icon indicating copy to clipboard operation
charts copied to clipboard

[bitnami/keycloak] How do I add my custom provider?

Open chominnn opened this issue 2 years ago • 5 comments

Name and Version

bitnami/keycloak

#values.yaml

extraVolumes:
    - name: keycloak-spi-pv
      persistentVolumeClaim:
        claimName: keycloak-spi-pvc
extraVolumeMounts:
    - name: keycloak-spi-pv
      mountPath: /mydir

This is my first time using Keycloak. And I am not good at English. I ask for your understanding

When the pod starts, I can see the directory in /mydir

To custom user providers apply, The file must be placed in /opt/bitnami/keycloak

If i edit the additional volume mount path to [/opt/bitnami/keycloak]

The keycloak install scripts(?) are not working It seems to have been overwritten by the persistent volume

I used the container below

    - Name: init-spi
      Image: busybox
      imagePullPolicy: Always
      Command: ["/bin/sh"]
      args: [-c], cp -R /mydir/* /opt/bitnami / keycloak /"]
      Mount Volume:
      - name : keycloak-spi- pv
        mountPath: /mydir
      Security Context:
        Run as user: 1001
        RunAsGroup: 1001

But again, it didn't work

Unable to create cp: '/opt/bitnami/keycloak' directory, no such file or directory

The directory cannot be created because the main container (keycloak installation scripts) has not started

How do I apply for a custom user provider??

Or is there a way to restart Keycloak without deleting the pod? If possible, I would like to copy the file directly to the directory after the Keycloak pod is executed.

Or if there is a good way, please advise.

Thank you.

chominnn avatar Aug 09 '24 01:08 chominnn

and also can see when tried kc.sh start-dev I need to find out how to reload keycloak instead delete the pod

keycloak@keycloak-0:/opt/bitnami/keycloak$ kc.sh start-dev
Appending additional Java properties to JAVA_OPTS: -Djgroups.dns.query=keycloak-headless.keycloak.svc.cluster.local
Updating the configuration and installing your custom providers, if any. Please wait.
2024-08-09 01:25:40,317 WARN  [org.keycloak.services] (build-16) KC-SERVICES0047: metrics (org.jboss.aerogear.keycloak.metrics.MetricsEndpointFactory) is implementing the internal SPI realm-restapi-extension. This SPI is internal and may change without notice
2024-08-09 01:25:41,064 WARN  [org.keycloak.services] (build-16) KC-SERVICES0047: metrics-listener (org.jboss.aerogear.keycloak.metrics.MetricsEventListenerFactory) is implementing the internal SPI eventsListener. This SPI is in

2024-08-09 01:26:04,994 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (development) mode
2024-08-09 01:26:04,994 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start caches
2024-08-09 01:26:04,995 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: org.infinispan.manager.EmbeddedCacheManagerStartupException: Unable to start JGroups Channel
2024-08-09 01:26:04,995 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Unable to start JGroups Channel
2024-08-09 01:26:04,996 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Unable to start JGroups Channel
2024-08-09 01:26:04,997 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: No available port to bind to in range [7800 .. 7800]
2024-08-09 01:26:04,998 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.

chominnn avatar Aug 09 '24 01:08 chominnn

Hi,

Looking at the init script, you are copying data to /opt/bitnami/keycloak, but this would disappear if not stored in a volume. At the same time, mounting a volume in /opt/bitnami/keycloak would make its original contents disappear. So you would need to add an extra volume and do something like this:


cp -rf /opt/bitnami/keycloak/* /my-new-vol
cp -rf /mydir /my-new-vol

And then mount the new volume in the main container at /opt/bitnami/keycloak.

javsalgar avatar Aug 12 '24 08:08 javsalgar

안녕,

init 스크립트를 보면, /opt/bitnami/keycloak에 데이터를 복사하고 있지만, 볼륨에 저장하지 않으면 사라집니다. 동시에, /opt/bitnami/keycloak에 볼륨을 마운트하면 원래 내용이 사라집니다. 따라서 여분의 볼륨을 추가하고 다음과 같이 해야 합니다.

cp -rf /opt/bitnami/keycloak/* /my-new-vol
cp -rf /mydir /my-new-vol

그런 다음 /opt/bitnami/keycloak의 기본 컨테이너에 새 볼륨을 마운트합니다.

thx to reply but it didn't work T-T

I've been thinking about it for a few days I think I need the kc.sh restart(or stop) command.

There is no way to transfer custom files before the main container runs Even if you build kc.sh after adding files to the directory after the main container runs, providers do not seem to apply.

  • Theme seems to have been applied.

Even if the same version was performed in a docker environment, it is not applicable to build alone When I started [kc.sh start] finishing the process, I was able to confirm that the provider came up normally.

chominnn avatar Aug 12 '24 08:08 chominnn

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] avatar Aug 28 '24 01:08 github-actions[bot]

This commit https://github.com/bitnami/charts/commit/9de041c92e2788a108631052aa5401a9469e3592 has made it possible to add your providers with at initContainer.

initContainers: |
    - name: keycloak-plugin
      image: my-plugin
      imagePullPolicy: IfNotPresent
      command:
        - sh
      args:
        - -c
        - |
          echo "Copying module..."
          cp -r /module/* /emptydir/app-providers-dir
      volumeMounts:
        - name: empty-dir
          mountPath: /emptydir

bryne91 avatar Nov 15 '24 10:11 bryne91