Update and clean common chart

Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
This commit is contained in:
kjeld Schouten-Lebbing 2021-02-08 16:10:14 +01:00
parent acd00a2050
commit ec561f6512
No known key found for this signature in database
GPG Key ID: 4CDAD4A532BC1EDB
6 changed files with 42 additions and 32 deletions

View File

@ -55,7 +55,21 @@ class Test < ChartTest
jq('.spec.template.spec.containers[0].env[0].name', resource('Deployment')).must_equal values[:env].keys[0].to_s
jq('.spec.template.spec.containers[0].env[0].value', resource('Deployment')).must_equal values[:env].values[0].to_s
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
values = {

View File

@ -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/),
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]
### 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:
[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.0]: https://github.com/k8s-at-home/charts/tree/common-2.2.0/charts/common

View File

@ -2,8 +2,8 @@ apiVersion: v2
name: common
description: Function library for TrueCharts
type: library
version: 0.10.1
# upstream_version: 2.3.0
version: 0.11.1
# upstream_version: 2.4.0
keywords:
- truecharts
- library-chart

View File

@ -1,27 +0,0 @@
{{/*
Renders the Ingress objects required by the chart by returning a concatinated list
of the main Ingress and any additionalIngresses.
*/}}
{{- define "common.ingress" -}}
{{- if .Values.ingress.enabled -}}
{{- $svcPort := .Values.service.port.port -}}
{{- /* Generate primary ingress */ -}}
{{- $ingressValues := .Values.ingress -}}
{{- $_ := set . "ObjectValues" (dict "ingress" $ingressValues) -}}
{{- include "common.classes.ingress" . }}
{{- /* Generate additional ingresses as required */ -}}
{{- range $index, $extraIngress := .Values.ingress.additionalIngresses }}
{{- if $extraIngress.enabled -}}
{{- print ("---") | nindent 0 -}}
{{- $ingressValues := $extraIngress -}}
{{- if not $ingressValues.nameSuffix -}}
{{- $_ := set $ingressValues "nameSuffix" $index -}}
{{ end -}}
{{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}}
{{- include "common.classes.ingress" $ -}}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -15,7 +15,7 @@ The main container included in the controller.
securityContext:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if or .Values.env .Values.envTpl }}
{{- if or .Values.env .Values.envTpl .Values.envValueFrom }}
env:
{{- range $envVariable := .Values.environmentVariables }}
{{- if and $envVariable.name $envVariable.value }}
@ -33,6 +33,11 @@ The main container included in the controller.
- name: {{ $key }}
value: {{ tpl $value $ | quote }}
{{- end }}
{{- range $key, $value := .Values.envValueFrom }}
- name: {{ $key }}
valueFrom:
{{- $value | toYaml | nindent 6 }}
{{- end }}
{{- end }}
{{- with .Values.envFrom }}
envFrom:

View File

@ -38,7 +38,15 @@ env: {}
## Variables with values set from templates, example
## With a release name of: demo, the example env value will be: demo-admin
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: []
# - configMapRef:
# name: config-map-name