Skip to content

Commit 9bc0316

Browse files
promasuhagak
andauthored
Add support for ExistingClaim per pod (#486)
fix #371 Signed-off-by: Adrian Nöthlich <git@promasu.tech> Co-authored-by: Jeffrey Gordon <jeff@thetank.org>
1 parent 6bc921e commit 9bc0316

10 files changed

Lines changed: 93 additions & 14 deletions

File tree

charts/mailu/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ helm uninstall mailu --namespace=mailu-mailserver
409409
| `admin.persistence.accessModes` | Pod pvc access modes | `["ReadWriteOnce"]` |
410410
| `admin.persistence.claimNameOverride` | Pod pvc name override | `""` |
411411
| `admin.persistence.annotations` | Pod pvc annotations | `{}` |
412+
| `admin.persistence.existingClaim` | Pod pvc existing claim name | `""` |
412413
| `admin.resources.limits` | The resources limits for the container | `{}` |
413414
| `admin.resources.requests` | The requested resources for the container | `{}` |
414415
| `admin.livenessProbe.enabled` | Enable livenessProbe | `true` |
@@ -494,6 +495,7 @@ helm uninstall mailu --namespace=mailu-mailserver
494495
| `postfix.persistence.accessModes` | Pod pvc access modes | `["ReadWriteOnce"]` |
495496
| `postfix.persistence.claimNameOverride` | Pod pvc name override | `""` |
496497
| `postfix.persistence.annotations` | Pod pvc annotations | `{}` |
498+
| `postfix.persistence.existingClaim` | Pod pvc existing claim name | `""` |
497499
| `postfix.resources.limits` | The resources limits for the container | `{}` |
498500
| `postfix.resources.requests` | The requested resources for the container | `{}` |
499501
| `postfix.livenessProbe.enabled` | Enable livenessProbe | `true` |
@@ -555,6 +557,7 @@ helm uninstall mailu --namespace=mailu-mailserver
555557
| `dovecot.persistence.accessModes` | Pod pvc access modes | `["ReadWriteOnce"]` |
556558
| `dovecot.persistence.claimNameOverride` | Pod pvc name override | `""` |
557559
| `dovecot.persistence.annotations` | Pod pvc annotations | `{}` |
560+
| `dovecot.persistence.existingClaim` | Pod pvc existing claim name | `""` |
558561
| `dovecot.resources.limits` | The resources limits for the container | `{}` |
559562
| `dovecot.resources.requests` | The requested resources for the container | `{}` |
560563
| `dovecot.livenessProbe.enabled` | Enable livenessProbe | `true` |
@@ -625,6 +628,7 @@ helm uninstall mailu --namespace=mailu-mailserver
625628
| `rspamd.persistence.accessModes` | Pod pvc access modes | `["ReadWriteOnce"]` |
626629
| `rspamd.persistence.claimNameOverride` | Pod pvc name override | `""` |
627630
| `rspamd.persistence.annotations` | Pod pvc annotations | `{}` |
631+
| `rspamd.persistence.existingClaim` | Pod pvc existing claim name | `""` |
628632
| `rspamd.resources.limits` | The resources limits for the container | `{}` |
629633
| `rspamd.resources.requests` | The requested resources for the container | `{}` |
630634
| `rspamd.livenessProbe.enabled` | Enable livenessProbe | `true` |
@@ -757,6 +761,7 @@ helm uninstall mailu --namespace=mailu-mailserver
757761
| `webmail.persistence.accessModes` | Pod pvc access modes | `["ReadWriteOnce"]` |
758762
| `webmail.persistence.claimNameOverride` | Pod pvc name override | `""` |
759763
| `webmail.persistence.annotations` | Pod pvc annotations | `{}` |
764+
| `webmail.persistence.existingClaim` | Pod pvc existing claim name | `""` |
760765
| `webmail.resources.limits` | The resources limits for the container | `{}` |
761766
| `webmail.resources.requests` | The requested resources for the container | `{}` |
762767
| `webmail.livenessProbe.enabled` | Enable livenessProbe | `true` |

charts/mailu/templates/_claims.tpl

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,90 @@
11
{{/* Admin pod persistent volume claim name */}}
22
{{ define "mailu.admin.claimName" }}
3-
{{- .Values.persistence.single_pvc | ternary (include "mailu.claimName" .) .Values.admin.persistence.claimNameOverride | default (printf "%s-admin" (include "mailu.fullname" .)) -}}
3+
{{- if .Values.persistence.single_pvc -}}
4+
{{- (include "mailu.claimName" .) -}}
5+
{{- else if .Values.admin.persistence.existingClaim -}}
6+
{{- .Values.admin.persistence.existingClaim -}}
7+
{{- else if .Values.admin.persistence.claimNameOverride -}}
8+
{{- .Values.admin.persistence.claimNameOverride -}}
9+
{{- else -}}
10+
{{ printf "%s-admin" (include "mailu.fullname" .) }}
11+
{{- end -}}
412
{{- end -}}
513

614
{{/* Dovecot pod persistent volume claim name */}}
715
{{ define "mailu.dovecot.claimName" }}
8-
{{- .Values.persistence.single_pvc | ternary (include "mailu.claimName" .) .Values.dovecot.persistence.claimNameOverride | default (printf "%s-dovecot" (include "mailu.fullname" .)) -}}
16+
{{- if .Values.persistence.single_pvc -}}
17+
{{- (include "mailu.claimName" .) -}}
18+
{{- else if .Values.dovecot.persistence.existingClaim -}}
19+
{{- .Values.dovecot.persistence.existingClaim -}}
20+
{{- else if .Values.dovecot.persistence.claimNameOverride -}}
21+
{{- .Values.dovecot.persistence.claimNameOverride -}}
22+
{{- else -}}
23+
{{ printf "%s-dovecot" (include "mailu.fullname" .) }}
24+
{{- end -}}
925
{{- end -}}
1026

1127
{{/* Postfix pod persistent volume claim name */}}
1228
{{ define "mailu.postfix.claimName" }}
13-
{{- .Values.persistence.single_pvc | ternary (include "mailu.claimName" .) .Values.postfix.persistence.claimNameOverride | default (printf "%s-postfix" (include "mailu.fullname" .)) -}}
29+
{{- if .Values.persistence.single_pvc -}}
30+
{{- (include "mailu.claimName" .) -}}
31+
{{- else if .Values.postfix.persistence.existingClaim -}}
32+
{{- .Values.postfix.persistence.existingClaim -}}
33+
{{- else if .Values.postfix.persistence.claimNameOverride -}}
34+
{{- .Values.postfix.persistence.claimNameOverride -}}
35+
{{- else -}}
36+
{{ printf "%s-postfix" (include "mailu.fullname" .) }}
37+
{{- end -}}
1438
{{- end -}}
1539

1640
{{/* Rspamd pod persistent volume claim name */}}
1741
{{ define "mailu.rspamd.claimName" }}
18-
{{- .Values.persistence.single_pvc | ternary (include "mailu.claimName" .) .Values.rspamd.persistence.claimNameOverride | default (printf "%s-rspamd" (include "mailu.fullname" .)) -}}
42+
{{- if .Values.persistence.single_pvc -}}
43+
{{- (include "mailu.claimName" .) -}}
44+
{{- else if .Values.rspamd.persistence.existingClaim -}}
45+
{{- .Values.rspamd.persistence.existingClaim -}}
46+
{{- else if .Values.rspamd.persistence.claimNameOverride -}}
47+
{{- .Values.rspamd.persistence.claimNameOverride -}}
48+
{{- else -}}
49+
{{ printf "%s-rspamd" (include "mailu.fullname" .) }}
50+
{{- end -}}
1951
{{- end -}}
2052

2153
{{/* Roundcube pod persistent volume claim name */}}
2254
{{ define "mailu.webmail.claimName" }}
23-
{{- .Values.persistence.single_pvc | ternary (include "mailu.claimName" .) .Values.webmail.persistence.claimNameOverride | default (printf "%s-webmail" (include "mailu.fullname" .)) -}}
55+
{{- if .Values.persistence.single_pvc -}}
56+
{{- (include "mailu.claimName" .) -}}
57+
{{- else if .Values.webmail.persistence.existingClaim -}}
58+
{{- .Values.webmail.persistence.existingClaim -}}
59+
{{- else if .Values.webmail.persistence.claimNameOverride -}}
60+
{{- .Values.webmail.persistence.claimNameOverride -}}
61+
{{- else -}}
62+
{{ printf "%s-webmail" (include "mailu.fullname" .) }}
63+
{{- end -}}
2464
{{- end -}}
2565

2666
{{/* Fetchmail pod persistent volume claim name */}}
2767
{{ define "mailu.fetchmail.claimName" }}
28-
{{- .Values.persistence.single_pvc | ternary (include "mailu.claimName" .) .Values.fetchmail.persistence.claimNameOverride | default (printf "%s-fetchmail" (include "mailu.fullname" .)) -}}
68+
{{- if .Values.persistence.single_pvc -}}
69+
{{- (include "mailu.claimName" .) -}}
70+
{{- else if .Values.fetchmail.persistence.existingClaim -}}
71+
{{- .Values.fetchmail.persistence.existingClaim -}}
72+
{{- else if .Values.fetchmail.persistence.claimNameOverride -}}
73+
{{- .Values.fetchmail.persistence.claimNameOverride -}}
74+
{{- else -}}
75+
{{ printf "%s-fetchmail" (include "mailu.fullname" .) }}
76+
{{- end -}}
2977
{{- end -}}
3078

3179
{{/* Webdav pod persistent volume claim name */}}
3280
{{ define "mailu.webdav.claimName" }}
33-
{{- .Values.persistence.single_pvc | ternary (include "mailu.claimName" .) .Values.webdav.persistence.claimNameOverride | default (printf "%s-webdav" (include "mailu.fullname" .)) -}}
81+
{{- if .Values.persistence.single_pvc -}}
82+
{{- (include "mailu.claimName" .) -}}
83+
{{- else if .Values.webdav.persistence.existingClaim -}}
84+
{{- .Values.webdav.persistence.existingClaim -}}
85+
{{- else if .Values.webdav.persistence.claimNameOverride -}}
86+
{{- .Values.webdav.persistence.claimNameOverride -}}
87+
{{- else -}}
88+
{{ printf "%s-webdav" (include "mailu.fullname" .) }}
89+
{{- end -}}
3490
{{- end -}}

charts/mailu/templates/admin/pvc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
{{- if not .Values.persistence.single_pvc }}
2+
{{- if and (not .Values.persistence.single_pvc) (not .Values.admin.persistence.existingClaim)}}
33
kind: PersistentVolumeClaim
44
apiVersion: v1
55
metadata:

charts/mailu/templates/dovecot/pvc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
{{- if .Values.dovecot.enabled }}
3-
{{- if not .Values.persistence.single_pvc }}
3+
{{- if and (not .Values.persistence.single_pvc) (not .Values.postfix.persistence.existingClaim)}}
44
kind: PersistentVolumeClaim
55
apiVersion: v1
66
metadata:

charts/mailu/templates/fetchmail/pvc.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
{{- if and (.Values.fetchmail.enabled) (not .Values.persistence.single_pvc) }}
2+
{{- if .Values.fetchmail.enabled -}}
3+
{{- if and (not .Values.persistence.single_pvc) (not .Values.fetchmail.persistence.existingClaim) }}
34
kind: PersistentVolumeClaim
45
apiVersion: v1
56
metadata:
@@ -31,3 +32,4 @@ spec:
3132
storageClassName: {{ .Values.fetchmail.persistence.storageClass }}
3233
{{- end }}
3334
{{- end }}
35+
{{- end }}

charts/mailu/templates/postfix/pvc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
{{- if not .Values.persistence.single_pvc }}
2+
{{- if and (not .Values.persistence.single_pvc) (not .Values.postfix.persistence.existingClaim) }}
33
kind: PersistentVolumeClaim
44
apiVersion: v1
55
metadata:

charts/mailu/templates/rspamd/pvc.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
{{- if and (not .Values.persistence.single_pvc) .Values.rspamd.enabled }}
2+
{{- if .Values.rspamd.enabled -}}
3+
{{- if and (not .Values.persistence.single_pvc) (not .Values.rspamd.persistence.existingClaim) }}
34
kind: PersistentVolumeClaim
45
apiVersion: v1
56
metadata:
@@ -31,3 +32,4 @@ spec:
3132
storageClassName: {{ .Values.rspamd.persistence.storageClass }}
3233
{{- end }}
3334
{{- end }}
35+
{{- end }}

charts/mailu/templates/webdav/pvc.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
{{- if and (.Values.webdav.enabled) (not .Values.persistence.single_pvc) }}
2+
{{- if .Values.webdav.enabled -}}
3+
{{- if and (not .Values.persistence.single_pvc) (not .Values.webdav.persistence.existingClaim) }}
34
kind: PersistentVolumeClaim
45
apiVersion: v1
56
metadata:
@@ -31,3 +32,4 @@ spec:
3132
storageClassName: {{ .Values.webdav.persistence.storageClass }}
3233
{{- end }}
3334
{{- end }}
35+
{{- end }}

charts/mailu/templates/webmail/pvc.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
{{- if and (.Values.webmail.enabled) (not .Values.persistence.single_pvc) }}
2+
{{- if .Values.webmail.enabled -}}
3+
{{- if and (not .Values.persistence.single_pvc) (not .Values.webmail.persistence.existingClaim) }}
34
kind: PersistentVolumeClaim
45
apiVersion: v1
56
metadata:
@@ -31,3 +32,4 @@ spec:
3132
storageClassName: {{ .Values.webmail.persistence.storageClass }}
3233
{{- end }}
3334
{{- end }}
35+
{{- end }}

charts/mailu/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,12 +967,14 @@ admin:
967967
## @param admin.persistence.accessModes Pod pvc access modes
968968
## @param admin.persistence.claimNameOverride Pod pvc name override
969969
## @param admin.persistence.annotations Pod pvc annotations
970+
## @param admin.persistence.existingClaim Pod pvc existing claim name
970971
persistence:
971972
size: 20Gi
972973
storageClass: ""
973974
accessModes: [ReadWriteOnce]
974975
claimNameOverride: ""
975976
annotations: {}
977+
existingClaim: ""
976978

977979
## Pod resource requests and limits
978980
## ref: https://kubernetes.io/docs/user-guide/compute-resources/
@@ -1243,12 +1245,14 @@ postfix:
12431245
## @param postfix.persistence.accessModes Pod pvc access modes
12441246
## @param postfix.persistence.claimNameOverride Pod pvc name override
12451247
## @param postfix.persistence.annotations Pod pvc annotations
1248+
## @param postfix.persistence.existingClaim Pod pvc existing claim name
12461249
persistence:
12471250
size: 20Gi
12481251
storageClass: ""
12491252
accessModes: [ReadWriteOnce]
12501253
claimNameOverride: ""
12511254
annotations: {}
1255+
existingClaim: ""
12521256

12531257
## Pod resource requests and limits
12541258
## ref: https://kubernetes.io/docs/user-guide/compute-resources/
@@ -1451,12 +1455,14 @@ dovecot:
14511455
## @param dovecot.persistence.accessModes Pod pvc access modes
14521456
## @param dovecot.persistence.claimNameOverride Pod pvc name override
14531457
## @param dovecot.persistence.annotations Pod pvc annotations
1458+
## @param dovecot.persistence.existingClaim Pod pvc existing claim name
14541459
persistence:
14551460
size: 20Gi
14561461
storageClass: ""
14571462
accessModes: [ReadWriteOnce]
14581463
claimNameOverride: ""
14591464
annotations: {}
1465+
existingClaim: ""
14601466

14611467
## Pod resource requests and limits
14621468
## ref: https://kubernetes.io/docs/user-guide/compute-resources/
@@ -1773,12 +1779,14 @@ rspamd:
17731779
## @param rspamd.persistence.accessModes Pod pvc access modes
17741780
## @param rspamd.persistence.claimNameOverride Pod pvc name override
17751781
## @param rspamd.persistence.annotations Pod pvc annotations
1782+
## @param rspamd.persistence.existingClaim Pod pvc existing claim name
17761783
persistence:
17771784
size: 1Gi
17781785
storageClass: ""
17791786
accessModes: [ReadWriteOnce]
17801787
claimNameOverride: ""
17811788
annotations: {}
1789+
existingClaim: ""
17821790

17831791
## Pod resource requests and limits
17841792
## ref: https://kubernetes.io/docs/user-guide/compute-resources/
@@ -2253,12 +2261,14 @@ webmail:
22532261
## @param webmail.persistence.accessModes Pod pvc access modes
22542262
## @param webmail.persistence.claimNameOverride Pod pvc name override
22552263
## @param webmail.persistence.annotations Pod pvc annotations
2264+
## @param webmail.persistence.existingClaim Pod pvc existing claim name
22562265
persistence:
22572266
size: 20Gi
22582267
storageClass: ""
22592268
accessModes: [ReadWriteOnce]
22602269
claimNameOverride: ""
22612270
annotations: {}
2271+
existingClaim: ""
22622272

22632273
## Pod resource requests and limits
22642274
## ref: https://kubernetes.io/docs/user-guide/compute-resources/

0 commit comments

Comments
 (0)