Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring redis options #728

Merged
merged 5 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{% set command = @('services.redis-session.options')
| filter(v => v is not empty)
| map((value, var) => '--' ~ var ~ ' ' ~ value|join(' --' ~ var ~ ' '))
| reduce((carry, v) => carry|merge([v]), []) %}
redis-session:
image: {{ @('services.redis-session.image') }}
# 1GB; evict key that would expire soonest
command: redis-server --maxmemory 1073742000 --maxmemory-policy volatile-ttl --save 3600 1 --save 300 100 --save 60 10000
command: {{ to_nice_yaml(command, 2, 6) }}
labels:
# deprecated, a later workspace release will disable by default
- traefik.enable=false
Expand Down
7 changes: 5 additions & 2 deletions src/_base/_twig/docker-compose.yml/service/redis.yml.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{% set command = @('services.redis.options')
| filter(v => v is not empty)
| map((value, var) => '--' ~ var ~ ' ' ~ value|join(' --' ~ var ~ ' '))
| reduce((carry, v) => carry|merge([v]), []) %}
redis:
image: {{ @('services.redis.image') }}
# 1GB; evict any least recently used key even if they don't have a TTL
command: redis-server --maxmemory 1073742000 --maxmemory-policy allkeys-lru --save 3600 1 --save 300 100 --save 60 10000
command: {{ to_nice_yaml(command, 2, 6) }}
labels:
# deprecated, a later workspace release will disable by default
- traefik.enable=false
Expand Down
46 changes: 34 additions & 12 deletions src/_base/harness/attributes/docker-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,39 @@ attributes:
resources:
memory: "1024Mi"
redis:
enabled: "= 'redis' in @('app.services')"
image: redis:5-alpine
image: redis:6-alpine
options:
# Handle many smaller keys
activedefrag: 'yes'
# 1Gi - 1024*1024*1024 bytes
maxmemory: '1073741824'
# Evict any least recently used key even if they don't have a TTL
maxmemory-policy: allkeys-lru
# Save snapshots every X changes have happened within Y seconds (these are the defaults in redis.conf)
save:
- 3600 1
- 300 100
- 60 10000
resources:
memory: "256Mi"
# 1.5 * maxmemory to allow copy on write snapshots
memory: "1.5Gi"
redis-session:
enabled: "= 'redis-session' in @('app.services')"
image: redis:5-alpine
image: redis:6-alpine
options:
# Handle many smaller keys
activedefrag: 'yes'
# 1Gi - 1024*1024*1024 bytes
maxmemory: '1073741824'
# Evict key that would expire soonest
maxmemory-policy: volatile-ttl
# Save snapshots every X changes have happened within Y seconds (these are the defaults in redis.conf)
save:
- 3600 1
- 300 100
- 60 10000
resources:
memory: "1024Mi"
# 1.5 * maxmemory to allow copy on write snapshots
memory: "1.5Gi"
relay:
enabled: true
publish: false
Expand Down Expand Up @@ -221,6 +245,10 @@ attributes:
VARNISH_HOSTNAME_TEMPLATE: "{{ .Values.resourcePrefix }}varnish-%d.{{ .Values.resourcePrefix }}varnish-headless"
mysql:
options: = @('services.mysql.options')
redis:
options: = @('services.redis.options')
redis-session:
options: = @('services.redis-session.options')
console:
environment:
TIDEWAYS_ENABLED: "= @('php.ext-tideways.cli.enable') ? '{{ .Values.services.tideways.enabled }}' : 'false'"
Expand Down Expand Up @@ -293,9 +321,3 @@ attributes:
php-fpm-exporter:
resources:
memory: "32Mi"
redis:
resources:
memory: "64Mi"
redis-session:
resources:
memory: "64Mi"
27 changes: 12 additions & 15 deletions src/_base/helm/app/templates/service/redis-session/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,18 @@ spec:
app.service: {{ $.Values.resourcePrefix }}redis-session
spec:
containers:
- args:
- redis-server
- --maxmemory
- "1073742000"
- --maxmemory-policy
- volatile-ttl
- --save
- "3600"
- "1"
- --save
- "300"
- "100"
- --save
- "60"
- "10000"
- {{- if .options }}
args:
{{- range $var, $value := .options }}
{{- if and $value (kindIs "slice" $value) }}
{{- range $arrayValue := $value }}
- {{ print "--" $var " " $arrayValue | quote }}
{{- end }}
{{- else if $value }}
- {{ print "--" $var " " $value | quote }}
{{- end }}
{{- end }}
{{- end }}
image: {{ .image | quote }}
imagePullPolicy: Always
name: redis-session
Expand Down
27 changes: 12 additions & 15 deletions src/_base/helm/app/templates/service/redis/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,18 @@ spec:
app.service: {{ $.Values.resourcePrefix }}redis
spec:
containers:
- args:
- redis-server
- --maxmemory
- "1073742000"
- --maxmemory-policy
- allkeys-lru
- --save
- "3600"
- "1"
- --save
- "300"
- "100"
- --save
- "60"
- "10000"
- {{- if .options }}
args:
{{- range $var, $value := .options }}
{{- if and $value (kindIs "slice" $value) }}
{{- range $arrayValue := $value }}
- {{ print "--" $var " " $arrayValue | quote }}
{{- end }}
{{- else if $value }}
- {{ print "--" $var " " $value | quote }}
{{- end }}
{{- end }}
{{- end }}
image: {{ .image | quote }}
imagePullPolicy: Always
name: redis
Expand Down