Skip to content

Commit

Permalink
Implement extraEnv and extraEnvFrom patterns (#50)
Browse files Browse the repository at this point in the history
Change `extraEnv` from key / value mapping to a object, that is directly
inserted into a template. It allows usage of environment variables other
than plain text values. For example:

```yaml
extraEnv:
  - name: NODE_IP
    valueFrom:
      fieldRef:
        fieldPath: status.hostIP
```

Add `extraEnvFrom` chart parameter.
  • Loading branch information
cutwater authored Aug 22, 2024
1 parent 2893bca commit 680bb02
Show file tree
Hide file tree
Showing 12 changed files with 399 additions and 71 deletions.
2 changes: 1 addition & 1 deletion charts/kamu-api-server/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: kamu-api-server
description: API server component of the Kamu Compute Node
type: application
version: 0.32.1
version: 0.32.2
appVersion: "0.32.1"
home: https://kamu.dev
icon: https://www.kamu.dev/images/kamu_logo_icon_bg_square.png
Expand Down
11 changes: 7 additions & 4 deletions charts/kamu-api-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ spec:
value: "1"
- name: RUST_LOG
value: {{ .Values.app.logLevel | quote }}
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
{{- end }}
{{- if .Values.app.awsCredentials.enabled }}
{{- $secretName := include "kamu-api-server.awsCredentialsSecretName" . }}
- name: AWS_ENDPOINT
Expand All @@ -116,6 +112,13 @@ spec:
name: {{ $secretName }}
key: aws_secret_access_key
{{- end }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: configs
subPath: config.yaml
Expand Down
103 changes: 102 additions & 1 deletion charts/kamu-api-server/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,107 @@
}
}
}
},
"extraEnv": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
},
"valueFrom": {
"type": "object",
"properties": {
"configMapKeyRef": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "object"
},
"optional": {
"type": "boolean"
}
}
},
"fieldRef": {
"type": "object",
"properties": {
"apiVersion": {
"type": "string"
},
"fieldPath": {
"type": "string"
}
}
},
"resourceFieldRef": {
"type": "object",
"properties": {
"resource": {"type": "string"},
"containerName": {"type": "string"},
"divisor": {"type": "string"}
}
},
"secretKeyRef": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "object"
},
"optional": {
"type": "boolean"
}
}
}
}
}
},
"required": [
"name"
],
"additionalProperties": false
}
},
"extraEnvFrom": {
"type": "array",
"items": {
"type": "object",
"properties": {
"configMapRef": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"optional": {
"type": "boolean"
}
}
},
"prefix": {
"type": "string"
},
"secretRef": {
"type": "object",
"properties": {
"name": {
"type": "string",
"optional": "boolean"
}
}
}
}
}
}
}
}
}
3 changes: 2 additions & 1 deletion charts/kamu-api-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ serviceAccount:
# If not set and create is true, a name is generated using the fullname template
name: ""

extraEnv: {}
extraEnv: []
extraEnvFrom: []

podAnnotations: {}

Expand Down
2 changes: 1 addition & 1 deletion charts/kamu-oracle-provider/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: kamu-oracle-provider
description: Oracle provider that uses Kamu Node to supply data to blockchain smart contracts
type: application
version: 0.29.5
version: 0.29.6
appVersion: "0.29.1"
home: https://kamu.dev
icon: https://www.kamu.dev/images/kamu_logo_icon_bg_square.png
Expand Down
9 changes: 6 additions & 3 deletions charts/kamu-oracle-provider/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ spec:
value: "1"
- name: RUST_LOG
value: {{ .Values.app.logLevel | quote }}
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: configs
subPath: config.yaml
Expand Down
103 changes: 102 additions & 1 deletion charts/kamu-oracle-provider/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,107 @@
"properties": {}
}
}
},
"extraEnv": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
},
"valueFrom": {
"type": "object",
"properties": {
"configMapKeyRef": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "object"
},
"optional": {
"type": "boolean"
}
}
},
"fieldRef": {
"type": "object",
"properties": {
"apiVersion": {
"type": "string"
},
"fieldPath": {
"type": "string"
}
}
},
"resourceFieldRef": {
"type": "object",
"properties": {
"resource": {"type": "string"},
"containerName": {"type": "string"},
"divisor": {"type": "string"}
}
},
"secretKeyRef": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "object"
},
"optional": {
"type": "boolean"
}
}
}
}
}
},
"required": [
"name"
],
"additionalProperties": false
}
},
"extraEnvFrom": {
"type": "array",
"items": {
"type": "object",
"properties": {
"configMapRef": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"optional": {
"type": "boolean"
}
}
},
"prefix": {
"type": "string"
},
"secretRef": {
"type": "object",
"properties": {
"name": {
"type": "string",
"optional": "boolean"
}
}
}
}
}
}
}
}
}
3 changes: 2 additions & 1 deletion charts/kamu-oracle-provider/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ serviceAccount:
# If not set and create is true, a name is generated using the fullname template
name: ""

extraEnv: {}
extraEnv: []
extraEnvFrom: []

podAnnotations: {}

Expand Down
2 changes: 1 addition & 1 deletion charts/kamu-web-ui/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: kamu-web-ui
description: Web frontend component of the Kamu Compute Node
type: application
version: 0.25.1
version: 0.25.2
appVersion: "0.25.1"
home: https://kamu.dev
icon: https://www.kamu.dev/images/kamu_logo_icon_bg_square.png
Expand Down
8 changes: 8 additions & 0 deletions charts/kamu-web-ui/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 8080
Expand Down
Loading

0 comments on commit 680bb02

Please sign in to comment.