Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGoyette committed Oct 31, 2024
1 parent a5ce79e commit 3ceed94
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
2 changes: 1 addition & 1 deletion charts/operator-wandb/charts/app/templates/_deployment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ spec:
- name: GORILLA_INTERNAL_JWT_ISSUERS
value: '["https://kubernetes.default.svc.cluster.local"]'
- name: GORILLA_INTERNAL_JWT_SUBJECTS
value: '["system:serviceaccount:default:{{ include "weaveServiceAccountName" . }}"]'
value: '["system:serviceaccount:default:{{ include "weaveTrace.serviceAccountName" . }}"]'
{{- end }}
{{- include "app.extraEnv" (dict "global" $.Values.global "local" .Values) | nindent 12 }}
{{- include "wandb.extraEnvFrom" (dict "root" $ "local" .) | nindent 12 }}
Expand Down
13 changes: 7 additions & 6 deletions charts/operator-wandb/charts/app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ app deployments.
{{- trimSuffix "/" $bucket -}}
{{- end -}}

{{- define "weaveServiceAccountName" -}}
{{- if index .Values.global "weave-trace" "enabled" }}
{{- if (not (empty (index .Values.global "weave-trace" "serviceAccountName"))) }}
{{- index .Values.global "weave-trace" "serviceAccountName" }}
{{/*
Create the name of the weave-traceservice account to use
*/}}
{{- define "weaveTrace.serviceAccountName" -}}
{{- if .Values.global."weave-trace".serviceAccount.create }}
{{- default (include "weaveTrace.fullname" .) .Values.global."weave-trace".serviceAccount.name }}
{{- else }}
{{- fail "Values.global.weave-trace.serviceAccountName cannot be empty if serviceAccount.create is true" }}
{{- end}}
{{- default "default" .Values.global."weave-trace".serviceAccount.name }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions charts/operator-wandb/charts/weave-trace/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ app.kubernetes.io/name: {{ include "weaveTrace.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "weaveTrace.serviceAccountName" -}}
{{- if .Values.global."weave-trace".serviceAccount.create }}
{{- default (include "weaveTrace.fullname" .) .Values.global."weave-trace".serviceAccount.name }}
{{- else }}
{{- default "default" .Values.global."weave-trace".serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Returns the extraEnv keys and values to inject into containers.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{{- if index .Values.global "weave-trace" "enabled" }}
{{- if (empty (index .Values.global "weave-trace" "serviceAccountName")) -}}
{{- fail "Values.global.weave-trace.serviceAccountName cannot be empty if serviceAccount.create is true" -}}
{{- end -}}
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "weaveServiceAccountName" . }}
name: {{ include "weaveTrace.serviceAccountName" . }}
labels:
{{- include "wandb.commonLabels" . | nindent 4 }}
{{- include "weaveTrace.commonLabels" . | nindent 4 }}
{{- include "weaveTrace.labels" . | nindent 4 }}
{{- if .Values.serviceAccount.labels -}}
{{- toYaml .Values.serviceAccount.labels | nindent 4 }}
{{- if .Values.global."weave-trace".serviceAccount.labels -}}
{{- toYaml .Values.global."weave-trace".serviceAccount.labels | nindent 4 }}
{{- end }}
annotations:
{{- if .Values.serviceAccount.annotations -}}
{{- toYaml .Values.serviceAccount.annotations | nindent 4 }}
{{- if .Values.global."weave-trace".serviceAccount.annotations -}}
{{- toYaml .Values.global."weave-trace".serviceAccount.annotations | nindent 4 }}
{{- end }}
{{- end }}
3 changes: 0 additions & 3 deletions charts/operator-wandb/charts/weave-trace/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ extraCors: []
common:
labels: {}
deployment: {}
serviceAccount:
create: true
annotations: {}
clusterRole: {}

service:
Expand Down
12 changes: 12 additions & 0 deletions charts/operator-wandb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Weave Trace service account name
*/}}
{{- define "weaveTrace.serviceAccountName" -}}
{{- if index .Values "weave-trace" "enabled" }}
{{- if (not (empty (index .Values "weave-trace" "serviceAccount" "name"))) }}
{{- index .Values "weave-trace" "serviceAccount" "name" }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion charts/operator-wandb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ global:

weave-trace:
enabled: false
serviceAccountName: ""
serviceAccount:
create: true
annotations: {}


ingress:
Expand Down

0 comments on commit 3ceed94

Please sign in to comment.