Skip to content

Commit

Permalink
Fix tmp volume mounts not being consistent (#68)
Browse files Browse the repository at this point in the history
* Fix tmp volume mounts not being consistent

* Fix falseness check in template

* Use configurable tmpVolumeSize

* It appears we need to compare to strings
  • Loading branch information
oliverguenther authored Jan 9, 2024
1 parent 7355cbd commit ab8b83d
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 70 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-swans-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openproject/helm-charts": minor
---

Fix tmp volume mounts not being consistent
41 changes: 39 additions & 2 deletions charts/openproject/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,47 @@ securityContext:
{{- end }}
{{- end }}


{{- define "openproject.useTmpVolumes" -}}
{{- if (default .Values.useTmpVolumes (not .Values.develop)) -}}
{{- true -}}
{{- if ne .Values.openproject.useTmpVolumes nil -}}
{{- .Values.openproject.useTmpVolumes -}}
{{- else -}}
{{- (not .Values.develop) -}}
{{- end -}}
{{- end -}}

{{- define "openproject.tmpVolumeMounts" -}}
{{- if eq (include "openproject.useTmpVolumes" .) "true" }}
- mountPath: /tmp
name: tmp
- mountPath: /app/tmp
name: app-tmp
{{- end }}
{{- end -}}

{{- define "openproject.tmpVolumeSpec" -}}
{{- if eq (include "openproject.useTmpVolumes" .) "true" }}
- name: tmp
# we can't use emptyDir due to the sticky bit issue
# see: https://github.com/kubernetes/kubernetes/issues/110835
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.openproject.tmpVolumesStorage }}
- name: app-tmp
# we can't use emptyDir due to the sticky bit / world writable issue
# see: https://github.com/kubernetes/kubernetes/issues/110835
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.openproject.tmpVolumesStorage }}
{{- end }}
{{- end -}}

{{- define "openproject.envFrom" -}}
Expand Down
18 changes: 2 additions & 16 deletions charts/openproject/templates/seeder-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,7 @@ spec:
{{ toYaml . | nindent 8 | trim }}
{{- end }}
volumes:
{{- if (include "openproject.useTmpVolumes" .) }}
- name: tmp
# we can't use emptyDir due to the sticky bit issue
# see: https://github.com/kubernetes/kubernetes/issues/110835
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
{{- end }}
{{- include "openproject.tmpVolumeSpec" . | indent 8 }}
{{- if .Values.persistence.enabled }}
- name: "data"
persistentVolumeClaim:
Expand Down Expand Up @@ -67,10 +56,7 @@ spec:
{{- include "openproject.envFrom" . | nindent 10 }}
{{- include "openproject.env" . | nindent 10 }}
volumeMounts:
{{- if (include "openproject.useTmpVolumes" .) }}
- mountPath: /tmp
name: tmp
{{- end }}
{{- include "openproject.tmpVolumeMounts" . | indent 12 }}
{{- if .Values.persistence.enabled }}
- name: "data"
mountPath: "/var/openproject/assets"
Expand Down
30 changes: 2 additions & 28 deletions charts/openproject/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,7 @@ spec:
{{- include "openproject.podSecurityContext" . | indent 6 }}
serviceAccountName: {{ include "common.names.fullname" . }}
volumes:
{{- if (include "openproject.useTmpVolumes" .) }}
- name: tmp
# we can't use emptyDir due to the sticky bit issue
# see: https://github.com/kubernetes/kubernetes/issues/110835
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
- name: app-tmp
# we can't use emptyDir due to the sticky bit / world writable issue
# see: https://github.com/kubernetes/kubernetes/issues/110835
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
{{- end }}
{{- include "openproject.tmpVolumeSpec" . | indent 8 }}
{{- if .Values.egress.tls.rootCA.fileName }}
- name: ca-pemstore
configMap:
Expand Down Expand Up @@ -96,12 +75,7 @@ spec:
{{- include "openproject.envFrom" . | nindent 10 }}
{{- include "openproject.env" . | nindent 10 }}
volumeMounts:
{{- if (include "openproject.useTmpVolumes" .) }}
- mountPath: /tmp
name: tmp
- mountPath: /app/tmp
name: app-tmp
{{- end }}
{{- include "openproject.tmpVolumeMounts" . | indent 12 }}
{{- if .Values.persistence.enabled }}
- name: "data"
mountPath: "/var/openproject/assets"
Expand Down
21 changes: 2 additions & 19 deletions charts/openproject/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,7 @@ spec:
{{- include "openproject.podSecurityContext" . | indent 6 }}
serviceAccountName: {{ include "common.names.fullname" . }}
volumes:
{{- if (include "openproject.useTmpVolumes" .) }}
- name: tmp
# we can't use emptyDir due to the sticky bit issue
# see: https://github.com/kubernetes/kubernetes/issues/110835
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
# the worker may need a lot of memory in case of big exports
# or backups
# @todo put this into a separate PVC per replica
storage: 5Gi
{{- end }}
{{- include "openproject.tmpVolumeSpec" . | indent 8 }}
{{- if .Values.egress.tls.rootCA.fileName }}
- name: ca-pemstore
configMap:
Expand Down Expand Up @@ -92,10 +78,7 @@ spec:
- bash
- /app/docker/prod/worker
volumeMounts:
{{- if (include "openproject.useTmpVolumes" .) }}
- mountPath: /tmp
name: tmp
{{- end }}
{{- include "openproject.tmpVolumeMounts" . | indent 12 }}
{{- if .Values.persistence.enabled }}
- name: "data"
mountPath: "/var/openproject/assets"
Expand Down
13 changes: 8 additions & 5 deletions charts/openproject/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@ openproject:
#
postgresStatementTimeout: 120s

## Whether or not to use ephemeral volumes for /app/tmp and /tmp.
## Falls back to a sensible default if undefined.
#
useTmpVolumes:

## customize the tmp storage mount sizes
tmpVolumesStorage: "5Gi"

## Whether to allocate persistent volume disk for the data directory.
## In case of node failure, the node data directory will still persist.
##
Expand Down Expand Up @@ -555,11 +563,6 @@ replicaCount: 1
#
backgroundReplicaCount: 1

## Whether or not to use ephemeral volumes for /app/tmp and /tmp.
## Falls back to a sensible default if undefined.
#
useTmpVolumes:

## Configure resource requests and limits.
##
## http://kubernetes.io/docs/user-guide/compute-resources/
Expand Down

0 comments on commit ab8b83d

Please sign in to comment.