Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Shift around some values and actually enable user supplied bucket access secrets #279

Merged
merged 7 commits into from
Dec 11, 2024
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.20.3
version: 0.21.0
appVersion: 1.0.0
icon: https://wandb.ai/logo.svg

Expand Down
14 changes: 13 additions & 1 deletion charts/operator-wandb/charts/app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ spec:
resource: limits.memory
- name: GLUE_ENABLED
value: "{{ not .Values.global.beta.glue.enabled }}"
- name: BUCKET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).accessKeyName }}"
- name: BUCKET_SECRET_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).secretKeyName }}"
- name: BUCKET
value: "{{ (include "wandb.bucket" . | fromYaml).url }}"
- name: HOST
value: "{{ .Values.global.host }}"
{{- if .Values.extraCors }}
Expand Down Expand Up @@ -140,7 +152,7 @@ spec:
secretKeyRef:
name: {{ include "wandb.redis.passwordSecret" . }}
optional: true
key: {{ .Values.global.redis.secretKey }}
key: {{ .Values.global.redis.secret.secretKey }}
- name: REDIS_PORT
value: "{{ include "wandb.redis.port" . }}"
- name: REDIS_HOST
Expand Down
12 changes: 12 additions & 0 deletions charts/operator-wandb/charts/executor/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ spec:
valueFrom:
resourceFieldRef:
resource: limits.memory
- name: BUCKET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).accessKeyName }}"
- name: BUCKET_SECRET_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).secretKeyName }}"
- name: BUCKET
value: "{{ (include "wandb.bucket" . | fromYaml).url }}"
{{- if ne .Values.traceRatio 0.0 }}
- name: GORILLA_TRACER
value: "otlp+grpc://{{ .Release.Name }}-otel-daemonset:4317?trace_ratio={{ .Values.traceRatio }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ spec:
value: 'true'
- name: LOGGING_ENABLED
value: 'true'
- name: BUCKET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).accessKeyName }}"
- name: BUCKET_SECRET_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).secretKeyName }}"
- name: BUCKET
value: "{{ (include "wandb.bucket" . | fromYaml).url }}"
- name: AZURE_STORAGE_KEY
valueFrom:
secretKeyRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ spec:
value: 'true'
- name: LOGGING_ENABLED
value: 'true'
- name: BUCKET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).accessKeyName }}"
- name: BUCKET_SECRET_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).secretKeyName }}"
- name: BUCKET
value: "{{ (include "wandb.bucket" . | fromYaml).url }}"
- name: AZURE_STORAGE_KEY
valueFrom:
secretKeyRef:
Expand Down
12 changes: 12 additions & 0 deletions charts/operator-wandb/charts/parquet/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ spec:
valueFrom:
resourceFieldRef:
resource: limits.memory
- name: BUCKET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).accessKeyName }}"
- name: BUCKET_SECRET_KEY
valueFrom:
secretKeyRef:
name: "{{ (include "wandb.bucket" . | fromYaml).secretName }}"
key: "{{ (include "wandb.bucket" . | fromYaml).secretKeyName }}"
- name: BUCKET
value: "{{ (include "wandb.bucket" . | fromYaml).url }}"
{{- if ne .Values.traceRatio 0.0 }}
- name: GORILLA_TRACER
value: "otlp+grpc://{{ .Release.Name }}-otel-daemonset:4317?trace_ratio={{ .Values.traceRatio }}"
Expand Down
25 changes: 11 additions & 14 deletions charts/operator-wandb/templates/_bucket.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
Assorted bucket related helpers.
*/}}
{{- define "wandb.bucket.secret" -}}
{{- if .Values.global.bucket.secretName -}}
{{ .Values.global.bucket.secretName }}
{{- else if .Values.global.defaultBucket.secretName -}}
{{ .Values.global.defaultBucket.secretName }}
{{- if .Values.global.bucket.secret.secretName -}}
{{ .Values.global.bucket.secret.secretName }}
{{- else }}
{{- print .Release.Name "-bucket" -}}
{{- end -}}
Expand All @@ -15,35 +13,34 @@
{{ .Release.Name }}-bucket-configmap
{{- end -}}


