diff --git a/library/common-test/tests/pod/deployment_port_test.yaml b/library/common-test/tests/pod/deployment_port_test.yaml index 22f95a8c..11dcecc6 100644 --- a/library/common-test/tests/pod/deployment_port_test.yaml +++ b/library/common-test/tests/pod/deployment_port_test.yaml @@ -10,4 +10,4 @@ tests: isKind: of: Deployment -TODO: ports +#TODO: ports diff --git a/library/common-test/tests/pod/deployment_volume_test.yaml b/library/common-test/tests/pod/deployment_volume_test.yaml index 70c88f14..f8f0de9a 100644 --- a/library/common-test/tests/pod/deployment_volume_test.yaml +++ b/library/common-test/tests/pod/deployment_volume_test.yaml @@ -175,7 +175,7 @@ tests: set: persistence.some_volume.type: nfs persistence.some_volume.enabled: true - persistence.some_volume.enabled: some_path + persistence.some_volume.path: some_path asserts: - failedTemplate: errorMessage: NFS Server not set on item some_volume diff --git a/library/common/1.0.0/templates/lib/chart/_annotations.tpl b/library/common/1.0.0/templates/lib/chart/_annotations.tpl index acd97145..db700a41 100644 --- a/library/common/1.0.0/templates/lib/chart/_annotations.tpl +++ b/library/common/1.0.0/templates/lib/chart/_annotations.tpl @@ -5,7 +5,7 @@ Rendered under ".metadata.annotations" {{- define "ix.v1.common.annotations" -}} {{- with .Values.global.annotations -}} {{- range $k, $v := . }} -{{ $k }}: {{ tpl $v $ | quote }} + {{- $k | nindent 6 }}: {{ tpl $v $ | quote }} {{- end -}} {{- end -}} {{- end -}} @@ -28,6 +28,4 @@ Rendered under ".metadata.annotations" rollme: {{ randAlphaNum 5 | quote }} {{- end -}} -{{/* -Workloads = Deployment, ReplicaSet, StatefulSet, DaemonSet, Job, CronJob, etc -*/}} +{{/* Workloads = Deployment, ReplicaSet, StatefulSet, DaemonSet, Job, CronJob, etc */}} diff --git a/library/common/1.0.0/templates/lib/chart/_capabilities.tpl b/library/common/1.0.0/templates/lib/chart/_capabilities.tpl index cd35d09b..20903cd5 100644 --- a/library/common/1.0.0/templates/lib/chart/_capabilities.tpl +++ b/library/common/1.0.0/templates/lib/chart/_capabilities.tpl @@ -1,34 +1,24 @@ -{{/* -Return the appropriate apiVersion for deployment -*/}} +{{/* Return the appropriate apiVersion for deployment */}} {{- define "ix.v1.common.capabilities.deployment.apiVersion" -}} {{- print "apps/v1" -}} {{- end -}} -{{/* -Return the appropriate apiVersion for statefulset -*/}} +{{/* Return the appropriate apiVersion for statefulset */}} {{- define "ix.v1.common.capabilities.statefulset.apiVersion" -}} {{- print "apps/v1" -}} {{- end -}} -{{/* -Return the appropriate apiVersion for daemonset -*/}} +{{/* Return the appropriate apiVersion for daemonset */}} {{- define "ix.v1.common.capabilities.daemonset.apiVersion" -}} {{- print "apps/v1" -}} {{- end -}} -{{/* -Return the appropriate apiVersion for CronJob -*/}} +{{/* Return the appropriate apiVersion for CronJob */}} {{- define "ix.v1.common.capabilities.cronJob.apiVersion" -}} {{- print "batch/v1" -}} {{- end -}} -{{/* -Return the appropriate apiVersion for Job -*/}} +{{/* Return the appropriate apiVersion for Job */}} {{- define "ix.v1.common.capabilities.job.apiVersion" -}} {{- print "batch/v1" -}} {{- end -}} diff --git a/library/common/1.0.0/templates/lib/chart/_labels.tpl b/library/common/1.0.0/templates/lib/chart/_labels.tpl index 7b0595cf..8cf8beeb 100644 --- a/library/common/1.0.0/templates/lib/chart/_labels.tpl +++ b/library/common/1.0.0/templates/lib/chart/_labels.tpl @@ -7,18 +7,18 @@ helm-revision: {{ .Release.Revision | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- with .Values.global.labels }} - {{- range $k, $v := . }} -{{ $k }}: {{ tpl $v $ | quote }} + {{- with .Values.global.labels }} + {{- range $k, $v := . }} + {{- $k | nindent 0 }}: {{ tpl $v $ | quote }} {{- end }} -{{- end }} + {{- end }} {{- end -}} {{/* Selector labels shared across objects */}} +{{/* TODO: Check why "app" and "release" are needed (ported from the current common) */}} {{- define "ix.v1.common.labels.selectorLabels" -}} app.kubernetes.io/name: {{ include "ix.v1.common.names.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} -{{/* TODO: Check why those are needed (ported from the current common) */}} app: {{ include "ix.v1.common.names.name" . }} release: {{ .Release.Name }} {{- end -}} diff --git a/library/common/1.0.0/templates/lib/chart/_names.tpl b/library/common/1.0.0/templates/lib/chart/_names.tpl index f0e0df78..f92ddfcc 100644 --- a/library/common/1.0.0/templates/lib/chart/_names.tpl +++ b/library/common/1.0.0/templates/lib/chart/_names.tpl @@ -4,9 +4,7 @@ global.nameOverride applies to the current chart and all sub-charts nameOverride applies only to the current chart */}} -{{/* -Expand ther name of the chart -*/}} +{{/* Expand ther name of the chart */}} {{- define "ix.v1.common.names.name" -}} {{- $globalNameOverride := "" -}} {{- if hasKey .Values "global" -}} @@ -17,9 +15,7 @@ Expand ther name of the chart {{- default .Chart.Name (default .Values.nameOverride $globalNameOverride) | trunc 63 | trimSuffix "-" -}} {{- end -}} -{{/* -Create a default fully qualified app name. -*/}} +{{/* Create a default fully qualified app name. */}} {{- define "ix.v1.common.names.fullname" -}} {{- $name := include "ix.v1.common.names.name" . -}} {{- $globalFullNameOverride := "" -}} @@ -43,24 +39,17 @@ Create a default fully qualified app name. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} -{{/* -Create the "name" + "." + "namespace" fqdn -*/}} +{{/* Create the "name" + "." + "namespace" fqdn */}} {{- define "ix.v1.common.names.fqdn" -}} {{- printf "%s.%s" (include "ix.v1.common.names.fullname" .) .Release.Namespace | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} -{{/* -Create the "fqdn" + "." + "svc.cluster.local" -*/}} +{{/* Create the "fqdn" + "." + "svc.cluster.local" */}} {{- define "ix.v1.common.names.fqdn.cluster" -}} {{- printf "%s.%s" (include "ix.v1.common.names.fqdn" .) "svc.cluster.local" -}} {{- end -}} -{{/* -TODO: See if it's needed -Return the properly cased version of the controller type -*/}} +{{/* Return the properly cased version of the controller type */}} {{- define "ix.v1.common.names.controllerType" -}} {{- if eq (.Values.controller.type | lower) "deployment" -}} {{- print "Deployment" -}} diff --git a/library/common/1.0.0/templates/lib/controller/_container.tpl b/library/common/1.0.0/templates/lib/controller/_container.tpl new file mode 100644 index 00000000..40d3856d --- /dev/null +++ b/library/common/1.0.0/templates/lib/controller/_container.tpl @@ -0,0 +1,40 @@ +{{/* The main container included in the controller */}} +{{- define "ix.v1.common.controller.mainContainer" -}} +- name: {{ include "ix.v1.common.names.fullname" . }} + image: TODO:!! + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- with .Values.command }} + command: + {{- if kindIs "string" . }} + - {{ tpl . $ }} + {{- else }} + {{- tpl ( toYaml . ) $ | nindent 4 }} + {{- end }} + {{- end }} + {{- if or (.Values.extraArgs) (.Values.args) }} + args: + {{/* args usually defined while developing the chart */}} + {{- with .Values.args }} + {{- if kindIs "string" . }} + - {{ tpl . $ }} + {{- else }} + {{- tpl ( toYaml . ) $ | nindent 4 }} + {{- end }} + {{- end }} + {{/* extraArgs used in cases that users wants to APPEND to args */}} + {{- with .Values.extraArgs }} + {{- if kindIs "string" . }} + - {{ tpl . $ }} + {{- else }} + {{- tpl ( toYaml . ) $ | nindent 4 }} + {{- end }} + {{- end }} + {{- end }} + {{- with .Values.tty }} + tty: {{ . }} + {{- end }} + {{- with .Values.stdin }} + stdin: {{ . }} + {{- end }} + +{{- end -}} diff --git a/library/common/1.0.0/templates/lib/controller/_pod.tpl b/library/common/1.0.0/templates/lib/controller/_pod.tpl index ab7e0ccc..87ecbb45 100644 --- a/library/common/1.0.0/templates/lib/controller/_pod.tpl +++ b/library/common/1.0.0/templates/lib/controller/_pod.tpl @@ -1,9 +1,9 @@ -{{/* -The pod definition included in the controller. -*/}} +{{/* The pod definition included in the controller. */}} {{- define "ix.v1.common.controller.pod" -}} - {{- with (include "ix.v1.common.controller.volumes" . | trim) }} +containers: + {{- include "ix.v1.common.controller.mainContainer" . | nindent 2 }} +{{- with (include "ix.v1.common.controller.volumes" . | trim) }} volumes: {{- . | nindent 2 }} - {{- end }} +{{- end }} {{- end -}} diff --git a/library/common/1.0.0/templates/lib/controller/_ports.tpl b/library/common/1.0.0/templates/lib/controller/_ports.tpl index 1b2d1daf..df1be024 100644 --- a/library/common/1.0.0/templates/lib/controller/_ports.tpl +++ b/library/common/1.0.0/templates/lib/controller/_ports.tpl @@ -1,6 +1,4 @@ -{{/* -Ports included by the controller. -*/}} +{{/* Ports included by the controller. */}} {{- define "ix.v1.common.controller.ports" -}} {{ $ports := list }} {{- range .Values.service -}} @@ -12,9 +10,7 @@ Ports included by the controller. {{- end -}} {{- end -}} -{{/* -Render the list of ports -*/}} +{{/* Render the list of ports */}} {{- if $ports -}} {{- range $_ := $ports }} {{- if .enabled }} @@ -27,6 +23,9 @@ Render the list of ports This is for cases where port (that container listens) can be dynamically configured via an env var. */}} + {{- if not .port }} + {{- fail (printf "Port is required on enabled services. Service: (%s)" .name) }} + {{- end }} containerPort: {{ default .port .targetPort }} {{- with .protocol }} {{- if or (eq (. | upper) "HTTP") (eq (. | upper) "HTTPS") (eq (. | upper) "TCP") }} diff --git a/library/common/1.0.0/templates/lib/controller/_probes.tpl b/library/common/1.0.0/templates/lib/controller/_probes.tpl index 710639ab..e6089bc7 100644 --- a/library/common/1.0.0/templates/lib/controller/_probes.tpl +++ b/library/common/1.0.0/templates/lib/controller/_probes.tpl @@ -1,6 +1,4 @@ -{{/* -Probes selection logic. -*/}} +{{/* Probes selection logic. */}} {{- define "ix.v1.common.controller.probes" -}} {{- end -}} diff --git a/library/common/1.0.0/templates/lib/controller/_volumes.tpl b/library/common/1.0.0/templates/lib/controller/_volumes.tpl index 6c4cdb5b..5bb86e25 100644 --- a/library/common/1.0.0/templates/lib/controller/_volumes.tpl +++ b/library/common/1.0.0/templates/lib/controller/_volumes.tpl @@ -1,6 +1,4 @@ -{{/* -Volumes included by the controller. -*/}} +{{/* Volumes included by the controller. */}} {{- define "ix.v1.common.controller.volumes" -}} {{- $persistenceDefault := "pvc" -}} {{- range $index, $persistence := .Values.persistence }} diff --git a/library/common/1.0.0/templates/pods/_deployment.tpl b/library/common/1.0.0/templates/pods/_deployment.tpl index 2bff04bd..b9f1b6dc 100644 --- a/library/common/1.0.0/templates/pods/_deployment.tpl +++ b/library/common/1.0.0/templates/pods/_deployment.tpl @@ -46,7 +46,7 @@ spec: labels: {{- include "ix.v1.common.labels.selectorLabels" . | nindent 8 }} {{- with .Values.podLabels }} - {{- tpl (toYaml .) $ | nindent 8 }} + {{- tpl (toYaml .) $ | nindent 8 }} {{- end }} spec: blabla: diff --git a/library/common/1.0.0/values.yaml b/library/common/1.0.0/values.yaml index 4c875d14..d99afca8 100644 --- a/library/common/1.0.0/values.yaml +++ b/library/common/1.0.0/values.yaml @@ -19,6 +19,27 @@ ixExternalInterfacesConfigurationNames: [] # - interface1 # - interface2 +image: + # -- Image repository + repository: + # -- Image tag + tag: + # -- Image pull policy + pullPolicy: IfNotPresent + +# -- Override the args for the default container +args: [] + +# -- Add args in addition to the arguments set by default. +# Primarily for the SCALE GUI +extraArgs: [] + +# -- Determines whether containers in a pod runs with TTY enabled. +tty: false + +# -- Determines whether containers in a pod runs with stdin enabled. +stdin: false + controller: # -- Enable the controller. enabled: true