Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+ init containers; use functions to build names #2

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ece4a12
rework deployments to use standardized names; implement initContainer…
May 17, 2023
30c7841
rework configmap & extra-deployments to use standardized names
May 17, 2023
3048230
cleanup
May 17, 2023
5f96f9b
rework configmap-files and cronjobs to use the standard labels
May 17, 2023
4624374
cleaned up deployment, hp, image-pull-secret, ingress-istio, and ingr…
May 17, 2023
9bbbd9c
rework jobs to use the standard labels
May 18, 2023
afaaf35
cleaned up extra-deployments, pod-disruption-budget, pvc, secret, ser…
May 18, 2023
f66161e
cleaned up secret
May 18, 2023
a3d14df
cleaned up service
May 18, 2023
0fc6eed
cleaned up _helpers
May 18, 2023
de7fb6c
utilize buildExtraAnnotations
May 18, 2023
9646f53
fixing chart.buildExtraAnnotations
May 18, 2023
b725c86
fixing bugs
May 18, 2023
0d4e023
fixing bugs
May 18, 2023
ea9f971
fixing bugs
May 18, 2023
73dd478
fixing bugs
May 18, 2023
6cc622c
fixing bugs
May 18, 2023
2525137
fixing bugs
May 18, 2023
f3ac431
fixing bugs
May 18, 2023
cce9897
fixing bugs
May 18, 2023
c514943
fixing bugs
May 18, 2023
a470c53
remove resource limits
May 22, 2023
a5f4291
try to incorporate http redirect code
May 30, 2023
0452250
+istio.forceHttpRedirect as option
May 30, 2023
3a37c15
Merge pull request #3 from m9sweeper/http-redirects
becky-intelletive May 30, 2023
559a10f
fullnameOverride
Oct 17, 2023
0130fbd
pull down latest origin
Oct 17, 2023
aeb0723
mainContainerNameOverride
Oct 17, 2023
67b957f
latest main
Oct 17, 2023
4149b72
make image fields backwards compatible
Oct 17, 2023
948cd9b
update test results
Oct 17, 2023
6bec752
+ test template istio deployment
Oct 17, 2023
6933ec6
stub out everything.values to run more use cases
Oct 17, 2023
578e1a6
rename test charts
Oct 17, 2023
83c8845
rename test charts
Oct 17, 2023
ee398c0
rename test charts
Oct 17, 2023
466a072
rename test charts
Oct 17, 2023
06b3939
set nameoverride and fullnameOverride for tests
Oct 17, 2023
10a6297
unset nameOverride and fulnameOverride for tests
Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/k8ez/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: k8ez
description: A Re-usable Helm Chart for Deploying Almost Any App
type: application
version: 0.0.1
version: 1.0.0
appVersion: 0.0.1
maintainers:
- name: M9sweeper
Expand Down
2 changes: 2 additions & 0 deletions charts/k8ez/files/example-file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
example-root:
example-key: exampleValue
97 changes: 86 additions & 11 deletions charts/k8ez/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Expand the name of the chart.
*/}}
{{- define "chart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" | lower -}}
{{- end -}}