{{- define "wandb.bucket" -}}
{{- $url := "" -}}
{{- $url := "" -}}
{{- $provider := .Values.global.bucket.provider -}}
provider: {{ $provider }}
{{- $name := .Values.global.bucket.name | default .Values.global.defaultBucket.name }}
name: {{ $name }}
{{- $path := .Values.global.bucket.path | default (default "" .Values.global.defaultBucket.path) }}
{{- $path := .Values.global.bucket.path | default .Values.global.defaultBucket.path }}
path: {{ $path }}
region: {{ .Values.global.bucket.region | default .Values.global.defaultBucket.region }}
kmsKey: {{ .Values.global.bucket.kmsKey | default .Values.global.defaultBucket.kmsKey }}
{{- $accessKey:= .Values.global.bucket.accessKey | default .Values.global.defaultBucket.accessKey }}
accessKey: {{ $accessKey }}
{{- $secretKey:= .Values.global.bucket.secretKey | default .Values.global.defaultBucket.secretKey }}
secretKey: {{ $secretKey }}
accessKeyName: {{ .Values.global.bucket.accessKeyName | default (default "ACCESS_KEY" .Values.global.defaultBucket.accessKeyName) }}
secretKeyName: {{ .Values.global.bucket.secretKeyName | default (default "SECRET_KEY" .Values.global.defaultBucket.secretKeyName) }}
accessKeyName: {{ .Values.global.bucket.secret.accessKeyName }}
secretKeyName: {{ .Values.global.bucket.secret.secretKeyName }}
secretName: {{ include "wandb.bucket.secret" . }}
{{- if eq $provider "az" -}}
{{- $url = printf "az://%s/%s" $name $path -}}
{{- $url = "az://$(BUCKET_NAME)/$(BUCKET_PATH)" -}}
{{- end -}}
{{- if eq $provider "gcs" -}}
{{- $url = printf "gs://%s/%s" $name $path -}}
{{- $url = "gs://$(BUCKET_NAME)/$(BUCKET_PATH)" -}}
{{- end -}}
{{- if eq $provider "s3" -}}
{{- if and $accessKey $secretKey -}}
{{- $url = printf "s3://%s:%s@%s/%s" $accessKey $secretKey $name $path -}}
{{- if or (and $accessKey $secretKey) .Values.global.bucket.secret.secretName -}}
{{- $url = "s3://$(BUCKET_ACCESS_KEY):$(BUCKET_SECRET_KEY)@$(BUCKET_NAME)/$(BUCKET_PATH)" -}}
{{- else -}}
{{- $url = printf "s3://%s/%s" $name $path -}}
{{- $url = "s3://$(BUCKET_NAME)/$(BUCKET_PATH)" -}}
{{- end -}}
{{- end -}}
{{- $url = trimSuffix "/" $url }}
Expand Down
6 changes: 3 additions & 3 deletions charts/operator-wandb/templates/_redis.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Return name of secret where redis information is stored
*/}}
{{- define "wandb.redis.passwordSecret" -}}
{{- if .Values.global.redis.secretName -}}
{{ .Values.global.redis.secretName }}
{{- if .Values.global.redis.secret.secretName -}}
{{ .Values.global.redis.secret.secretName }}
{{- else -}}
{{- print .Release.Name "-redis" -}}
{{- end -}}
Expand Down Expand Up @@ -46,7 +46,7 @@ Return the redis to url

{{- define "wandb.redis.connectionString" -}}
{{- $password := include "wandb.redis.password" . }}
{{- if or $password .Values.global.redis.secretName }}
{{- if or $password .Values.global.redis.secret.secretName }}
redis://:$(REDIS_PASSWORD)@$(REDIS_HOST):$(REDIS_PORT)
{{- else }}
redis://$(REDIS_HOST):$(REDIS_PORT)
Expand Down
5 changes: 3 additions & 2 deletions charts/operator-wandb/templates/bucket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ metadata:
{{- include "wandb.commonLabels" . | nindent 4 }}
data:
{{- with include "wandb.bucket" . | fromYaml }}
BUCKET: {{ .url | quote }}
BUCKET_NAME: {{ .name | quote }}
BUCKET_PATH: {{ .path | quote }}
AWS_REGION: {{ .region | quote }}
AWS_S3_KMS_ID: {{ .kmsKey | quote }}
{{- end }}
{{- if not .Values.global.bucket.secretName }}
{{- if not .Values.global.bucket.secret.secretName }}
---
apiVersion: v1
kind: Secret
Expand Down
16 changes: 7 additions & 9 deletions charts/operator-wandb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,23 @@ global:
path: ""
region: ""
kmsKey: ""
secretKey: ""
accessKey: ""
secretName: ""

# If specified the application will use this bucket for all storage operations, and will not be overridable by the user.
bucket:
secretName: ""
accessKeyName: "ACCESS_KEY"
secretAccessKeyName: "SECRET_KEY"
secret:
secretName: ""
accessKeyName: "ACCESS_KEY"
secretKeyName: "SECRET_KEY"

redis:
host: ""
port: 6379
password: ""
parameters: {}
caCert: ""
# The name of the user supplied secret containing the password for the redis instance.
secretName: ""
secretKey: "REDIS_PASSWORD"
secret:
secretName: ""
secretKey: "REDIS_PASSWORD"

bigtable:
v3:
Expand Down
Loading