From 9d45ef65d9dfbba76fb6d2cecfc79e1c016d4458 Mon Sep 17 00:00:00 2001 From: velotioaastha Date: Mon, 23 Sep 2024 17:42:59 +0530 Subject: [PATCH] Support to pull Redis configurations from secrets --- charts/operator-wandb/Chart.lock | 2 +- charts/operator-wandb/Chart.yaml | 2 +- charts/operator-wandb/templates/_redis.tpl | 48 ++++++++++++++++++---- charts/operator-wandb/templates/redis.yaml | 2 + charts/operator-wandb/values.yaml | 1 + 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/charts/operator-wandb/Chart.lock b/charts/operator-wandb/Chart.lock index 13ec8ee7..f441f9d5 100644 --- a/charts/operator-wandb/Chart.lock +++ b/charts/operator-wandb/Chart.lock @@ -42,4 +42,4 @@ dependencies: repository: file://charts/yace version: 0.1.0 digest: sha256:bca2b6781737da6806e4485605cf9ce87b1428944b14cb88f082024cc3500bbd -generated: "2024-07-18T01:17:04.532871-04:00" +generated: "2024-09-23T17:37:35.315807+05:30" diff --git a/charts/operator-wandb/Chart.yaml b/charts/operator-wandb/Chart.yaml index 6a4adefb..f5fe1602 100644 --- a/charts/operator-wandb/Chart.yaml +++ b/charts/operator-wandb/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: operator-wandb description: A Helm chart for deploying W&B to Kubernetes type: application -version: 0.17.9 +version: 0.18.2 appVersion: 1.0.0 icon: https://wandb.ai/logo.svg diff --git a/charts/operator-wandb/templates/_redis.tpl b/charts/operator-wandb/templates/_redis.tpl index 4c83de69..5c632fe5 100644 --- a/charts/operator-wandb/templates/_redis.tpl +++ b/charts/operator-wandb/templates/_redis.tpl @@ -1,33 +1,58 @@ {{/* -Return name of secret where redis information is stored +Return name of secret where redis information is stored or fallback if not present */}} {{- define "wandb.redis.passwordSecret" -}} -{{- print .Release.Name "-redis" -}} +{{- if .Values.global.redis.secretName -}} + {{ .Values.global.redis.secretName }} +{{- else -}} + {{- print .Release.Name "-redis" -}} {{- end -}} +{{- end }} {{/* Return the redis port */}} {{- define "wandb.redis.port" -}} -{{- print $.Values.global.redis.port -}} +{{- $redisPort := .Values.global.redis.port -}} +{{- if .Values.global.redis.secretName -}} + {{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.global.redis.secretName -}} + {{- if $secret -}} + {{- $redisPort = (index $secret.data "REDIS_PORT") | b64dec -}} + {{- end -}} +{{- end -}} +{{- $redisPort -}} {{- end -}} {{/* Return the redis host */}} {{- define "wandb.redis.host" -}} -{{- if eq .Values.global.redis.host "" -}} -{{ printf "%s-%s" .Release.Name "redis-master" }} +{{- $redisHost := .Values.global.redis.host -}} +{{- if .Values.global.redis.secretName -}} + {{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.global.redis.secretName -}} + {{- if $secret -}} + {{- $redisHost = (index $secret.data "REDIS_HOST") | b64dec -}} + {{- end -}} {{- else -}} -{{ .Values.global.redis.host }} + {{- if eq $redisHost "" -}} + {{- $redisHost = printf "%s-%s" .Release.Name "redis-master" -}} + {{- end -}} {{- end -}} +{{- $redisHost -}} {{- end -}} {{/* Return the redis password */}} {{- define "wandb.redis.password" -}} -{{- print $.Values.global.redis.password -}} +{{- $redisPassword := .Values.global.redis.password -}} +{{- if .Values.global.redis.secretName -}} + {{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.global.redis.secretName -}} + {{- if $secret -}} + {{- $redisPassword = (index $secret.data "REDIS_PASSWORD") | b64dec -}} + {{- end -}} +{{- end -}} +{{- $redisPassword -}} {{- end -}} {{/* @@ -53,5 +78,12 @@ redis://$(REDIS_HOST):$(REDIS_PORT) Return the redis caCert */}} {{- define "wandb.redis.caCert" -}} -{{- print $.Values.global.redis.caCert -}} +{{- $redisCaCert := .Values.global.redis.caCert -}} +{{- if .Values.global.redis.secretName -}} + {{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.global.redis.secretName -}} + {{- if $secret -}} + {{- $redisCaCert = (index $secret.data "REDIS_CA_CERT") | b64dec -}} + {{- end -}} +{{- end -}} +{{- $redisCaCert -}} {{- end -}} diff --git a/charts/operator-wandb/templates/redis.yaml b/charts/operator-wandb/templates/redis.yaml index ef1e6aea..a18f36f6 100644 --- a/charts/operator-wandb/templates/redis.yaml +++ b/charts/operator-wandb/templates/redis.yaml @@ -1,4 +1,5 @@ {{- if not .Values.redis.install }} +{{- if not .Values.global.redis.secretName }} {{- $secretName := (include "wandb.redis.passwordSecret" .) }} apiVersion: v1 kind: Secret @@ -10,3 +11,4 @@ data: REDIS_PASSWORD: {{ include "wandb.redis.password" . | b64enc }} REDIS_CA_CERT: {{ include "wandb.redis.caCert" . | b64enc }} {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/operator-wandb/values.yaml b/charts/operator-wandb/values.yaml index ad775dc5..06576608 100644 --- a/charts/operator-wandb/values.yaml +++ b/charts/operator-wandb/values.yaml @@ -106,6 +106,7 @@ global: password: "" parameters: {} caCert: "" + secretName: "" kafka: # The following values are anchored here, and referenced by alias later for