Skip to content

Commit dd2c69f

Browse files
Copy Bitnami common subcharts (#87)
Moves us off any further Bitnami dependencies in the Helm charts
1 parent 1c5398b commit dd2c69f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4700
-22
lines changed

do

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ kubeconform() {
1212
for chart_dir in ./helm/*/; do
1313
if [[ -f "$chart_dir/Chart.yaml" ]]; then
1414
# TODO: Skip postgresql chart - failing validation
15-
if [[ "$chart_dir" == *"postgresql"* ]]; then
15+
if [[ "$chart_dir" == *"postgresql"* || "$chart_dir" == *"common"* ]]; then
1616
echo "Skipping chart: $chart_dir (TODO: fix validation issues)"
1717
continue
1818
fi
@@ -76,6 +76,10 @@ package-all-charts() {
7676

7777
for chart_path in "${charts_dir}"/*; do
7878
if [ -d "${chart_path}" ]; then
79+
if [[ "${chart_path}" == *"common"* ]]; then
80+
continue
81+
fi
82+
7983
echo "Processing chart: $(basename "${chart_path}")"
8084
echo "${stdin_data}" | ./do package-chart "${chart_path}" "${@:2}"
8185
echo

helm/common/v1/.helmignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
.vscode/

helm/common/v1/Chart.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
annotations:
2+
category: Infrastructure
3+
apiVersion: v2
4+
appVersion: 1.17.1
5+
description: A Library Helm Chart for grouping common logic between bitnami charts.
6+
This chart is not deployable by itself.
7+
home: https://github.com/bitnami/charts/tree/master/bitnami/common
8+
icon: https://bitnami.com/downloads/logos/bitnami-mark.png
9+
keywords:
10+
- common
11+
- helper
12+
- template
13+
- function
14+
- bitnami
15+
maintainers:
16+
- name: Bitnami
17+
url: https://github.com/bitnami/charts
18+
name: common
19+
sources:
20+
- https://github.com/bitnami/charts
21+
- https://www.bitnami.com/
22+
type: library
23+
version: 1.17.1

helm/common/v1/README.md

Lines changed: 350 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
3+
{{/*
4+
Return a soft nodeAffinity definition
5+
{{ include "common.affinities.nodes.soft" (dict "key" "FOO" "values" (list "BAR" "BAZ")) -}}
6+
*/}}
7+
{{- define "common.affinities.nodes.soft" -}}
8+
preferredDuringSchedulingIgnoredDuringExecution:
9+
- preference:
10+
matchExpressions:
11+
- key: {{ .key }}
12+
operator: In
13+
values:
14+
{{- range .values }}
15+
- {{ . | quote }}
16+
{{- end }}
17+
weight: 1
18+
{{- end -}}
19+
20+
{{/*
21+
Return a hard nodeAffinity definition
22+
{{ include "common.affinities.nodes.hard" (dict "key" "FOO" "values" (list "BAR" "BAZ")) -}}
23+
*/}}
24+
{{- define "common.affinities.nodes.hard" -}}
25+
requiredDuringSchedulingIgnoredDuringExecution:
26+
nodeSelectorTerms:
27+
- matchExpressions:
28+
- key: {{ .key }}
29+
operator: In
30+
values:
31+
{{- range .values }}
32+
- {{ . | quote }}
33+
{{- end }}
34+
{{- end -}}
35+
36+
{{/*
37+
Return a nodeAffinity definition
38+
{{ include "common.affinities.nodes" (dict "type" "soft" "key" "FOO" "values" (list "BAR" "BAZ")) -}}
39+
*/}}
40+
{{- define "common.affinities.nodes" -}}
41+
{{- if eq .type "soft" }}
42+
{{- include "common.affinities.nodes.soft" . -}}
43+
{{- else if eq .type "hard" }}
44+
{{- include "common.affinities.nodes.hard" . -}}
45+
{{- end -}}
46+
{{- end -}}
47+
48+
{{/*
49+
Return a soft podAffinity/podAntiAffinity definition
50+
{{ include "common.affinities.pods.soft" (dict "component" "FOO" "extraMatchLabels" .Values.extraMatchLabels "context" $) -}}
51+
*/}}
52+
{{- define "common.affinities.pods.soft" -}}
53+
{{- $component := default "" .component -}}
54+
{{- $extraMatchLabels := default (dict) .extraMatchLabels -}}
55+
preferredDuringSchedulingIgnoredDuringExecution:
56+
- podAffinityTerm:
57+
labelSelector:
58+
matchLabels: {{- (include "common.labels.matchLabels" .context) | nindent 10 }}
59+
{{- if not (empty $component) }}
60+
{{ printf "app.kubernetes.io/component: %s" $component }}
61+
{{- end }}
62+
{{- range $key, $value := $extraMatchLabels }}
63+
{{ $key }}: {{ $value | quote }}
64+
{{- end }}
65+
namespaces:
66+
- {{ include "common.names.namespace" .context | quote }}
67+
topologyKey: kubernetes.io/hostname
68+
weight: 1
69+
{{- end -}}
70+
71+
{{/*
72+
Return a hard podAffinity/podAntiAffinity definition
73+
{{ include "common.affinities.pods.hard" (dict "component" "FOO" "extraMatchLabels" .Values.extraMatchLabels "context" $) -}}
74+
*/}}
75+
{{- define "common.affinities.pods.hard" -}}
76+
{{- $component := default "" .component -}}
77+
{{- $extraMatchLabels := default (dict) .extraMatchLabels -}}
78+
requiredDuringSchedulingIgnoredDuringExecution:
79+
- labelSelector:
80+
matchLabels: {{- (include "common.labels.matchLabels" .context) | nindent 8 }}
81+
{{- if not (empty $component) }}
82+
{{ printf "app.kubernetes.io/component: %s" $component }}
83+
{{- end }}
84+
{{- range $key, $value := $extraMatchLabels }}
85+
{{ $key }}: {{ $value | quote }}
86+
{{- end }}
87+
namespaces:
88+
- {{ include "common.names.namespace" .context | quote }}
89+
topologyKey: kubernetes.io/hostname
90+
{{- end -}}
91+
92+
{{/*
93+
Return a podAffinity/podAntiAffinity definition
94+
{{ include "common.affinities.pods" (dict "type" "soft" "key" "FOO" "values" (list "BAR" "BAZ")) -}}
95+
*/}}
96+
{{- define "common.affinities.pods" -}}
97+
{{- if eq .type "soft" }}
98+
{{- include "common.affinities.pods.soft" . -}}
99+
{{- else if eq .type "hard" }}
100+
{{- include "common.affinities.pods.hard" . -}}
101+
{{- end -}}
102+
{{- end -}}
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
3+
{{/*
4+
Return the target Kubernetes version
5+
*/}}
6+
{{- define "common.capabilities.kubeVersion" -}}
7+
{{- if .Values.global }}
8+
{{- if .Values.global.kubeVersion }}
9+
{{- .Values.global.kubeVersion -}}
10+
{{- else }}
11+
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
12+
{{- end -}}
13+
{{- else }}
14+
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
15+
{{- end -}}
16+
{{- end -}}
17+
18+
{{/*
19+
Return the appropriate apiVersion for poddisruptionbudget.
20+
*/}}
21+
{{- define "common.capabilities.policy.apiVersion" -}}
22+
{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}}
23+
{{- print "policy/v1beta1" -}}
24+
{{- else -}}
25+
{{- print "policy/v1" -}}
26+
{{- end -}}
27+
{{- end -}}
28+
29+
{{/*
30+
Return the appropriate apiVersion for networkpolicy.
31+
*/}}
32+
{{- define "common.capabilities.networkPolicy.apiVersion" -}}
33+
{{- if semverCompare "<1.7-0" (include "common.capabilities.kubeVersion" .) -}}
34+
{{- print "extensions/v1beta1" -}}
35+
{{- else -}}
36+
{{- print "networking.k8s.io/v1" -}}
37+
{{- end -}}
38+
{{- end -}}
39+
40+
{{/*
41+
Return the appropriate apiVersion for cronjob.
42+
*/}}
43+
{{- define "common.capabilities.cronjob.apiVersion" -}}
44+
{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}}
45+
{{- print "batch/v1beta1" -}}
46+
{{- else -}}
47+
{{- print "batch/v1" -}}
48+
{{- end -}}
49+
{{- end -}}
50+
51+
{{/*
52+
Return the appropriate apiVersion for deployment.
53+
*/}}
54+
{{- define "common.capabilities.deployment.apiVersion" -}}
55+
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
56+
{{- print "extensions/v1beta1" -}}
57+
{{- else -}}
58+
{{- print "apps/v1" -}}
59+
{{- end -}}
60+
{{- end -}}
61+
62+
{{/*
63+
Return the appropriate apiVersion for statefulset.
64+
*/}}
65+
{{- define "common.capabilities.statefulset.apiVersion" -}}
66+
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
67+
{{- print "apps/v1beta1" -}}
68+
{{- else -}}
69+
{{- print "apps/v1" -}}
70+
{{- end -}}
71+
{{- end -}}
72+
73+
{{/*
74+
Return the appropriate apiVersion for ingress.
75+
*/}}
76+
{{- define "common.capabilities.ingress.apiVersion" -}}
77+
{{- if .Values.ingress -}}
78+
{{- if .Values.ingress.apiVersion -}}
79+
{{- .Values.ingress.apiVersion -}}
80+
{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
81+
{{- print "extensions/v1beta1" -}}
82+
{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}}
83+
{{- print "networking.k8s.io/v1beta1" -}}
84+
{{- else -}}
85+
{{- print "networking.k8s.io/v1" -}}
86+
{{- end }}
87+
{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
88+
{{- print "extensions/v1beta1" -}}
89+
{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}}
90+
{{- print "networking.k8s.io/v1beta1" -}}
91+
{{- else -}}
92+
{{- print "networking.k8s.io/v1" -}}
93+
{{- end -}}
94+
{{- end -}}
95+
96+
{{/*
97+
Return the appropriate apiVersion for RBAC resources.
98+
*/}}
99+
{{- define "common.capabilities.rbac.apiVersion" -}}
100+
{{- if semverCompare "<1.17-0" (include "common.capabilities.kubeVersion" .) -}}
101+
{{- print "rbac.authorization.k8s.io/v1beta1" -}}
102+
{{- else -}}
103+
{{- print "rbac.authorization.k8s.io/v1" -}}
104+
{{- end -}}
105+
{{- end -}}
106+
107+
{{/*
108+
Return the appropriate apiVersion for CRDs.
109+
*/}}
110+
{{- define "common.capabilities.crd.apiVersion" -}}
111+
{{- if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}}
112+
{{- print "apiextensions.k8s.io/v1beta1" -}}
113+
{{- else -}}
114+
{{- print "apiextensions.k8s.io/v1" -}}
115+
{{- end -}}
116+
{{- end -}}
117+
118+
{{/*
119+
Return the appropriate apiVersion for APIService.
120+
*/}}
121+
{{- define "common.capabilities.apiService.apiVersion" -}}
122+
{{- if semverCompare "<1.10-0" (include "common.capabilities.kubeVersion" .) -}}
123+
{{- print "apiregistration.k8s.io/v1beta1" -}}
124+
{{- else -}}
125+
{{- print "apiregistration.k8s.io/v1" -}}
126+
{{- end -}}
127+
{{- end -}}
128+
129+
{{/*
130+
Return the appropriate apiVersion for Horizontal Pod Autoscaler.
131+
*/}}
132+
{{- define "common.capabilities.hpa.apiVersion" -}}
133+
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .context) -}}
134+
{{- if .beta2 -}}
135+
{{- print "autoscaling/v2beta2" -}}
136+
{{- else -}}
137+
{{- print "autoscaling/v2beta1" -}}
138+
{{- end -}}
139+
{{- else -}}
140+
{{- print "autoscaling/v2" -}}
141+
{{- end -}}
142+
{{- end -}}
143+
144+
{{/*
145+
Returns true if the used Helm version is 3.3+.
146+
A way to check the used Helm version was not introduced until version 3.3.0 with .Capabilities.HelmVersion, which contains an additional "{}}" structure.
147+
This check is introduced as a regexMatch instead of {{ if .Capabilities.HelmVersion }} because checking for the key HelmVersion in <3.3 results in a "interface not found" error.
148+
**To be removed when the catalog's minimun Helm version is 3.3**
149+
*/}}
150+
{{- define "common.capabilities.supportsHelmVersion" -}}
151+
{{- if regexMatch "{(v[0-9])*[^}]*}}$" (.Capabilities | toString ) }}
152+
{{- true -}}
153+
{{- end -}}
154+
{{- end -}}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Through error when upgrading using empty passwords values that must not be empty.
4+
5+
Usage:
6+
{{- $validationError00 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password00" "secret" "secretName" "field" "password-00") -}}
7+
{{- $validationError01 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password01" "secret" "secretName" "field" "password-01") -}}
8+
{{ include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $validationError00 $validationError01) "context" $) }}
9+
10+
Required password params:
11+
- validationErrors - String - Required. List of validation strings to be return, if it is empty it won't throw error.
12+
- context - Context - Required. Parent context.
13+
*/}}
14+
{{- define "common.errors.upgrade.passwords.empty" -}}
15+
{{- $validationErrors := join "" .validationErrors -}}
16+
{{- if and $validationErrors .context.Release.IsUpgrade -}}
17+
{{- $errorString := "\nPASSWORDS ERROR: You must provide your current passwords when upgrading the release." -}}
18+
{{- $errorString = print $errorString "\n Note that even after reinstallation, old credentials may be needed as they may be kept in persistent volume claims." -}}
19+
{{- $errorString = print $errorString "\n Further information can be obtained at https://docs.bitnami.com/general/how-to/troubleshoot-helm-chart-issues/#credential-errors-while-upgrading-chart-releases" -}}
20+
{{- $errorString = print $errorString "\n%s" -}}
21+
{{- printf $errorString $validationErrors | fail -}}
22+
{{- end -}}
23+
{{- end -}}

0 commit comments

Comments
 (0)