From 56e8408b2efabf2341365949101acc1de2bd370a Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sun, 25 Sep 2022 22:29:32 +0200
Subject: [PATCH] fix(keycloak): Fix infinispan magic

This patch adds the infinispan cache configuration for keycloak to allow
proper HA deployment with all caching goodies.

Turns out it's important to add the ping port (7800) to the headless
service in order to run the inifispan setup for kubernetes.

This was pieced together by some nice community posts, see:
https://gist.github.com/pedroigor/e1476a41b544d15c1bd59155aad4f6ad
https://github.com/keycloak/keycloak/issues/9644#issuecomment-1016850466
https://github.com/keycloak/keycloak/discussions/10125

Further the strategy Recreate was removed since it's not needed and the
inifispan will allow to always keep one keycloak instance around.
---
 charts/keycloak/Chart.yaml                | 2 +-
 charts/keycloak/README.md                 | 2 +-
 charts/keycloak/templates/deployment.yaml | 4 ++--
 charts/keycloak/templates/service.yaml    | 6 +++---
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/charts/keycloak/Chart.yaml b/charts/keycloak/Chart.yaml
index 4a5ce31e5..196681a5c 100644
--- a/charts/keycloak/Chart.yaml
+++ b/charts/keycloak/Chart.yaml
@@ -7,5 +7,5 @@ icon: https://www.keycloak.org/resources/images/keycloak_icon_512px.svg
 sources:
   - https://git.shivering-isles.com/shivering-isles/infrastructure-gitops
   - https://github.com/keycloak/keycloak
-version: 0.2.1
+version: 0.2.2
 appVersion: "19.0.2"
diff --git a/charts/keycloak/README.md b/charts/keycloak/README.md
index 6027ffe37..e5887acf0 100644
--- a/charts/keycloak/README.md
+++ b/charts/keycloak/README.md
@@ -1,6 +1,6 @@
 # keycloak
 
-![Version: 0.2.1](https://img.shields.io/badge/Version-0.2.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 19.0.2](https://img.shields.io/badge/AppVersion-19.0.2-informational?style=flat-square)
+![Version: 0.2.2](https://img.shields.io/badge/Version-0.2.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 19.0.2](https://img.shields.io/badge/AppVersion-19.0.2-informational?style=flat-square)
 
 (Alpha) A Helm chart for Keycloak on Kubernetes
 
diff --git a/charts/keycloak/templates/deployment.yaml b/charts/keycloak/templates/deployment.yaml
index ffd455621..f6f4702f8 100644
--- a/charts/keycloak/templates/deployment.yaml
+++ b/charts/keycloak/templates/deployment.yaml
@@ -5,8 +5,6 @@ metadata:
   labels:
     {{- include "keycloak.labels" . | nindent 4 }}
 spec:
-  strategy:
-    type: Recreate
   {{- if not .Values.autoscaling.enabled }}
   replicas: {{ .Values.replicaCount }}
   {{- end }}
@@ -38,6 +36,8 @@ spec:
           imagePullPolicy: {{ .Values.image.pullPolicy }}
           args:
             - start
+            - --cache=ispn
+            - --cache-config-file=cache-ispn.xml
             - --cache-stack=kubernetes
             - --proxy
             - '{{ .Values.keycloak.proxy }}'
diff --git a/charts/keycloak/templates/service.yaml b/charts/keycloak/templates/service.yaml
index 4b669b4fe..2091811a2 100644
--- a/charts/keycloak/templates/service.yaml
+++ b/charts/keycloak/templates/service.yaml
@@ -23,9 +23,9 @@ metadata:
 spec:
   clusterIP: None
   ports:
-    - port: {{ .Values.service.port }}
-      targetPort: http
+    - port: 7800
+      targetPort: 7800
       protocol: TCP
-      name: http
+      name: ping
   selector:
     {{- include "keycloak.selectorLabels" . | nindent 4 }}
-- 
GitLab