diff --git a/charts/operator-wandb/Chart.lock b/charts/operator-wandb/Chart.lock index b2941e87..eb0985d9 100644 --- a/charts/operator-wandb/Chart.lock +++ b/charts/operator-wandb/Chart.lock @@ -55,6 +55,6 @@ dependencies: version: 0.1.0 - name: wandb-base repository: file://../wandb-base - version: 0.1.1 -digest: sha256:3c02029e1921428d7f45866291a8c42b79894505ee47864c54f34fcd847b2793 -generated: "2024-12-19T11:00:55.672581+05:30" + version: 0.2.0 +digest: sha256:4a8dbdef20db07f9ed7e39f3353aa265a310b025637b15e19d3f149f601894e0 +generated: "2024-12-26T13:14:12.979282-08:00" diff --git a/charts/operator-wandb/values.yaml b/charts/operator-wandb/values.yaml index bffd0908..39d96f4d 100644 --- a/charts/operator-wandb/values.yaml +++ b/charts/operator-wandb/values.yaml @@ -496,7 +496,7 @@ glue: "{{ .Release.Name }}-glue-secret": "secretRef" "{{ .Release.Name }}-glue-configmap": "configMapRef" containers: - - name: glue + glue: args: ["glue"] env: {} envFrom: {} diff --git a/charts/wandb-base/Chart.yaml b/charts/wandb-base/Chart.yaml index 7d791b5b..6b94c6c4 100644 --- a/charts/wandb-base/Chart.yaml +++ b/charts/wandb-base/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: wandb-base description: A generic helm chart for deploying services to kubernetes type: application -version: 0.1.1 +version: 0.2.0 icon: https://wandb.ai/logo.svg maintainers: diff --git a/charts/wandb-base/templates/_containers.tpl b/charts/wandb-base/templates/_containers.tpl index 308e2f57..adab8a42 100644 --- a/charts/wandb-base/templates/_containers.tpl +++ b/charts/wandb-base/templates/_containers.tpl @@ -1,26 +1,18 @@ -{{- define "wandb-base.containers" }} -{{- range .Values.containers}} +{{/* + wandb-base.containers should be passed a dict with key `containers` containing the map of containers and a key `root` + containing the . from the calling context + */}} +{{- define "wandb-base.containers" -}} +{{- range $containerName, $containerSource := .containers -}} {{- $container := dict }} -{{- $_ := deepCopy . | merge $container }} -{{- $_ = set $container "securityContext" (coalesce $container.securityContext $.Values.securityContext) }} -{{- $_ = set $container "image" (coalesce $container.image $.Values.image) }} -{{- $_ = set $container "envFrom" (merge (default (dict) ($container.envFrom)) (default (dict) ($.Values.envFrom))) }} -{{- $_ = set $container "env" (merge (default (dict) ($container.env)) (default (dict) ($.Values.env))) }} -{{- $_ = set $container "root" $ }} -{{- include "wandb-base.container" $container }} -{{- end }} -{{- end }} - -{{- define "wandb-base.initContainers" }} -{{- range .Values.initContainers}} -{{- $container := dict }} -{{- $_ := deepCopy . | merge $container }} -{{- $_ = set $container "securityContext" (coalesce $container.securityContext $.Values.securityContext) }} -{{- $_ = set $container "image" (coalesce $container.image $.Values.image) }} -{{- $_ = set $container "envFrom" (merge (default (dict) ($container.envFrom)) (default (dict) ($.Values.envFrom))) }} -{{- $_ = set $container "env" (merge (default (dict) ($container.env)) (default (dict) ($.Values.env))) }} -{{- $_ = set $container "root" $ }} -{{- include "wandb-base.container" $container }} +{{- $_ := deepCopy $containerSource | merge $container }} +{{- $_ = set $container "name" $containerName }} +{{- $_ = set $container "securityContext" (coalesce $container.securityContext $.root.Values.securityContext) }} +{{- $_ = set $container "image" (coalesce $container.image $.root.Values.image) }} +{{- $_ = set $container "envFrom" (merge (default (dict) ($container.envFrom)) (default (dict) ($.root.Values.envFrom))) }} +{{- $_ = set $container "env" (merge (default (dict) ($container.env)) (default (dict) ($.root.Values.env))) }} +{{- $_ = set $container "root" $.root }} +{{- include "wandb-base.container" $container -}} {{- end }} {{- end }} @@ -78,19 +70,19 @@ {{- end }} {{- end }} -{{- define "wandb-base.env" }} -{{- range $key, $value := .env }} +{{- define "wandb-base.env" -}} +{{- range $key, $value := .env -}} {{- if kindIs "string" $value }} - name: {{ $key }} value: {{ $value | quote }} {{- else }} - name: {{ $key }} {{- toYaml $value | nindent 2 }} -{{- end }} -{{- end }} -{{- end }} +{{- end -}} +{{- end -}} +{{- end -}} -{{- define "wandb-base.envFrom" }} +{{- define "wandb-base.envFrom" -}} {{- range $key, $value := .envFrom }} - {{ $value }}: name: {{ $key }} diff --git a/charts/wandb-base/templates/cronjob b/charts/wandb-base/templates/cronjob new file mode 100644 index 00000000..00e2ce2e --- /dev/null +++ b/charts/wandb-base/templates/cronjob @@ -0,0 +1,56 @@ +{{- range $cronJobName, $cronJob := .Values.cronJobs }} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ printf "%s-%s" $.Release.Name $cronJobName }} + labels: + {{- include "wandb-base.labels" $ | nindent 4 }} +spec: + schedule: "{{ $cronJob.schedule }}" + jobTemplate: + spec: + template: + metadata: + {{- with $cronJob.podAnnotations }} + annotations: + {{- toYaml . | nindent 12 }} + {{- end }} + labels: + {{- include "wandb-base.labels" $ | nindent 12 }} + {{- with $cronJob.podLabels }} + {{- toYaml . | nindent 12 }} + {{- end }} + spec: + {{- with $.Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 12 }} + {{- end }} + serviceAccountName: {{ include "wandb-base.serviceAccountName" $ }} + securityContext: + {{- toYaml $.Values.podSecurityContext | nindent 12 }} + {{- if $cronJob.initContainers }} + initContainers: + {{- include "wandb-base.containers" (dict "containers" $cronJob.initContainers "root" $) | nindent 12 }} + {{- end }} + containers: + {{- include "wandb-base.containers" (dict "containers" $cronJob.containers "root" $) | nindent 12 }} + restartPolicy: Never + {{/* TODO: enable this as needed + volumes: + {{- tpl (toYaml . | nindent 12) $ }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} + */}} +--- +{{- end }} \ No newline at end of file diff --git a/charts/wandb-base/templates/deployment.yaml b/charts/wandb-base/templates/deployment.yaml index 40d140ec..073893e5 100644 --- a/charts/wandb-base/templates/deployment.yaml +++ b/charts/wandb-base/templates/deployment.yaml @@ -33,10 +33,10 @@ spec: {{- toYaml .Values.podSecurityContext | nindent 8 }} {{- if .Values.initContainers }} initContainers: - {{- include "wandb-base.initContainers" . | nindent 8 }} + {{- include "wandb-base.containers" (dict "containers" .Values.initContainers "root" .) | nindent 8 }} {{- end }} containers: - {{- include "wandb-base.containers" . | nindent 8 }} + {{- include "wandb-base.containers" (dict "containers" .Values.containers "root" .) | nindent 8 }} {{- with .Values.volumes }} volumes: {{- tpl (toYaml . | nindent 8) $ }} diff --git a/charts/wandb-base/templates/job.yaml b/charts/wandb-base/templates/job.yaml new file mode 100644 index 00000000..8f7d4cdb --- /dev/null +++ b/charts/wandb-base/templates/job.yaml @@ -0,0 +1,57 @@ +{{- range $jobName, $job := .Values.jobs }} +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ printf "%s-%s" $.Release.Name $jobName }} + labels: + {{- include "wandb-base.labels" $ | nindent 4 }} + {{- with $job.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + template: + metadata: + {{- with $job.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "wandb-base.labels" $ | nindent 8 }} + {{- with $job.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with $.Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "wandb-base.serviceAccountName" $ }} + securityContext: + {{- toYaml $.Values.podSecurityContext | nindent 8 }} + {{- if $job.initContainers }} + initContainers: + {{- include "wandb-base.containers" (dict "containers" $job.initContainers "root" $) | nindent 8 }} + {{- end }} + containers: + {{- include "wandb-base.containers" (dict "containers" $job.containers "root" $) | nindent 8 }} + restartPolicy: Never +{{/* TODO: enable this as needed + volumes: + {{- tpl (toYaml . | nindent 8) $ }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +*/}} +--- +{{- end }} \ No newline at end of file diff --git a/charts/wandb-base/templates/statefulset.yaml b/charts/wandb-base/templates/statefulset.yaml index 475083e3..a5f9d694 100644 --- a/charts/wandb-base/templates/statefulset.yaml +++ b/charts/wandb-base/templates/statefulset.yaml @@ -31,34 +31,12 @@ spec: serviceAccountName: {{ include "wandb-base.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.initContainers }} + initContainers: + {{- include "wandb-base.containers" (dict "containers" .Values.initContainers "root" .) | nindent 8 }} + {{- end }} containers: - - name: {{ .Chart.Name }} - {{ with .Values.envFrom }} - envFrom: - {{- toYaml . | nindent 12 }} - {{- end }} - {{ with .Values.env }} - env: - {{- toYaml . | nindent 12 }} - {{- end }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: {{ .Values.service.port }} - protocol: TCP - livenessProbe: - {{- toYaml .Values.livenessProbe | nindent 12 }} - readinessProbe: - {{- toYaml .Values.readinessProbe | nindent 12 }} - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.volumeMounts }} - volumeMounts: - {{- toYaml . | nindent 12 }} - {{- end }} + {{- include "wandb-base.containers" (dict "containers" .Values.containers "root" .) | nindent 8 }} {{- with .Values.volumes }} volumes: {{- toYaml . | nindent 8 }} diff --git a/charts/wandb-base/values.yaml b/charts/wandb-base/values.yaml index cf0a7066..ee646270 100644 --- a/charts/wandb-base/values.yaml +++ b/charts/wandb-base/values.yaml @@ -49,38 +49,112 @@ securityContext: initContainers: [] -containers: - - name: nginx - command: [] - args: [] - env: {} - envFrom: {} - securityContext: {} - image: {} - ports: - - containerPort: 80 - name: http - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - startupProbe: - httpGet: - path: / - port: http - lifecycle: {} - resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi - volumeMounts: [] +containers: {} +# nginx: +# command: [] +# args: [] +# env: {} +# envFrom: {} +# securityContext: {} +# image: {} +# ports: +# - containerPort: 80 +# name: http +# livenessProbe: +# httpGet: +# path: / +# port: http +# readinessProbe: +# httpGet: +# path: / +# port: http +# startupProbe: +# httpGet: +# path: / +# port: http +# lifecycle: {} +# resources: +# limits: +# cpu: 100m +# memory: 128Mi +# requests: +# cpu: 100m +# memory: 128Mi +# volumeMounts: [] + +jobs: {} +# example: +# annotations: +# "helm.sh/hook": post-install +# containers: +# nginx: +# command: [ ] +# args: [ ] +# env: { } +# envFrom: { } +# securityContext: { } +# image: { } +# ports: +# - containerPort: 80 +# name: http +# livenessProbe: +# httpGet: +# path: / +# port: http +# readinessProbe: +# httpGet: +# path: / +# port: http +# startupProbe: +# httpGet: +# path: / +# port: http +# lifecycle: { } +# resources: +# limits: +# cpu: 100m +# memory: 128Mi +# requests: +# cpu: 100m +# memory: 128Mi +# volumeMounts: [ ] + +cronJobs: {} +# example: +# schedule: "*/5 * * * *" +# annotations: { } +# containers: +# nginx: +# command: [ ] +# args: [ ] +# env: { } +# envFrom: { } +# securityContext: { } +# image: { } +# ports: +# - containerPort: 80 +# name: http +# livenessProbe: +# httpGet: +# path: / +# port: http +# readinessProbe: +# httpGet: +# path: / +# port: http +# startupProbe: +# httpGet: +# path: / +# port: http +# lifecycle: { } +# resources: +# limits: +# cpu: 100m +# memory: 128Mi +# requests: +# cpu: 100m +# memory: 128Mi +# volumeMounts: [ ] # This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ service: