projectsyn / component-keycloak

Commodore Component for Keycloak
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Support custom theme #40

Closed chloesoe closed 3 years ago

chloesoe commented 3 years ago

Context

In order to provide a custom theme according to the codecentric documentation we have to add extraInitContainers, extraVolumeMounts, and extraVolumes. In the component-keycloak that should be supported easily. At the moment we to copy the whole extraVolumes String (see component-keycloak/defaults.yml) to our cluster definition file to add an additional volume.

For https://github.com/vshn/keycloak-theme/ we have to add the values below, but we also have to copy everything from defaults.yml, which leads to duplication.

      extraVolumes: |
        - name: db-certs
          secret:
            secretName: keycloak-postgresql-tls
            defaultMode: 0400
            items:
              - key: tls.crt
                path: tls.crt
        - name: keycloak-tls
          secret:
            secretName: keycloak-tls
            defaultMode: 420
        - name: theme
          emptyDir: {}
      extraVolumeMounts: |
        - name: db-certs
          readOnly: true
          mountPath: /opt/jboss/certs
        - name: keycloak-tls
          readOnly: true
          mountPath: /etc/x509/https
        - name: theme
          readOnly: true
          mountPath: /opt/jboss/keycloak/themes/vshn
      extraInitContainers: |
        - name: theme-provider
          image: quay.io/vshn/keycloak-theme:v1.0.0
          imagePullPolicy: IfNotPresent
          command:
            - sh
          args:
            - -c
            - |
              echo "Copying theme..."
              cp -R /theme/* /vshn-theme
          volumeMounts:
            - name: theme
              mountPath: /vshn-theme

Acceptance criteria

Alternatives

Copy paste all extraVolume definitions from component-keycloak works but.

simu commented 3 years ago

Maybe we can build something similar to what we already do for the EXTRA_OPTS environment variable. for allowing to add additional entries to extraVolumes, extraVolumeMounts and extraInitContainers.

https://github.com/projectsyn/component-keycloak/blob/532880ab59f6966d0ebe1253d9ee13eb5a83f6d5/class/defaults.yml#L136-L143

https://github.com/projectsyn/component-keycloak/blob/532880ab59f6966d0ebe1253d9ee13eb5a83f6d5/class/defaults.yml#L83-L85 The additional parameters may have to be strings themselves for the interpolation to work, but it's worth a try to make them arrays and see if reclass interpolates them correctly in a string context.

ccremer commented 3 years ago

For extending Keycloak with custom JARs this is also useful (regarding init containers)