Skip to content

Commit 0a7db6d

Browse files
Feature/nginx cron (#436)
* nginx, cronjob tweaks, version dependant hpa
1 parent ae85420 commit 0a7db6d

File tree

6 files changed

+40
-5
lines changed

6 files changed

+40
-5
lines changed

charts/drupal/templates/_helpers.tpl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,20 @@ set -e
548548
if [ -f /lagoon/entrypoints.sh ] ; then /lagoon/entrypoints.sh ; fi
549549

550550
{{- end }}
551+
552+
553+
{{- define "drupal.cron.api-version" }}
554+
{{- if semverCompare ">=1.21" .Capabilities.KubeVersion.Version }}
555+
batch/v1
556+
{{- else }}
557+
batch/v1beta1
558+
{{- end }}
559+
{{- end }}
560+
561+
{{- define "drupal.autoscaling.api-version" }}
562+
{{- if semverCompare ">=1.23" .Capabilities.KubeVersion.Version }}
563+
autoscaling/v2
564+
{{- else }}
565+
autoscaling/v2beta1
566+
{{- end }}
567+
{{- end }}

charts/drupal/templates/backup-cron.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- if .Values.backup.enabled }}
22
{{- $db_password := randAlphaNum 20 }}
33
{{- $params := dict "db_password" $db_password -}}
4-
apiVersion: batch/v1beta1
4+
apiVersion: {{ include "drupal.cron.api-version" $ | trim }}
55
kind: CronJob
66
metadata:
77
name: {{ .Release.Name }}-backup

charts/drupal/templates/drupal-configmap.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,11 @@ data:
463463
expires 365d;
464464
add_header Cache-Control "public";
465465
## Set the OS file cache.
466-
open_file_cache max=10000 inactive=120s;
466+
{{- if .Values.nginx.open_file_cache.enabled }}
467+
open_file_cache max={{ .Values.nginx.open_file_cache.max }} inactive={{ .Values.nginx.open_file_cache.inactive }};
468+
{{- else }}
469+
open_file_cache off;
470+
{{- end }}
467471
open_file_cache_valid 45s;
468472
open_file_cache_min_uses 2;
469473
open_file_cache_errors off;
@@ -485,7 +489,11 @@ data:
485489
expires 365d;
486490
add_header Cache-Control "public";
487491
## Set the OS file cache.
488-
open_file_cache max=10000 inactive=120s;
492+
{{- if .Values.nginx.open_file_cache.enabled }}
493+
open_file_cache max={{ .Values.nginx.open_file_cache.max }} inactive={{ .Values.nginx.open_file_cache.inactive }};
494+
{{- else }}
495+
open_file_cache off;
496+
{{- end }}
489497
open_file_cache_valid 45s;
490498
open_file_cache_min_uses 2;
491499
open_file_cache_errors off;

charts/drupal/templates/drupal-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ spec:
148148
- drupal
149149
---
150150
{{- if .Values.autoscaling.enabled }}
151-
apiVersion: autoscaling/v2beta1
151+
apiVersion: {{ include "drupal.autoscaling.api-version" . | trim }}
152152
kind: HorizontalPodAutoscaler
153153
metadata:
154154
name: {{ .Release.Name }}-drupal

charts/drupal/templates/reference-data-cron.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- if .Values.referenceData.enabled }}
22
{{- if eq .Values.referenceData.referenceEnvironment .Values.environmentName }}
3-
apiVersion: batch/v1beta1
3+
apiVersion: {{ include "drupal.cron.api-version" . | trim }}
44
kind: CronJob
55
metadata:
66
name: {{ .Release.Name }}-refdata

charts/drupal/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ nginx:
137137
requests:
138138
cpu: 1m
139139
memory: 10M
140+
limits:
141+
cpu: 500m
142+
memory: 250M
140143

141144
# Set of values to enable and use http basic authentication
142145
# It is implemented only for very basic protection (like web crawlers)
@@ -197,6 +200,13 @@ nginx:
197200
# Extra configuration to pass to nginx as a file
198201
extraConfig: |
199202
203+
# Toggle open_files_cache.
204+
# Naming follows https://nginx.org/en/docs/http/ngx_http_core_module.html#open_file_cache directive
205+
open_file_cache:
206+
enabled: true
207+
max: 6000
208+
inactive: 120s
209+
200210
# Configuration for everything that runs in php containers.
201211
php:
202212
# The docker image to be used. This is typically passed by your CI system using the --set parameter.

0 commit comments

Comments
 (0)