Skip to content

Commit

Permalink
feat: add possibility to overide probe (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe-vandermoere committed Jan 2, 2021
1 parent bd4dbd3 commit afc50a9
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/symfony/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ sources:
- https://hub.docker.com/_/nginx
- https://github.com/symfony/symfony
type: application
version: 1.0.0
version: 1.1.0
4 changes: 4 additions & 0 deletions charts/symfony/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@ The following tables lists the configurable parameters of the symfony chart, and
| web.nginx.image.pullPolicy | Nginx image pull policy | string | `"IfNotPresent"` |
| web.nginx.config | Nginx configuration | | Check `values.yaml` file |
| web.nginx.livenessProbe | Nginx liveness probe | | Check `values.yaml` file |
| web.nginx.customLivenessProbe | Override default Nginx liveness probe | object | nil |
| web.nginx.readinessProbe | Nginx readiness probe | | Check `values.yaml` file |
| web.nginx.customReadinessProbe | Override default Nginx readiness probe | object | nil |
| web.nginx.resources.requests | The requested resources for the NGINX container | object | `{}` |
| web.nginx.resources.limits | The resources limits for the NGINX container | object | `{}` |
| web.phpfpm.image.repository | PHP-FPM image repository (override global PHP image) | string | |
| web.phpfpm.image.tag | PHP-FPM image tag (override global PHP image) | string | |
| web.phpfpm.image.pullPolicy | PHP-FPM image pull policy (override global PHP image) | string | |
| web.phpfpm.env | PHP-FPM environment variables (override global environment variables) | object | `{}` |
| web.phpfpm.livenessProbe.enabled | PHP-FPM liveness probe | | Check `values.yaml` file |
| web.phpfpm.customLivenessProbe | Override default PHP-FPM liveness probe | object | nil |
| web.phpfpm.readinessProbe | PHP-FPM readiness probe | | Check `values.yaml` file |
| web.phpfpm.customReadinessProbe | Override default PHP-FPM readiness probe | object | nil |
| web.phpfpm.resources.requests | The requested resources for the PHP-FPM container | object | `{}` |
| web.phpfpm.resources.limits | The resources limits for the PHP-FPM container | object | `{}` |

Expand Down
17 changes: 17 additions & 0 deletions charts/symfony/ci/custom-probe-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
web:
nginx:
customLivenessProbe: |-
httpGet:
port: {{ .Values.web.nginx.port }}
path: /healthz
customReadinessProbe: |-
httpGet:
port: {{ .Values.web.nginx.port }}
path: /healthz
phpfpm:
customLivenessProbe:
tcpSocket:
port: 9000
customReadinessProbe:
exec:
command: [ls]
5 changes: 0 additions & 5 deletions charts/symfony/ci/nginx-values.yaml

This file was deleted.

13 changes: 13 additions & 0 deletions charts/symfony/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,16 @@ Generate secret for environment variables
{{ $key }}: {{ $value | b64enc | quote }}
{{- end }}
{{- end -}}

{{/*
Renders a value that contains template.
Usage:
{{ include "symfony.tplvalues.render" ( dict "value" .Values.path.to.the.Value "global" $) }}
*/}}
{{- define "symfony.tplvalues.render" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .global }}
{{- else }}
{{- tpl (.value | toYaml) .global }}
{{- end }}
{{- end -}}
4 changes: 2 additions & 2 deletions charts/symfony/templates/web/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ metadata:
app.kubernetes.io/component: web
data:
{{- if .Values.web.nginx.config.main }}
nginx.conf: {{ .Values.web.nginx.config.main | indent 4 }}
nginx.conf: {{- include "symfony.tplvalues.render" (dict "value" .Values.web.nginx.config.main "global" .) | nindent 4 }}
{{- end }}
{{- if .Values.web.nginx.config.serverBlock }}
default.conf: {{ .Values.web.nginx.config.serverBlock | indent 4 }}
default.conf: {{- include "symfony.tplvalues.render" (dict "value" .Values.web.nginx.config.serverBlock "global" .) | nindent 4 }}
{{- end }}
{{- end }}
19 changes: 18 additions & 1 deletion charts/symfony/templates/web/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@ spec:
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
{{- end }}
{{- if .Values.web.nginx.customLivenessProbe }}
livenessProbe: {{- include "symfony.tplvalues.render" (dict "value" .Values.web.nginx.customLivenessProbe "global" .) | nindent 12 }}
{{- else }}
livenessProbe:
tcpSocket:
httpGet:
port: {{ .Values.web.nginx.port }}
path: /healthz
periodSeconds: {{ .Values.web.nginx.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.web.nginx.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.web.nginx.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.web.nginx.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.web.nginx.customReadinessProbe }}
readinessProbe: {{- include "symfony.tplvalues.render" (dict "value" .Values.web.nginx.customReadinessProbe "global" .) | nindent 12 }}
{{- else }}
readinessProbe:
tcpSocket:
port: {{ .Values.web.nginx.port }}
Expand All @@ -55,6 +63,7 @@ spec:
timeoutSeconds: {{ .Values.web.nginx.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.web.nginx.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.web.nginx.readinessProbe.failureThreshold }}
{{- end }}
resources: {{- toYaml .Values.web.nginx.resources | nindent 12 }}
- name: phpfpm
{{- if and .Values.web.phpfpm.image }}
Expand All @@ -67,6 +76,9 @@ spec:
envFrom:
- secretRef:
name: {{ include "symfony.fullname" . }}-web
{{- if .Values.web.phpfpm.customLivenessProbe }}
livenessProbe: {{- include "symfony.tplvalues.render" (dict "value" .Values.web.phpfpm.customLivenessProbe "global" .) | nindent 12 }}
{{- else }}
livenessProbe:
tcpSocket:
port: 9000
Expand All @@ -75,6 +87,10 @@ spec:
timeoutSeconds: {{ .Values.web.phpfpm.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.web.phpfpm.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.web.phpfpm.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.web.phpfpm.customReadinessProbe }}
readinessProbe: {{- include "symfony.tplvalues.render" (dict "value" .Values.web.phpfpm.customReadinessProbe "global" .) | nindent 12 }}
{{- else }}
readinessProbe:
tcpSocket:
port: 9000
Expand All @@ -83,6 +99,7 @@ spec:
timeoutSeconds: {{ .Values.web.phpfpm.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.web.phpfpm.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.web.phpfpm.readinessProbe.failureThreshold }}
{{- end }}
resources: {{- toYaml .Values.web.phpfpm.resources | nindent 12 }}
{{- if .Values.metrics.enabled }}
- name: nginx-metrics
Expand Down
24 changes: 24 additions & 0 deletions charts/symfony/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,21 @@
"livenessProbe": {
"$ref": "#/definitions/probe"
},
"customLivenessProbe": {
"oneOf": [
{"type": "string"},
{"type": "object"}
]
},
"readinessProbe": {
"$ref": "#/definitions/probe"
},
"customReadinessProbe": {
"oneOf": [
{"type": "string"},
{"type": "object"}
]
},
"resources": {
"$ref": "#/definitions/resources"
}
Expand All @@ -102,9 +114,21 @@
"livenessProbe": {
"$ref": "#/definitions/probe"
},
"customLivenessProbe": {
"oneOf": [
{"type": "string"},
{"type": "object"}
]
},
"readinessProbe": {
"$ref": "#/definitions/probe"
},
"customReadinessProbe": {
"oneOf": [
{"type": "string"},
{"type": "object"}
]
},
"resources": {
"$ref": "#/definitions/resources"
}
Expand Down
7 changes: 7 additions & 0 deletions charts/symfony/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ web:
serverBlock: |-
server {
listen {{ .Values.web.nginx.port }};
root /var/www/html/public;
add_header X-Request-Id $request_uid;
Expand All @@ -91,6 +93,11 @@ web:
return 404;
}
location /healthz {
access_log off;
return 200;
}
location /status {
access_log off;
stub_status on;
Expand Down

0 comments on commit afc50a9

Please sign in to comment.