mirror of
https://github.com/k8s-at-home/charts.git
synced 2025-01-23 23:49:12 +00:00
[common] Update to 2.4.0 (#550)
* [common] Add envValueFrom * Add unit tests Co-authored-by: ᗪєνιη ᗷυнʟ <onedr0p@users.noreply.github.com>
This commit is contained in:
parent
a5cd196a7f
commit
3d64b1c07a
@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2.4.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Allow setting environment variables from Downward API via `envValueFrom`. See [the Kubernetes docs](https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/) for more information.
|
||||||
|
|
||||||
## [2.3.0]
|
## [2.3.0]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@ -78,6 +84,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
This is the last version before starting this changelog. All sorts of cool stuff was changed, but only `git log` remembers what that was :slightly_frowning_face:
|
This is the last version before starting this changelog. All sorts of cool stuff was changed, but only `git log` remembers what that was :slightly_frowning_face:
|
||||||
|
|
||||||
|
[2.4.0]: https://github.com/k8s-at-home/charts/tree/common-2.4.0/charts/common
|
||||||
|
|
||||||
|
[2.3.0]: https://github.com/k8s-at-home/charts/tree/common-2.3.0/charts/common
|
||||||
|
|
||||||
[2.2.1]: https://github.com/k8s-at-home/charts/tree/common-2.2.1/charts/common
|
[2.2.1]: https://github.com/k8s-at-home/charts/tree/common-2.2.1/charts/common
|
||||||
|
|
||||||
[2.2.0]: https://github.com/k8s-at-home/charts/tree/common-2.2.0/charts/common
|
[2.2.0]: https://github.com/k8s-at-home/charts/tree/common-2.2.0/charts/common
|
||||||
|
@ -2,7 +2,7 @@ apiVersion: v2
|
|||||||
name: common
|
name: common
|
||||||
description: Function library for k8s-at-home charts
|
description: Function library for k8s-at-home charts
|
||||||
type: library
|
type: library
|
||||||
version: 2.3.0
|
version: 2.4.0
|
||||||
keywords:
|
keywords:
|
||||||
- k8s-at-home
|
- k8s-at-home
|
||||||
- common
|
- common
|
||||||
|
@ -15,7 +15,7 @@ The main container included in the controller.
|
|||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml . | nindent 4 }}
|
{{- toYaml . | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if or .Values.env .Values.envTpl }}
|
{{- if or .Values.env .Values.envTpl .Values.envValueFrom }}
|
||||||
env:
|
env:
|
||||||
{{- range $key, $value := .Values.env }}
|
{{- range $key, $value := .Values.env }}
|
||||||
- name: {{ $key }}
|
- name: {{ $key }}
|
||||||
@ -25,6 +25,11 @@ The main container included in the controller.
|
|||||||
- name: {{ $key }}
|
- name: {{ $key }}
|
||||||
value: {{ tpl $value $ | quote }}
|
value: {{ tpl $value $ | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- range $key, $value := .Values.envValueFrom }}
|
||||||
|
- name: {{ $key }}
|
||||||
|
valueFrom:
|
||||||
|
{{- $value | toYaml | nindent 6 }}
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- with .Values.envFrom }}
|
{{- with .Values.envFrom }}
|
||||||
envFrom:
|
envFrom:
|
||||||
|
@ -39,6 +39,14 @@ env: {}
|
|||||||
## With a release name of: demo, the example env value will be: demo-admin
|
## With a release name of: demo, the example env value will be: demo-admin
|
||||||
envTpl: {}
|
envTpl: {}
|
||||||
# TEMPLATE_VALUE: "{{ .Release.Name }}-admin"
|
# TEMPLATE_VALUE: "{{ .Release.Name }}-admin"
|
||||||
|
|
||||||
|
## Variables with values from (for example) the Downward API
|
||||||
|
## See https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/
|
||||||
|
envValueFrom: {}
|
||||||
|
# NODE_NAME:
|
||||||
|
# fieldRef:
|
||||||
|
# fieldPath: spec.nodeName
|
||||||
|
|
||||||
envFrom: []
|
envFrom: []
|
||||||
# - configMapRef:
|
# - configMapRef:
|
||||||
# name: config-map-name
|
# name: config-map-name
|
||||||
|
@ -56,6 +56,20 @@ class Test < ChartTest
|
|||||||
jq('.spec.template.spec.containers[0].env[0].value', resource('Deployment')).must_equal values[:env].values[0].to_s
|
jq('.spec.template.spec.containers[0].env[0].value', resource('Deployment')).must_equal values[:env].values[0].to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'set "valueFrom" environment variables' do
|
||||||
|
values = {
|
||||||
|
envValueFrom: {
|
||||||
|
NODE_NAME: {
|
||||||
|
fieldRef: {
|
||||||
|
fieldPath: "spec.nodeName"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chart.value values
|
||||||
|
jq('.spec.template.spec.containers[0].env[0].name', resource('Deployment')).must_equal values[:envValueFrom].keys[0].to_s
|
||||||
|
jq('.spec.template.spec.containers[0].env[0].valueFrom | keys[0]', resource('Deployment')).must_equal values[:envValueFrom].values[0].keys[0].to_s
|
||||||
|
end
|
||||||
|
|
||||||
it 'set "static" and "Dynamic/Tpl" environment variables' do
|
it 'set "static" and "Dynamic/Tpl" environment variables' do
|
||||||
values = {
|
values = {
|
||||||
|
Loading…
Reference in New Issue
Block a user