Skip to content

Commit

Permalink
Split persistent volume claim creation from volume mounts to address #…
Browse files Browse the repository at this point in the history
  • Loading branch information
cfis committed Mar 10, 2025
1 parent 13dc666 commit 604d180
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 31 deletions.
21 changes: 20 additions & 1 deletion charts/docker-mailserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ If you do not enable the PROXY protocol and your mail server is not exposed usin

## Persistence

By default, the Chart creates four PersistentVolumeClaims. These are defined under the `persistence` key:
By default, the Chart assumes there are for Persistent volumes. Thus it requests four PersistentVolumeClaims which are defined using the `persistent_volume_claims` key. Each PVC can be set to an existing claim by settin the `persistent_volume_claims.<volume_name>.existing_claim` key or a new cliams. To disable creation of a PVC, set `persistent_volume_claims.<volume_name>.enabled` to false. The default PVCs have the following characteristics:

| PVC Name | Default Size | Mount | Description |
| ---------- | ------- | ----------------------- | -------------------------------------|
Expand All @@ -188,6 +188,25 @@ By default, the Chart creates four PersistentVolumeClaims. These are defined und
| mail-state | 1Gi | /var/mail-state | Stores [state](https://docker-mailserver.github.io/docker-mailserver/latest/faq/#what-about-the-docker-datadmsmail-state-directory) for mail services |
| mail-log | 1Gi | /var/log/mail | Stores log files |

The PVCs are then mounted to `volumeMounts` via the `persistence` key. Each `volumeMount` must specify a volume name and mount path. It is also possbile to set a subpath via the `subPath` key.

Extra volumes and volume mounts may be added using the `extraVolumes` and `extraVolumeMounts` keys.

## Upgrading to Version 5
Version 5.0 upgrades docker-mailserver to version 15. This version of the chart *does* include backwards incompatible changes

### PersistentVolumeClaims

Previously by default the Chart created four persistent volume claims and then mounted them to the container. This made it difficult for users that want to use just one Volume. Therefore the `persistence` key was spit into two keys:

* `persistent_volume_claims`
* `persistence`

This separate the creation of PVCs from mounting their associated volumes. If you previously overrode the creation of PVCs or their mount paths you will need to update your custom `values.yaml` file.

## Upgrading to Version 4
Version 4.0 upgrades docker-mailserver to version 14. There are no backwards incompatible changes in the chart.

## Upgrading to Version 3

Version 3.0 is not backwards compatible with previous versions. The biggest changes include:
Expand Down
12 changes: 5 additions & 7 deletions charts/docker-mailserver/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ spec:
{{- end }}

# PVCs
{{- range $name, $persistence := .Values.persistence }}
{{- if $persistence.enabled }}
{{- range $name, $pvc := .Values.persistent_volume_claims }}
{{- if $pvc.enabled }}
- name: {{ $name }}
persistentVolumeClaim:
{{- if $persistence.existingClaim}}
claimName: {{ $persistence.existingClaim }}
{{- if $pvc.existingClaim}}
claimName: {{ $pvc.existingClaim }}
{{ else }}
claimName: {{ template "dockermailserver.fullname" $ }}-{{ $name }}
{{ end }}
Expand Down Expand Up @@ -168,13 +168,11 @@ spec:

# Mount Volumes
{{- range $name, $persistence := .Values.persistence }}
{{- if $persistence.enabled }}
- name: {{ $name }}
- name: {{ $persistence.volumeName }}
mountPath: {{ $persistence.mountPath }}
{{- if $persistence.subPath }}
subPath: {{ $persistence.subPath }}
{{- end }}
{{- end }}
{{- end }}

# Mount Extra Volumes
Expand Down
20 changes: 10 additions & 10 deletions charts/docker-mailserver/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{{- range $name, $persistence := .Values.persistence -}}
{{- if and (not $persistence.existingClaim) ($persistence.enabled) }}
{{- range $name, $pvc := .Values.persistent_volume_claims -}}
{{- if and (not $pvc.existingClaim) ($pvc.enabled) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "dockermailserver.fullname" $ }}-{{ $name }}
{{- if $persistence.annotations }}
{{- if $pvc.annotations }}
annotations:
{{ toYaml $persistence.annotations | indent 2 }}
{{ toYaml $pvc.annotations }}
{{ end }}
spec:
accessModes:
{{ toYaml $persistence.accessModes | indent 2 }}
{{ toYaml $pvc.accessModes | indent 2 }}

{{- if $persistence.storageClass }}
storageClassName: {{ $persistence.storageClass | quote }}
{{- if $pvc.storageClass }}
storageClassName: {{ $pvc.storageClass | quote }}
{{- end }}
resources:
requests:
storage: {{ $persistence.size | quote }}
{{- if $persistence.selector }}
storage: {{ $pvc.size | quote }}
{{- if $pvc.selector }}
selector:
{{ toYaml $persistence.selector | indent 4 }}
{{ toYaml $pvc.selector | indent 4 }}
{{ end }}
---
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ manifest should match snapshot:
resources:
requests:
storage: 1Gi
should apply annotations from persistence.annotations:
should apply annotations from persistent_volume_claims.annotations:
1: |
apiVersion: v1
kind: PersistentVolumeClaim
Expand Down
6 changes: 3 additions & 3 deletions charts/docker-mailserver/tests/pvc_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ chart:
version: 0.1.0
appVersion: 0.1.0
tests:
- it: should apply annotations from persistence.annotations
- it: should apply annotations from persistent_volume_claims.annotations
set:
persistence:
persistent_volume_claims:
mail-config:
annotations:
backup.banana.io/deltas: pancakes
Expand All @@ -18,7 +18,7 @@ tests:

- it: should create pvc of specified size
set:
persistence:
persistent_volume_claims:
mail-data:
size: 1Pb
documentIndex: 1
Expand Down
37 changes: 28 additions & 9 deletions charts/docker-mailserver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,12 @@ service:
labels: {}

# Note this is a dictionary and not a list so individual keys can be overridden by --set or --value helm parameters
persistence:
persistent_volume_claims:
# Stores generated configuration files
# https://docker-mailserver.github.io/docker-mailserver/edge/faq/#what-about-the-docker-datadmsconfig-directory
mail-config:
enabled: true
existingClaim: ""
mountPath: /tmp/docker-mailserver
subPath: ""
size: "1Mi"
annotations: {}
accessModes:
Expand All @@ -348,9 +346,7 @@ persistence:
mail-data:
enabled: true
existingClaim: ""
subPath: ""
size: 10Gi
mountPath: /var/mail
annotations: {}
accessModes:
- ReadWriteOnce
Expand All @@ -362,8 +358,6 @@ persistence:
mail-state:
enabled: true
existingClaim: ""
mountPath: /var/mail-state
subPath: ""
size: "1Gi"
annotations: {}
accessModes:
Expand All @@ -375,15 +369,40 @@ persistence:
mail-log:
enabled: true
existingClaim: ""
mountPath: /var/log/mail
subPath: ""
size: "1Gi"
annotations: {}
accessModes:
- ReadWriteOnce
storageClass:
selector: {}

persistence:
# Stores generated configuration files
# https://docker-mailserver.github.io/docker-mailserver/edge/faq/#what-about-the-docker-datadmsconfig-directory
mail-config:
volumeName: mail-config
mountPath: /tmp/docker-mailserver
subPath:

# Stores emails
mail-data:
volumeName: mail-data
mountPath: /var/mail
subPath:

# Stores state for Postfix, Dovecot, Fail2Ban, Amavis, PostGrey, ClamAV, SpamAssassin, Rspamd & Redis
# https://docker-mailserver.github.io/docker-mailserver/edge/faq/#what-about-the-docker-datadmsmail-state-directory
mail-state:
volumeName: mail-state
mountPath: /var/mail-state
subPath:

# Store mail logs
mail-log:
volumeName: mail-log
mountPath: /var/log/mail
subPath:

## Monitoring adds the prometheus.io annotations to pods and services, so that the Prometheus Kubernetes SD mechanism
## as configured in the examples will automatically discover both the pods and the services to query.
##
Expand Down
Loading

0 comments on commit 604d180

Please sign in to comment.