Skip to content

Commit

Permalink
Support to pull Redis configurations from secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
velotioaastha committed Sep 23, 2024
1 parent 49e5bf0 commit 9d45ef6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/operator-wandb/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion charts/operator-wandb/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
48 changes: 40 additions & 8 deletions charts/operator-wandb/templates/_redis.tpl
Original file line number Diff line number Diff line change
@@ -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 -}}

{{/*
Expand All @@ -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 -}}
2 changes: 2 additions & 0 deletions charts/operator-wandb/templates/redis.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if not .Values.redis.install }}
{{- if not .Values.global.redis.secretName }}
{{- $secretName := (include "wandb.redis.passwordSecret" .) }}
apiVersion: v1
kind: Secret
Expand All @@ -10,3 +11,4 @@ data:
REDIS_PASSWORD: {{ include "wandb.redis.password" . | b64enc }}
REDIS_CA_CERT: {{ include "wandb.redis.caCert" . | b64enc }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/operator-wandb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ global:
password: ""
parameters: {}
caCert: ""
secretName: ""

kafka:
# The following values are anchored here, and referenced by alias later for
Expand Down

0 comments on commit 9d45ef6

Please sign in to comment.