fix keycloak secrets drift (#508)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
- Enhanced management of Keycloak credentials by checking for existing
passwords stored in Kubernetes Secrets.
- Improved password management logic, allowing for the reuse of existing
passwords or the generation of new ones as needed.

- **Bug Fixes**
- Streamlined secret handling to avoid unnecessary random password
generation, improving security and maintainability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Floppy Disk <kklinch0@gmail.com>
This commit is contained in:
Andrei Kvapil
2024-12-04 19:40:37 +01:00
committed by GitHub
parent 3aa5f88a5f
commit d43b8fdab0

View File

@@ -1,6 +1,11 @@
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
{{- $host := index $cozyConfig.data "root-host" }}
{{- $existingPassword := lookup "v1" "Secret" "cozy-keycloak" "{{ .Release.Name }}-credentials" }}
{{- $password := randAlphaNum 16 -}}
{{- if $existingPassword }}
{{- $password = index $existingPassword.data "password" | b64dec }}
{{- end }}
apiVersion: v1
kind: Secret