Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

charts: support using an existing PVC via persistence.existingClaim

Steven Koof4db9ec5275b
diff --git a/charts/templates/deployment.yaml b/charts/templates/deployment.yaml
index f1b9d186..57d57ac2 100644
--- a/charts/templates/deployment.yaml
+++ b/charts/templates/deployment.yaml
@@ -101,7 +101,7 @@ spec:
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
- claimName: {{ include "answer.fullname" . }}-claim
+ claimName: {{ .Values.persistence.existingClaim | default (printf "%s-claim" (include "answer.fullname" .)) }}
{{- else }}
emptyDir: {}
{{- end -}}
diff --git a/charts/templates/pvc.yaml b/charts/templates/pvc.yaml
index 640fb9fe..e01ff820 100644
--- a/charts/templates/pvc.yaml
+++ b/charts/templates/pvc.yaml
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-{{ if .Values.persistence.enabled -}}
+{{ if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
diff --git a/charts/values.yaml b/charts/values.yaml
index d932db84..7a5c16f3 100644
--- a/charts/values.yaml
+++ b/charts/values.yaml
@@ -91,6 +91,8 @@ persistence:
accessMode: ReadWriteOnce
size: 5Gi
annotations: {}
+ # Use an existing PVC instead of creating one; when set, no PVC is created by this chart
+ existingClaim: ""
# To restore a PVC from a VolumeSnapshot, set the dataSource;
# the kind and apiGroup are optional and default to the shown values
dataSource: {}