mirror of
https://github.com/truenas/charts.git
synced 2026-06-15 22:48:44 +08:00
some cleanup on envs
This commit is contained in:
@@ -1,33 +1,43 @@
|
||||
# Environment Variable
|
||||
|
||||
## Key: env
|
||||
| Key | Type | Helm Template | Default | Description |
|
||||
| :----------------------------------- | :-------------: | :-----------: | :-----: | :-------------------------------------------- |
|
||||
| env | object | Yes | `{}` | [env](#env) |
|
||||
| env.[env-name] | object / string | Yes | `""` | Specify the value for the `env-name` |
|
||||
| env.[env-name].secretKeyRef | object | Yes | `{}` | Objects that holds info for the secret ref |
|
||||
| env.[env-name].secretKeyRef.name | string | Yes | `""` | Specify the secret name |
|
||||
| env.[env-name].secretKeyRef.key | string | Yes | `""` | Specify the key on the secret |
|
||||
| env.[env-name].secretKeyRef.optional | boolean | Yes | `false` | Specify if the secret is optional |
|
||||
| env.[env-name].configMapKeyRef | object | Yes | `{}` | Objects that holds info for the configMap ref |
|
||||
| env.[env-name].configMapKeyRef.name | string | Yes | `""` | Specify the configMap name |
|
||||
| env.[env-name].configMapKeyRef.key | string | Yes | `""` | Specify the key on the configMap |
|
||||
| envList | list | Yes | `[]` | [envlist](#envlist) |
|
||||
| envList.name | string | Yes | `""` | The name of the env |
|
||||
| envList.value | string | Yes | `""` | The value of the env |
|
||||
| envFrom | list | Yes | `[]` | [envfrom](#envfrom) |
|
||||
| envFrom.secretRef | object | Yes | `{}` | Objects that holds info for the secret ref |
|
||||
| envFrom.secretRef.name | string | Yes | `""` | The name of the secret |
|
||||
| envFrom.configMapRef | object | Yes | `{}` | Objects that holds info for the configMap ref |
|
||||
| envFrom.configMapRef.name | string | Yes | `""` | The name of the configMap |
|
||||
|
||||
Info:
|
||||
## env
|
||||
|
||||
- Type: `dict`
|
||||
- Default: `{}`
|
||||
- Helm Template:
|
||||
- key: ❌
|
||||
- value: ✅
|
||||
- secretKeyRef.name: ✅
|
||||
- secretKeyRef.key: ✅
|
||||
- configMapKeyRef.name: ✅
|
||||
- configMapKeyRef.key: ✅
|
||||
Contains environment variables and can be defined in few different formats
|
||||
|
||||
---
|
||||
|
||||
Can be defined in:
|
||||
|
||||
- `.Values`.env
|
||||
- `.Values.additionalContainers.[container-name]`.env
|
||||
- `.Values.initContainers.[container-name]`.env
|
||||
- `.Values.systemContainers.[container-name]`.env
|
||||
- `.Values.installContainers.[container-name]`.env
|
||||
- `.Values.upgradeContainers.[container-name]`.env
|
||||
- `.Values.systemContainers.[container-name]`.env
|
||||
- `.Values.additionalContainers.[container-name]`.env
|
||||
- `.Values.jobs.[job-name].podSpec.containers.[container-name].[container-name]`.env
|
||||
|
||||
---
|
||||
|
||||
Contains environment variables and can be defined in few different formats
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
@@ -63,17 +73,13 @@ env:
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## Key: envList
|
||||
## envList
|
||||
|
||||
Info:
|
||||
|
||||
- Type: `list`
|
||||
- Default: `[]`
|
||||
- Helm Template:
|
||||
- name: ✅
|
||||
- value: ✅
|
||||
Mainly designed to be used in the SCALE GUI.
|
||||
So users can pass additional environment variables.
|
||||
|
||||
Can be defined in:
|
||||
|
||||
@@ -87,9 +93,6 @@ Can be defined in:
|
||||
|
||||
---
|
||||
|
||||
Mainly designed to be used in the SCALE GUI.
|
||||
So users can pass additional environment variables.
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
@@ -103,17 +106,15 @@ envList:
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## Key: envFrom
|
||||
## envFrom
|
||||
|
||||
Info:
|
||||
|
||||
- Type: `list`
|
||||
- Default: `[]`
|
||||
- Helm Template:
|
||||
- name: ✅
|
||||
- value: ✅
|
||||
Used to load multiple environment variables
|
||||
from a `configMap` or a `secret`. With a single list entry,
|
||||
it will load all keys as environment variables
|
||||
defined in the specified object.
|
||||
|
||||
Can be defined in:
|
||||
|
||||
@@ -127,11 +128,6 @@ Can be defined in:
|
||||
|
||||
---
|
||||
|
||||
Used to load multiple environment variables
|
||||
from a `configMap` or a `secret`. With a single list entry,
|
||||
it will load all keys as environment variables
|
||||
defined in the specified object.
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
@@ -149,9 +145,12 @@ envFrom:
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## Key: TZ
|
||||
## Fixed Environment Variables
|
||||
|
||||
### TZ
|
||||
|
||||
Info:
|
||||
|
||||
@@ -188,9 +187,10 @@ env:
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## Key: security
|
||||
## security
|
||||
|
||||
Info:
|
||||
|
||||
@@ -231,9 +231,10 @@ security:
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## Key: nvidiaCaps
|
||||
## nvidiaCaps
|
||||
|
||||
Info:
|
||||
|
||||
@@ -273,9 +274,10 @@ nvidiaCaps:
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## Key: injectFixedEnvs
|
||||
## injectFixedEnvs
|
||||
|
||||
Info:
|
||||
|
||||
@@ -294,29 +296,37 @@ Can be defined in:
|
||||
- `.Values.jobs.[job-name].podSpec.containers.[container-name].[container-name]`.injectFixedEnvs
|
||||
|
||||
If **enabled**, injects environment variables to the container.
|
||||
|
||||
> If not defined, it will use the `.Values.global.defaults.injectFixedEnvs`
|
||||
|
||||
`TZ`:
|
||||
|
||||
> Applied always. No conditions.
|
||||
|
||||
`UMASK`, `UMASK_SET`:
|
||||
|
||||
> Applied always. No conditions.
|
||||
|
||||
`NVIDIA_VISIBLE_DEVICES`:
|
||||
|
||||
> Applied and set to `void`, if container has no GPU pass through.
|
||||
|
||||
`NVIDIA_DRIVER_CAPABILITIES`:
|
||||
|
||||
> Applied when a GPU is passed through to the container.
|
||||
> Value is defined based on the `nvidiaCaps` key
|
||||
|
||||
`PGID`, `GROUP_ID`, `GID`:
|
||||
|
||||
> Applied when container runs as `root` user or `root` group.
|
||||
> `PGID`, `GROUP_ID`, `GID` is always equal to `fsGroup`.
|
||||
|
||||
`PUID`, `USER_ID`, `UID`:
|
||||
|
||||
> Applied when container runs as `root` user or `root` group.
|
||||
|
||||
`S6_READ_ONLY_ROOT`:
|
||||
|
||||
> Applied when container runs as `root` user or `root` group
|
||||
> or has `readOnlyRootFilesystem` set to true
|
||||
|
||||
|
||||
@@ -35,19 +35,11 @@ That's why the custom dict is expected.
|
||||
"secEnvs" $secEnvs)) -}}
|
||||
{{- end -}} {{/* Finish fixedEnv */}}
|
||||
{{- with $fixedEnv -}}
|
||||
{{- range $fixedEnv | fromJsonArray }} {{/* "fromJsonArray" parses stringified output and convet to list */}}
|
||||
{{- range $fixedEnv | fromJsonArray }} {{/* "fromJsonArray" parses stringified output and convert to list */}}
|
||||
- name: {{ .name | quote }}
|
||||
value: {{ .value | quote }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- include "ix.v1.common.container.env" (dict "envs" $envs
|
||||
"root" $root
|
||||
"fixedEnv" $fixedEnv
|
||||
"containerName" $containerName) -}}
|
||||
|
||||
{{- include "ix.v1.common.container.envList" (dict "envList" $envList
|
||||
"envs" $envs
|
||||
"root" $root
|
||||
"fixedEnv" $fixedEnv
|
||||
"containerName" $containerName) -}}
|
||||
{{- include "ix.v1.common.container.env" (dict "envs" $envs "root" $root "containerName" $containerName) -}}
|
||||
{{- include "ix.v1.common.container.envList" (dict "envList" $envList "root" $root "containerName" $containerName) -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
{{/* Call this template like this:
|
||||
{{- include "ix.v1.common.container.env" (dict "envs" $envs "root" $root "containerName" $containerName) -}}
|
||||
*/}}
|
||||
{{- define "ix.v1.common.container.env" -}}
|
||||
{{- $envs := .envs -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $containerName := .containerName -}}
|
||||
{{- $fixedEnv := .fixedEnv -}}
|
||||
|
||||
{{- if $envs -}}
|
||||
{{- $envs := fromYaml (tpl ($envs | toYaml) $root) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $dupeCheck := dict -}}
|
||||
|
||||
@@ -15,10 +21,7 @@
|
||||
{{- fail "Environment Variables as a list is not supported. Use key-value format." -}}
|
||||
{{- end }}
|
||||
- name: {{ $name | quote }}
|
||||
{{- if not (kindIs "map" $value) -}}
|
||||
{{- if kindIs "string" $value -}} {{/* Single values are parsed as string (eg. int, bool) */}}
|
||||
{{- $value = tpl $value $root -}} {{/* Expand Value */}}
|
||||
{{- end }}
|
||||
{{- if not (kindIs "map" $value) }}
|
||||
value: {{ $value | quote }}
|
||||
{{- $_ := set $dupeCheck $name $value -}}
|
||||
{{- else if kindIs "map" $value -}} {{/* If value is a dict... */}}
|
||||
@@ -47,8 +50,8 @@
|
||||
{{- else -}}
|
||||
{{- fail "Not a valid valueFrom reference. Valid options are (configMapKeyRef and secretKeyRef)" -}}
|
||||
{{- end }}
|
||||
name: {{ tpl (required (printf "<name> for the keyRef is not defined in (%s)" $name) $value.name) $root }} {{/* Expand name and key */}}
|
||||
key: {{ tpl (required (printf "<key> for the keyRef is not defined in (%s)" $name) $value.key) $root }}
|
||||
name: {{ required (printf "<name> for the keyRef is not defined in (%s)" $name) $value.name }} {{/* Expand name and key */}}
|
||||
key: {{ required (printf "<key> for the keyRef is not defined in (%s)" $name) $value.key }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- include "ix.v1.common.util.storeEnvsForDupeCheck" (dict "root" $root "source" "env" "data" $dupeCheck "containers" (list $containerName)) -}}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
{{/* Call this template like this:
|
||||
{{- include "ix.v1.common.container.envList" (dict "envList" $envList "root" $root "containerName" $containerName) -}}
|
||||
*/}}
|
||||
{{- define "ix.v1.common.container.envList" -}}
|
||||
{{- $envList := .envList -}}
|
||||
{{- $envs := .envs -}}
|
||||
{{- $containerName := .containerName -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $fixedEnv := .fixedEnv -}}
|
||||
|
||||
{{- if $envList -}}
|
||||
{{- $envList := fromYaml (tpl ($envList | toYaml) $root) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $dupeCheck := dict -}}
|
||||
|
||||
{{- with $envList -}}
|
||||
{{- range $envList -}}
|
||||
{{- if and .name .value -}}
|
||||
@@ -14,16 +20,14 @@
|
||||
{{- end -}}
|
||||
{{- if mustHas (kindOf .value) (list "map" "slice") -}}
|
||||
{{- fail "Value in envList cannot be a map or slice" -}}
|
||||
{{- end -}}
|
||||
{{- $name := tpl .name $root -}}
|
||||
{{- $value := tpl .value $root }}
|
||||
- name: {{ $name }}
|
||||
value: {{ $value | quote }}
|
||||
{{- $_ := set $dupeCheck $name $value -}}
|
||||
{{- end }}
|
||||
- name: {{ .name }}
|
||||
value: {{ .value | quote }}
|
||||
{{- $_ := set $dupeCheck .name .value -}}
|
||||
{{- else -}}
|
||||
{{- fail "Please specify both name and value for environment variable" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- include "ix.v1.common.util.storeEnvsForDupeCheck" (dict "root" $root "source" "envList" "data" $dupeCheck "containers" (list $containerName)) -}}
|
||||
{{- end -}} {{/* Finish envList */}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
{{/*
|
||||
"toYaml" makes sure that any type of data (int/float/strin)
|
||||
will be parsed correctly without causing errors.
|
||||
{{/* Call this template like this:
|
||||
{{- $fixedEnv = (include "ix.v1.common.container.fixedEnvs" (dict "root" $root
|
||||
"fixedEnv" $fixedEnv
|
||||
"containerName" $containerName
|
||||
"isMainContainer" $isMainContainer
|
||||
"scaleGPU" $scaleGPU
|
||||
"nvidiaCaps" $nvidiaCaps
|
||||
"secCont" $secCont
|
||||
"secEnvs" $secEnvs)) -}}
|
||||
*/}}
|
||||
{{- define "ix.v1.common.container.fixedEnvs" -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
{{- $values := .values -}}
|
||||
{{- $inherit := "inherit" -}}
|
||||
|
||||
{{- $values := fromYaml (tpl ($values | toYaml) $root) -}}
|
||||
|
||||
{{/* Prepare values */}}
|
||||
{{- $saName := "" -}}
|
||||
{{- with $values.serviceAccountName -}}
|
||||
{{- if eq . $inherit -}}
|
||||
{{- $saName = (include "ix.v1.common.names.serviceAccountName" $root) -}}
|
||||
{{- else -}}
|
||||
{{- $saName = tpl . $root -}}
|
||||
{{- $saName = . -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{/* If we ever have value in global.defaults */}}
|
||||
@@ -20,8 +22,8 @@
|
||||
{{- with $values.schedulerName -}}
|
||||
{{- if eq . $inherit -}}
|
||||
{{- $schedulerName = (tpl $root.Values.schedulerName $root) -}}
|
||||
{{- else -}}
|
||||
{{- $schedulerName = tpl . $root -}}
|
||||
{{- else -}}
|
||||
{{- $schedulerName = . -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{/* If we ever have value in global.defaults */}}
|
||||
@@ -32,7 +34,7 @@
|
||||
{{- if eq . $inherit -}}
|
||||
{{- $priorityClassName = (tpl $root.Values.priorityClassName $root) -}}
|
||||
{{- else -}}
|
||||
{{- $priorityClassName = tpl . $root -}}
|
||||
{{- $priorityClassName = . -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{/* If we ever have value in global.defaults */}}
|
||||
@@ -43,7 +45,7 @@
|
||||
{{- if eq . $inherit -}}
|
||||
{{- $hostname = (tpl $root.Values.hostname $root) -}}
|
||||
{{- else -}}
|
||||
{{- $hostname = tpl . $root -}}
|
||||
{{- $hostname = . -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{/* If we ever have value in global.defaults */}}
|
||||
|
||||
Reference in New Issue
Block a user