Skip to content

Commit

Permalink
Merge pull request #40 from hansaya/main
Browse files Browse the repository at this point in the history
Ability to add extra env variables
  • Loading branch information
ressu authored Feb 12, 2023
2 parents 040f189 + aa52637 commit 7f5a52f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
43 changes: 43 additions & 0 deletions charts/kube-plex/templates/_env_vars.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{/*
Environment variables used by containers.
*/}}
{{- define "env_vars" -}}
{{- $values := .Values.extraEnv -}}
{{- if hasKey . "ObjectValues" -}}
{{- with .ObjectValues.env -}}
{{- $values = . -}}
{{- end -}}
{{- end -}}

{{- with $values -}}
{{- $result := list -}}
{{- range $k, $v := . -}}
{{- $name := $k -}}
{{- $value := $v -}}
{{- if kindIs "int" $name -}}
{{- $name = required "environment variables as a list of maps require a name field" $value.name -}}
{{- end -}}

{{- if kindIs "map" $value -}}
{{- if hasKey $value "value" -}}
{{- $envValue := $value.value | toString -}}
{{- $result = append $result (dict "name" $name "value" (tpl $envValue $)) -}}
{{- else if hasKey $value "valueFrom" -}}
{{- $result = append $result (dict "name" $name "valueFrom" $value.valueFrom) -}}
{{- else -}}
{{- $result = append $result (dict "name" $name "valueFrom" $value) -}}
{{- end -}}
{{- end -}}
{{- if not (kindIs "map" $value) -}}
{{- if kindIs "string" $value -}}
{{- $result = append $result (dict "name" $name "value" (tpl $value $)) -}}
{{- else if or (kindIs "float64" $value) (kindIs "bool" $value) -}}
{{- $result = append $result (dict "name" $name "value" ($value | toString)) -}}
{{- else -}}
{{- $result = append $result (dict "name" $name "value" $value) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- toYaml (dict "env" $result) | nindent 0 -}}
{{- end -}}
{{- end -}}
4 changes: 4 additions & 0 deletions charts/kube-plex/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ spec:
- name: "NO_PROXY"
value: "{{.Values.proxy.noproxy}}"
{{- end }}
{{- end }}
# Extra ENV variables
{{- with .Values.extraEnv }}
{{- get (fromYaml (include "env_vars" $)) "env" | toYaml | nindent 8 -}}
{{- end }}
volumeMounts:
- name: data
Expand Down
7 changes: 7 additions & 0 deletions charts/kube-plex/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ claimToken: ""
# Set the timezone of the plex server
timezone: Europe/London

# Set extra environment variables
extraEnv: {}
# puid: 1002
# pgid: 1002
# NVIDIA_VISIBLE_DEVICES: all
# NVIDIA_DRIVER_CAPABILITIES: video,compute,utility

service:
type: ClusterIP
port: 32400
Expand Down

0 comments on commit 7f5a52f

Please sign in to comment.