From 987d1085e1ae3e8ad2cfd7fa63c246d90a674c0e Mon Sep 17 00:00:00 2001 From: James Halsall Date: Mon, 24 Feb 2020 15:19:49 +0000 Subject: [PATCH] Make liveness/readiness probes configurable (#26) --- .editorconfig | 4 ++++ helm/app/_twig/values.yaml/additional.yml.twig | 0 helm/app/templates/_container-ports.tpl | 3 +++ helm/app/templates/_probes.tpl | 12 ++++++++++++ helm/app/templates/application/app/deployment.yaml | 8 ++------ helm/app/values.yaml.twig | 2 ++ 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 helm/app/_twig/values.yaml/additional.yml.twig create mode 100644 helm/app/templates/_container-ports.tpl create mode 100644 helm/app/templates/_probes.tpl diff --git a/.editorconfig b/.editorconfig index 5b462cc..775433f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,3 +2,7 @@ root = true [*] insert_final_newline = true + +[{*.yml,*.yaml,*.yml.twig,*.yaml.twig}] +indent_style = space +indent_size = 2 diff --git a/helm/app/_twig/values.yaml/additional.yml.twig b/helm/app/_twig/values.yaml/additional.yml.twig new file mode 100644 index 0000000..e69de29 diff --git a/helm/app/templates/_container-ports.tpl b/helm/app/templates/_container-ports.tpl new file mode 100644 index 0000000..b1a06ea --- /dev/null +++ b/helm/app/templates/_container-ports.tpl @@ -0,0 +1,3 @@ +{{- define "container.ports" }} + - containerPort: {{ .Values.default_port.port }} +{{- end }} diff --git a/helm/app/templates/_probes.tpl b/helm/app/templates/_probes.tpl new file mode 100644 index 0000000..cdcb06e --- /dev/null +++ b/helm/app/templates/_probes.tpl @@ -0,0 +1,12 @@ +{{- define "probes" }} +readinessProbe: + tcpSocket: + port: {{ .Values.health_port }} + initialDelaySeconds: 5 + periodSeconds: 10 +livenessProbe: + tcpSocket: + port: {{ .Values.health_port }} + initialDelaySeconds: 10 + periodSeconds: 10 +{{- end }} diff --git a/helm/app/templates/application/app/deployment.yaml b/helm/app/templates/application/app/deployment.yaml index 9e89469..96177ca 100644 --- a/helm/app/templates/application/app/deployment.yaml +++ b/helm/app/templates/application/app/deployment.yaml @@ -27,13 +27,9 @@ spec: imagePullPolicy: Always name: app ports: - - containerPort: {{ .Values.default_port.port }} + {{- include "container.ports" . | indent 8 }} resources: {} - readinessProbe: - tcpSocket: - port: {{ .Values.health_port }} - initialDelaySeconds: 5 - periodSeconds: 10 + {{- include "probes" . | indent 8 }} imagePullSecrets: - name: {{ .Values.resourcePrefix }}docker-config restartPolicy: Always diff --git a/helm/app/values.yaml.twig b/helm/app/values.yaml.twig index c8b5fc5..0bc8ab3 100644 --- a/helm/app/values.yaml.twig +++ b/helm/app/values.yaml.twig @@ -26,3 +26,5 @@ health_port: {{ @('app.health_port') }} ingress: {{ to_yaml(@('app.ingress'), 2, 2) | raw }} resourcePrefix: {{ @('pipeline.base.resourcePrefix') | json_encode | raw }} + +{% include blocks ~ 'additional.yml.twig' %}