{{/*
Expand All @@ -12,16 +12,16 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
If release name contains chart name it will be used as a full name.
*/}}
{{- define "chart.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" | lower -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" | lower -}}
{{- end -}}
{{- end -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" | lower -}}
{{- else -}}
{{- $name := include "chart.name" . -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" | lower -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" | lower -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Expand All @@ -30,3 +30,78 @@ Create chart name and version as used by the chart label.
{{- define "chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Basic selector labels for the chart
** will also be used for matchExpressions
*/}}
{{- define "chart.basicSelectorLabels" -}}
app: {{ include "chart.fullname" . }}
release: {{ .Release.Name }}
{{- end -}}

{{/*
Basic labels for the chart
*/}}
{{- define "chart.basicLabels" -}}
{{ include "chart.basicSelectorLabels" . }}
chart: {{ include "chart.chart" . }}
heritage: {{ .Release.Service }}
version: {{ .Chart.Version }}
{{- end -}}

{{/*
Builds the full image path
Tested by the array of Stateful Sets
*/}}
{{- define "chart.buildImagePath" -}}
{{- if .image }}{{/* IF .image is defined */}}
{{- if (kindIs "map" .image) }}
{{- $image_to_use := default .values.image.image .image.image }}
{{- if .image.tag }}
{{- $image_to_use }}:{{ .image.tag }}{{/* ENDPOINT ONE */}}
{{- else }}{{/* if not .image.tag */}}
{{- $image_to_use }}{{/* ENDPOINT TWO */}}
{{- end }}{{/* ends if .image.tag */}}
{{- else -}} {{/* if not (kindIs "map" .image) */}}
{{- .image }}{{/* ENDPOINT THREE */}}
{{- end }}{{/* ends if (kindIs "map" .image) */}}
{{- else -}} {{/* if not .image */}}
{{- if .values.image.tag }}
{{- .values.image.image }}:{{ .values.image.tag }}{{/* ENDPOINT FOUR A */}}
{{- else -}}{{/* if not .values.image.tag */}}
{{- .values.image.image }}{{/* ENDPOINT FOUR B */}}
{{- end }}{{/* end if .values.image.tag */}}
{{- end }}{{/* ends if .image */}}
{{- end }}

{{/*
Generic function to build extra annotations
Will include the global annotations unless specified
Will include the resource-specific annotations
*/}}
{{- define "chart.buildExtraAnnotations" -}}
{{- if and .values.extraAnnotations (ne (.excludeGlobalExtraAnnotations | toString | lower) "true") }}
{{- toYaml .values.extraAnnotations | nindent 0 }}
{{- end }}
{{- if .extraAnnotations }}
{{- toYaml .extraAnnotations | nindent 0 }}
{{- end }}
{{- end }}

{{/*
Generic function to build volumes
Will include the global volumes unless specified
Will include the resource-specific volumes
*/}}
{{- define "chart.buildVolumes" -}}
{{- if or .volumes (and .values.volumes (ne (.excludeGlobalVolumes | toString | lower) "true")) }}
volumes:
{{- if and .values.volumes (ne (.excludeGlobalVolumes | toString | lower) "true") }}
{{- toYaml .values.volumes | nindent 2 }}
{{- end }}
{{- if .volumes }}
{{- toYaml .volumes | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}
8 changes: 2 additions & 6 deletions charts/k8ez/templates/configmap-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .configMapName }}
name: {{ required "Each entry in configFiles needs a configMapName" .configMapName }}
labels:
app: {{ $.Release.Name }}
chart: {{ include "chart.chart" $ }}
release: {{ $.Release.Name }}
heritage: {{ $.Release.Service }}
version: {{ $.Chart.Version }}
{{- include "chart.basicLabels" $ | nindent 4 }}
data:
{{- range $path, $_ := $.Files.Glob .fileGlob }}
{{- $path | base | nindent 2 }}: |-
Expand Down
8 changes: 2 additions & 6 deletions charts/k8ez/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}
name: {{ include "chart.fullname" . }}
labels:
app: {{ .Release.Name }}
chart: {{ include "chart.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
version: {{ .Chart.Version }}
{{- include "chart.basicLabels" . | nindent 4 }}
data:
{{ toYaml .Values.configData | indent 2 }}
{{ end }}
112 changes: 65 additions & 47 deletions charts/k8ez/templates/cronjobs.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{- if .Values.cronJobs.enabled }}
{{- range .Values.cronJobs.scheduled }}
{{- $cronJobName := (required "Each entry in cronJobs.scheduled needs a name" .name) }}
{{- $cronJobFullName := printf "%s-%s" (include "chart.fullname" $ | trunc 40) $cronJobName }}
---
{{- if $.Capabilities.APIVersions.Has "batch/v1/CronJob" -}}
apiVersion: batch/v1
Expand All @@ -8,79 +10,95 @@ apiVersion: batch/v1beta1
{{- end }}
kind: CronJob
metadata:
name: {{ .name }}
labels:
app: {{ $.Release.Name }}
chart: {{ include "chart.chart" $ }}
release: {{ $.Release.Name }}
heritage: {{ $.Release.Service }}
version: {{ $.Chart.Version }}
name: {{ $cronJobFullName }}
labels: {{/* TODO: should the app label include the cronjob name? */}}
{{- include "chart.basicLabels" $ | nindent 4}}
spec:
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
metadata:
annotations:
{{- if not $.Values.istio.enabled }}
{{- if not $.Values.istio.enabled }}
sidecar.istio.io/inject: "false"
{{- end }}
{{- if $.Values.extraAnnotations }}
{{ toYaml $.Values.extraAnnotations | indent 12 }}
{{- end }}
{{- end }}
{{- if $.Values.extraAnnotations }}
{{- toYaml $.Values.extraAnnotations | nindent 12 }}
{{- end }}
spec:
{{if $.Values.imagePullSecrets}}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{ end }}
serviceAccount: {{ $.Release.Name }}
serviceAccount: {{ include "chart.fullname" $ }}
enableServiceLinks: {{ $.Values.enableServiceLinks }}
securityContext:
fsGroup: {{ $.Values.podSecurityContext.fsGroup }}
containers:
- name: {{ .name }}
image: "{{ or .image $.Values.image.image }}"
securityContext:
{{ toYaml (merge dict $.Values.securityContext (or .securityContext dict)) | indent 16}}
{{if .resources}}
resources:
{{ toYaml $.Values.resources | indent 14 }}
{{- end }}
{{- if .volumeMounts }}
volumeMounts:
{{ toYaml .volumeMounts | indent 14 }}
{{- end }}
{{ if .command }}
image: {{ include "chart.buildImagePath" (dict "image" .image "values" $.Values ) | quote }}
{{- if and .image (kindIs "map" .image) }}
{{/* commented out: - if and .image (default dict .image).pullPolicy */}}
imagePullPolicy: {{ .image.pullPolicy }}
{{- else }}
imagePullPolicy: {{ $.Values.image.pullPolicy }}
{{- end }}
securityContext:
{{- toYaml (merge dict $.Values.securityContext (or .securityContext dict)) | nindent 16}}

{{- if .command }}
command: [{{ .command | quote }}]
{{- end }}
{{ if .args }}
args:
{{ toYaml .args | indent 14 }}
{{- end }}
{{ if .env }}
env:
{{- range $k, $v := .env }}
{{- end }}

{{- if .args }}
args:
{{- toYaml .args | nindent 14 }}
{{- end }}

{{- if .env }}
env:
{{- range $k, $v := .env }}
- name: {{ $k | quote}}
value: {{ $v | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

{{- if or $.Values.configData $.Values.secretData}}
envFrom:
{{ if $.Values.configData }}
{{- if $.Values.configData }}
- configMapRef:
name: {{ $.Release.Name }}
{{- end }}
{{ if $.Values.secretData }}
name: {{ include "chart.fullname" $ }}
{{- end }}
{{- if $.Values.secretData }}
- secretRef:
name: {{ $.Release.Name }}
{{- end }}
name: {{ include "chart.fullname" $ }}
{{- end }}
{{- end }}

{{- with .volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 14 }}
{{- end }}

{{- if .resources}}
resources:
{{- toYaml .resources | nindent 16 }}
{{- else }}
{{- with $.Values.resources }}
resources:
{{- toYaml . | nindent 16 }}
{{- end }}
{{- end }}

restartPolicy: {{ or .restartPolicy "Never" }}
{{- if .volumes }}

{{- if .volumes }}
volumes:
{{ toYaml .volumes | indent 10 }}
{{- end }}
{{- toYaml .volumes | nindent 10 }}
{{- end }}

schedule: {{ .schedule | quote }}

{{- end }}
{{- end }}
{{- end }}
Loading