Skip to content

Commit

Permalink
Support for existingClaim
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Sep 15, 2021
1 parent 07afdb1 commit 937cb67
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions charts/common/templates/_pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- define "common.pvc.tpl" -}}
{{- range .Values.volumes }}
{{- if not .existingClaim }}
{{- $robustName := include "common.robustName" $.Release.Name }}
---
apiVersion: v1
Expand All @@ -15,4 +16,5 @@ spec:
requests:
storage: {{ .size | default "1Gi" }}
{{- end }}
{{- end }}
{{- end -}}
4 changes: 4 additions & 0 deletions charts/common/templates/_volumesRef.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ volumes:
{{- range .Values.volumes }}
- name: {{ .name }}
persistentVolumeClaim:
{{- if .existingClaim }}
claimName: {{ .existingClaim }}
{{ else }}
claimName: {{ printf "%s-%s" $.Release.Name .name }}
{{- end }}
{{- end }}
{{- range .Values.sealedFileSecrets }}
- name: {{ .name }}
Expand Down
Binary file modified charts/cron-job/charts/common-0.1.0.tgz
Binary file not shown.
Binary file modified charts/onechart/charts/common-0.1.0.tgz
Binary file not shown.
15 changes: 14 additions & 1 deletion charts/onechart/tests/deployment_volumes_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,17 @@ tests:
asserts:
- equal:
path: spec.strategy.type
value: Dummy
value: Dummy
- it: Should use the existing claim
set:
volumes:
- name: data
path: /var/lib/1clickinfra/data
existingClaim: my-static-claim
asserts:
- equal:
path: spec.template.spec.volumes
value:
- name: data
persistentVolumeClaim:
claimName: my-static-claim
9 changes: 9 additions & 0 deletions charts/onechart/tests/pvc_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ tests:
- equal:
path: spec.storageClassName
value: default
- it: Should not generate a claim when using existing claim
set:
volumes:
- name: data
path: /var/lib/1clickinfra/data
existingClaim: my-static-claim
asserts:
- hasDocuments:
count: 0
3 changes: 1 addition & 2 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ vars:
volumes:
- name: data
path: /data
size: 10Gi
storageClass: default
existingClaim: myclaim

0 comments on commit 937cb67

Please sign in to comment.