Skip to content

Commit

Permalink
Module helm added for Kubernetes deployments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Steiner committed Apr 17, 2024
1 parent b1909a7 commit 7882946
Show file tree
Hide file tree
Showing 8 changed files with 284 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ release.properties

# Postgres data
/docker-compose/postgres/volume/

Chart.lock
helm/src/generated/**/*.tgz
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project is based on the [custom Keycloak template](https://github.com/inven
- `container`: creates the custom docker image
- `docker-compose`: provides a sample for launching the custom docker image
- `extensions`: provides samples for Keycloak SPI implementations
- `helm`: provides a sample for installing the custom container image in Kubernetes using the Codecentric Helm Chart
- `server`: provides a Keycloak installation for local development & testing
- `themes`: provides samples for custom themes

Expand Down
75 changes: 75 additions & 0 deletions helm/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>parent</artifactId>
<groupId>com.inventage.keycloak.custom</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>helm</artifactId>
<packaging>helm</packaging>

<properties>
<chart.directory>${project.basedir}/src/generated/keycloak-custom-chart</chart.directory>

<!-- Image names in chart should always use the inventage registry! -->
<docker.registry.name>docker-registry.inventage.com:10121</docker.registry.name>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>with-substitution</id>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<outputDirectory>${chart.directory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- See https://github.com/kokuwaio/helm-maven-plugin for documentation -->
<groupId>io.kokuwa.maven</groupId>
<artifactId>helm-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>${project.build.directory}/**/charts/**/charts/portal-lib</exclude>
</excludes>
<chartDirectory>${chart.directory}</chartDirectory>
</configuration>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<skipInstall>false</skipInstall>
<skipUpgrade>false</skipUpgrade>
<releaseName>keycloak-custom</releaseName>
<values>
<yamlFiles>
<yamlFiles>${chart.directory}/values.yaml</yamlFiles>
</yamlFiles>
</values>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
8 changes: 8 additions & 0 deletions helm/src/generated/keycloak-custom-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: keycloak-custom-chart
version: 1.0.0-SNAPSHOT
apiVersion: v2

dependencies:
- name: keycloakx
version: 2.3.0
repository: "https://codecentric.github.io/helm-charts"
71 changes: 71 additions & 0 deletions helm/src/generated/keycloak-custom-chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
keycloakx:
# This is an example configuration, for production grade configuration see the Keycloak documentation.
# See https://www.keycloak.org/server/configuration
# See https://www.keycloak.org/server/all-config
command:
- "/opt/keycloak/bin/kc-with-setup.sh"
- "--verbose"
- "start"
- "--http-enabled=true"
- "--http-port=8080"
- "--hostname-strict=false"
- "--hostname-strict-https=false"
- "--spi-events-listener-jboss-logging-success-level=info"
- "--spi-events-listener-jboss-logging-error-level=warn"

image:
# The custom image repository
repository: docker-registry.inventage.com:10094/com.inventage.keycloak.custom.container
# Overrides the Keycloak image tag whose default is the chart appVersion
tag: 1.0.0-SNAPSHOT

http:
relativePath: "/"

extraEnv: |
- name: KEYCLOAK_ADMIN
valueFrom:
secretKeyRef:
name: {{ include "keycloak.fullname" . }}-admin-creds
key: user
- name: KEYCLOAK_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "keycloak.fullname" . }}-admin-creds
key: password
- name: JAVA_OPTS_APPEND
value: >-
-Djava.awt.headless=true
-Djgroups.dns.query={{ include "keycloak.fullname" . }}-headless
dbchecker:
enabled: true

database:
vendor: postgres
hostname: postgres-postgresql
port: 5432
username: keycloak
password: keycloak
database: keycloak

secrets:
admin-creds:
annotations:
my-test-annotation: Test secret for {{ include "keycloak.fullname" . }}
stringData:
user: admin
password: secret

securityContext:
# See https://github.com/keycloak/keycloak/issues/11286
# readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL

serviceAccount:
automountServiceAccountToken: "false"
imagePullSecrets:
- name: keycloak-custom
8 changes: 8 additions & 0 deletions helm/src/main/resources/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: keycloak-custom-chart
version: ${project.version}
apiVersion: v2

