From f4146345d589c1ca44da53db250484f6d12d9a5e Mon Sep 17 00:00:00 2001 From: Matthieu Lamalle Date: Mon, 18 Dec 2023 10:38:13 +0100 Subject: [PATCH] Patche du DSN redis --- components/hydra-oidc/kustomization.yaml | 4 ++++ components/hydra-sql/kustomization.yaml | 4 ++++ components/redis/README.md | 23 +++++++++++++++++++ components/redis/kustomization.yaml | 5 ++++ components/redis/patches/hydra-apps.yaml | 3 +++ doc/README.md | 8 ------- resources/hydra-dispatcher/kustomization.yaml | 6 ++++- 7 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 components/redis/README.md create mode 100644 components/redis/patches/hydra-apps.yaml delete mode 100644 doc/README.md diff --git a/components/hydra-oidc/kustomization.yaml b/components/hydra-oidc/kustomization.yaml index 215184b..ac4ec8c 100644 --- a/components/hydra-oidc/kustomization.yaml +++ b/components/hydra-oidc/kustomization.yaml @@ -5,6 +5,10 @@ resources: - ./resources/hydra-oidc-deployment.yaml - ./resources/hydra-oidc-service.yaml +generatorOptions: + labels: + com.cadoles.forge.sso-kustom/session: redis + configMapGenerator: - name: hydra-oidc-env literals: diff --git a/components/hydra-sql/kustomization.yaml b/components/hydra-sql/kustomization.yaml index b138dd7..b0b66d5 100644 --- a/components/hydra-sql/kustomization.yaml +++ b/components/hydra-sql/kustomization.yaml @@ -5,6 +5,10 @@ resources: - ./resources/hydra-sql-service.yaml - ./resources/hydra-sql-deployment.yaml +generatorOptions: + labels: + com.cadoles.forge.sso-kustom/session: redis + configMapGenerator: - name: hydra-sql-env literals: diff --git a/components/redis/README.md b/components/redis/README.md new file mode 100644 index 0000000..e8840e8 --- /dev/null +++ b/components/redis/README.md @@ -0,0 +1,23 @@ +# Composant `redis` + +### Description + +Les applications `hydra-dispatcher`, `hydra-sql` et `hydra-oidc` stockent dorénavant le cache et les sessions utilisateur sur un serveur Redis. +Le DSN du serveur est défini dans leur variable d'environnement respective `REDIS_DSN`. +Les applications peuvent utiliser le mode `sentinel`` de redis +Il est donc nécessaire donc nécessaire de disposer d'un serveur Redis pour utiliser ces applications. + +### Principe général de fonctionnement + +Un `RedisFailOver` crée un cluster redis en mode sentinel avec 3 réplicats chacun. +Un patche viens mettre à jour la variable d'environnement `REDIS_DSN` dans les ConfigMap sur toutes les resources `hydra-*`. + + +### Personnalisation + +Via des `patches` sur la ressource `ConfigMap` via un label selecto `com.cadoles.forge.sso-kustom/session=redis` il est possible de modifier la valeur du `REDIS_DSN`. + + +|Clé|Description|Exemple| +|---|-----------|-------| +|`REDIS_DSN`| DSN du cluster Redis | `redis://rfs-sso-redis:26379?&redis_sentinel=mymaster` diff --git a/components/redis/kustomization.yaml b/components/redis/kustomization.yaml index c030cf5..609cf30 100644 --- a/components/redis/kustomization.yaml +++ b/components/redis/kustomization.yaml @@ -4,3 +4,8 @@ kind: Component resources: - ./resources/redis-failover.yaml +patches: +- path: ./patches/hydra-apps.yaml + target: + kind: ConfigMap + labelSelector: "com.cadoles.forge.sso-kustom/session=redis" diff --git a/components/redis/patches/hydra-apps.yaml b/components/redis/patches/hydra-apps.yaml new file mode 100644 index 0000000..6ab436a --- /dev/null +++ b/components/redis/patches/hydra-apps.yaml @@ -0,0 +1,3 @@ +- op: replace + path: "/data/REDIS_DSN" + value: "redis://rfs-sso-redis:26379?&redis_sentinel=mymaster" diff --git a/doc/README.md b/doc/README.md deleted file mode 100644 index 0dc6be7..0000000 --- a/doc/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Documentation - -### Redis - -Les applications `hydra-dispatcher`, `hydra-sql` et `hydra-oidc` stockent dorénavant le cache et les sessions utilisateur sur un serveur Redis. -Le DSN du serveur est défini dans leur variable d'environnement respective `REDIS_DSN`. -Les applications peuvent utiliser le mode `sentinel`` de redis -Il est donc nécessaire donc nécessaire de disposer d'un serveur Redis pour utiliser ces applications. diff --git a/resources/hydra-dispatcher/kustomization.yaml b/resources/hydra-dispatcher/kustomization.yaml index 8f2c569..b3441fe 100644 --- a/resources/hydra-dispatcher/kustomization.yaml +++ b/resources/hydra-dispatcher/kustomization.yaml @@ -5,6 +5,10 @@ resources: - ./resources/hydra-dispatcher-deployment.yaml - ./resources/hydra-dispatcher-service.yaml +generatorOptions: + labels: + com.cadoles.forge.sso-kustom/session: redis + configMapGenerator: - name: hydra-dispatcher-env literals: @@ -21,7 +25,7 @@ configMapGenerator: - COOKIE_PATH=/ - DEFAULT_LOCALE=fr - APP_LOCALES=fr,en - - REDIS_DSN="redis://rfs-sso-redis:26379?&redis_sentinel=mymaster" + - REDIS_DSN="redis://redis:6379" - name: hydra-dispatcher-apps files: - apps.yaml=./files/hydra/default.yaml