Add probes

This commit is contained in:
Nikolai Rodionov 2024-05-26 13:02:04 +02:00
parent 8958c9e2e0
commit b76da1c101
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
3 changed files with 45 additions and 18 deletions

View File

@ -2,7 +2,7 @@ apiVersion: v2
name: softplayer-lib-workload
description: A library to be reused accross softplayer charts
type: library
version: 0.1.7
version: 0.1.8
maintainers:
- name: allanger
email: allanger@badhouseplants.net

View File

@ -3,15 +3,8 @@
{{ fail ".Values.workload.containers can not be empty (heler.deployment.containers)" }}
{{- end -}} {{- /* /(1) */ -}}
containers:
{{- range $k,$v := .Values.workload.containers }} {{- /* (1) */}}
- name: {{ $k }}
{{- include "helper.workload.containerSecurityContext" . | nindent 4 -}}
{{- include "helper.workload.image" (dict "Chart" $.Chart "Image" .image) | indent 4 -}}
{{- include "helper.container.command" $v | nindent 4 -}}
{{- include "helper.container.args" $v | nindent 4 -}}
{{- include "helper.container.ports" (dict "Context" $ "Container" $v) | nindent 4 -}}
{{- include "helper.container.volumeMounts" $v | nindent 4 -}}
{{- include "helper.container.envFrom" (dict "Context" $ "Container" $v) | nindent 4 -}}
{{- range $k, $v := .Values.workload.containers }} {{- /* (1) */}}
{{ include "helper.deployment.container" (dict "Context" $ "ContainerName" $k "ContainerData" $v) | indent 2}}
{{- end }} {{- /* /(1) */}}
{{- end -}} {{- /* /(define) */ -}}
@ -19,20 +12,24 @@ containers:
{{- if .Values.workload.initContainers -}} {{- /* (1) */ -}}
initContainers:
{{- range $k,$v := .Values.workload.initContainers }} {{- /* (2) */}}
- name: {{ $k }}
{{- include "helper.workload.containerSecurityContext" . | nindent 4 -}}
{{- include "helper.workload.image" (dict "Chart" $.Chart "Image" .image) | indent 4 -}}
{{- include "helper.container.command" $v | nindent 4 -}}
{{- include "helper.container.args" $v | nindent 4 -}}
{{- include "helper.container.ports" (dict "Context" $ "Container" $v) | nindent 4 -}}
{{- include "helper.container.volumeMounts" $v | nindent 4 -}}
{{- include "helper.container.envFrom" (dict "Context" $ "Container" $v) | nindent 4 -}}
{{ include "helper.deployment.container" (dict "Context" $ "ContainerName" $k "ContainerData" $v) | indent 2}}
{{- end }} {{- /* /(1) */}}
{{- end -}} {{- /* /(2) */ -}}
{{- end -}} {{- /* /(define) */ -}}
{{- define "helper.deployment.container" -}} {{- /* (define) */ -}}
- name: {{ .ContainerName }}
{{- include "helper.workload.containerSecurityContext" .ContainerData | nindent 2 -}}
{{- include "helper.workload.image" (dict "Chart" .Context.Chart "Image" .ContainerData.image) | indent 2 -}}
{{- include "helper.container.command" .ContainerData | nindent 2 -}}
{{- include "helper.container.args" .ContainerData | nindent 2 -}}
{{- include "helper.container.ports" (dict "Context" .Context "Container" .ContainerData) | nindent 2 -}}
{{- include "helper.container.volumeMounts" .ContainerData | nindent 2 -}}
{{- include "helper.container.envFrom" (dict "Context" .Context "Container" .ContainerData) | nindent 2 -}}
{{- include "helper.container.livenessProbe" .ContainerData | nindent 2 -}}
{{- include "helper.container.readinessProbe" .ContainerData | nindent 2 -}}
{{- include "helper.container.startupProbe" .ContainerData | nindent 2 -}}
{{- end -}} {{- /* /(define) */ -}}
{{- define "helper.container.command" -}} {{- /* (define) */ -}}
@ -118,3 +115,25 @@ envFrom:
{{- end -}} {{- /* /(2) */ -}}
{{- end -}} {{- /* /(1) */ -}}
{{- end -}} {{- /* /(define) */ -}}
{{- /* Probes */ -}}
{{- define "helper.container.readinessProbe" -}} {{- /* (define) */ -}}
{{- if .readinessProbe }} {{- /* (1) */}}
readinessProbe:
{{ .readinessProbe | toYaml | indent 2 }}
{{- end }} {{- /* /(0) */}}
{{- end -}} {{- /* /(define) */ -}}
{{- define "helper.container.livenessProbe" -}} {{- /* (define) */ -}}
{{- if .livenessProbe }} {{- /* (1) */}}
livenessProbe:
{{ .livenessProbe | toYaml | indent 2 }}
{{- end }} {{- /* /(0) */}}
{{- end -}} {{- /* /(define) */ -}}
{{- define "helper.container.startupProbe" -}} {{- /* (define) */ -}}
{{- if .startupProbe }} {{- /* (1) */}}
startupProbe:
{{ .startupProbe | toYaml | indent 2 }}
{{- end }} {{- /* /(0) */}}
{{- end -}} {{- /* /(define) */ -}}

View File

@ -0,0 +1,8 @@
{{- define "lib.raw" -}}
{{- if $.Values.raw -}}
{{- range $.Values.raw }}
---{{- (tpl . $) | nindent 0 }}
{{- end }}
{{- end -}}
{{- end -}}