dependencies:
- name: keycloakx
version: 2.3.0
repository: "https://codecentric.github.io/helm-charts"
71 changes: 71 additions & 0 deletions helm/src/main/resources/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
keycloakx:
# This is an example configuration, for production grade configuration see the Keycloak documentation.
# See https://www.keycloak.org/server/configuration
# See https://www.keycloak.org/server/all-config
command:
- "/opt/keycloak/bin/kc-with-setup.sh"
- "--verbose"
- "start"
- "--http-enabled=true"
- "--http-port=8080"
- "--hostname-strict=false"
- "--hostname-strict-https=false"
- "--spi-events-listener-jboss-logging-success-level=info"
- "--spi-events-listener-jboss-logging-error-level=warn"

image:
# The custom image repository
repository: ${docker.registry}${docker.image.name}
# Overrides the Keycloak image tag whose default is the chart appVersion
tag: ${project.version}

http:
relativePath: "/"

extraEnv: |
- name: KEYCLOAK_ADMIN
valueFrom:
secretKeyRef:
name: {{ include "keycloak.fullname" . }}-admin-creds
key: user
- name: KEYCLOAK_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "keycloak.fullname" . }}-admin-creds
key: password
- name: JAVA_OPTS_APPEND
value: >-
-Djava.awt.headless=true
-Djgroups.dns.query={{ include "keycloak.fullname" . }}-headless
dbchecker:
enabled: true

database:
vendor: postgres
hostname: postgres-postgresql
port: 5432
username: keycloak
password: keycloak
database: keycloak

secrets:
admin-creds:
annotations:
my-test-annotation: Test secret for {{ include "keycloak.fullname" . }}
stringData:
user: admin
password: secret

securityContext:
# See https://github.com/keycloak/keycloak/issues/11286
# readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL

serviceAccount:
automountServiceAccountToken: "false"
imagePullSecrets:
- name: keycloak-custom
55 changes: 47 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<module>themes</module>
<module>container</module>
<module>docker-compose</module>
<module>helm</module>
</modules>

<properties>
Expand All @@ -26,7 +27,7 @@
<keycloak.providers.dir>../../server/${keycloak.dir}/providers</keycloak.providers.dir> <!-- used in extension modules -->
<keycloak.themes.dir>../server/${keycloak.dir}/themes</keycloak.themes.dir> <!-- used in themes module -->
<docker.registry>docker-registry.inventage.com:10094/</docker.registry>
<docker.image.name>${project.groupId}.${project.artifactId}</docker.image.name>
<docker.image.name>com.inventage.keycloak.custom.container</docker.image.name>
<docker.contextDir>${project.build.outputDirectory}</docker.contextDir>
<docker.verbose>true</docker.verbose>
<docker.imagePropertyConfiguration>override</docker.imagePropertyConfiguration>
Expand Down Expand Up @@ -82,13 +83,6 @@
<version>${testcontainers-keycloak.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter-engine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down Expand Up @@ -234,6 +228,51 @@
</execution>
</executions>
</plugin>
<plugin>
<!-- See https://github.com/kokuwaio/helm-maven-plugin for documentation -->
<groupId>io.kokuwa.maven</groupId>
<artifactId>helm-maven-plugin</artifactId>
<version>6.13.0</version>
<extensions>true</extensions>
<configuration>
<chartVersion>${project.version}</chartVersion>
<chartDirectory>${project.basedir}/helm/target/chart</chartDirectory>
<useLocalHelmBinary>false</useLocalHelmBinary>
<debug>true</debug>
<skipUpload>false</skipUpload>
<skipPushLogin>true</skipPushLogin>
<uploadRepoSnapshot>
<name>ghcr</name>
<url>ghcr.io/keycloak-competence-center</url>
<type>NEXUS</type>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</uploadRepoSnapshot>
<uploadRepoStable>
<name>ghcr</name>
<url>ghcr.io/keycloak-competence-center</url>
<type>NEXUS</type>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</uploadRepoStable>
</configuration>
<executions>
<execution>
<id>default-upload</id>
<phase>none</phase>
</execution>
<execution>
<id>upload</id>
<goals>
<goal>init</goal>
<goal>lint</goal>
<goal>package</goal>
<goal>push</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down

0 comments on commit 7882946

Please sign in to comment.