Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/whole-badgers-make.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"helm-charts": patch
---

feat: option to keep all services PVCs when uninstalling helm
18 changes: 0 additions & 18 deletions charts/hdx-oss-v2/templates/claims/persistent-volume-claims.yaml
Copy link
Collaborator Author

@wrn14897 wrn14897 Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to mongodb-deployment.yaml file

This file was deleted.

8 changes: 8 additions & 0 deletions charts/hdx-oss-v2/templates/clickhouse-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ metadata:
name: {{ include "hdx-oss.fullname" . }}-clickhouse-data
labels:
{{- include "hdx-oss.labels" . | nindent 4 }}
{{- if .Values.global.keepPVC }}
annotations:
"helm.sh/resource-policy": keep
{{- end }}
spec:
accessModes:
- ReadWriteOnce
Expand All @@ -163,6 +167,10 @@ metadata:
name: {{ include "hdx-oss.fullname" . }}-clickhouse-logs
labels:
{{- include "hdx-oss.labels" . | nindent 4 }}
{{- if .Values.global.keepPVC }}
annotations:
"helm.sh/resource-policy": keep
{{- end }}
spec:
accessModes:
- ReadWriteOnce
Expand Down
22 changes: 22 additions & 0 deletions charts/hdx-oss-v2/templates/mongodb-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
{{- if .Values.mongodb.enabled }}
{{- if .Values.mongodb.persistence.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "hdx-oss.fullname" . }}-mongodb
labels:
{{- include "hdx-oss.labels" . | nindent 4 }}
{{- if .Values.global.keepPVC }}
annotations:
"helm.sh/resource-policy": keep
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- if .Values.global.storageClassName }}
storageClassName: {{ .Values.global.storageClassName }}
{{- end }}
resources:
requests:
storage: {{ .Values.mongodb.persistence.dataSize }}
---
{{- end }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
74 changes: 73 additions & 1 deletion charts/hdx-oss-v2/tests/clickhouse-deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,76 @@ tests:
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].readinessProbe.httpGet.port
value: 8124
value: 8124

- it: should add keep annotation to PVCs when global.keepPVC is true
set:
clickhouse:
enabled: true
persistence:
enabled: true
dataSize: 10Gi
logSize: 5Gi
global:
keepPVC: true
asserts:
- documentIndex: 4
isKind:
of: PersistentVolumeClaim
- documentIndex: 4
equal:
path: metadata.annotations["helm.sh/resource-policy"]
value: keep
- documentIndex: 5
isKind:
of: PersistentVolumeClaim
- documentIndex: 5
equal:
path: metadata.annotations["helm.sh/resource-policy"]
value: keep

- it: should not add keep annotation to PVCs when global.keepPVC is false
set:
clickhouse:
enabled: true
persistence:
enabled: true
dataSize: 10Gi
logSize: 5Gi
global:
keepPVC: false
asserts:
- documentIndex: 4
isKind:
of: PersistentVolumeClaim
- documentIndex: 4
isNull:
path: metadata.annotations
- documentIndex: 5
isKind:
of: PersistentVolumeClaim
- documentIndex: 5
isNull:
path: metadata.annotations

- it: should not add keep annotation to PVCs when global.keepPVC is not set
set:
clickhouse:
enabled: true
persistence:
enabled: true
dataSize: 10Gi
logSize: 5Gi
asserts:
- documentIndex: 4
isKind:
of: PersistentVolumeClaim
- documentIndex: 4
isNull:
path: metadata.annotations
- documentIndex: 5
isKind:
of: PersistentVolumeClaim
- documentIndex: 5
isNull:
path: metadata.annotations
108 changes: 102 additions & 6 deletions charts/hdx-oss-v2/tests/mongodb-deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ tests:
image: mongo:5.0.14-focal
port: 27017
enabled: true
persistence:
enabled: false
asserts:
- hasDocuments:
count: 2
Expand All @@ -26,38 +28,57 @@ tests:
- hasDocuments:
count: 0

- it: should use PVC when persistence is enabled
- it: should create PVC, deployment and service when persistence is enabled
set:
mongodb:
enabled: true
persistence:
enabled: true
dataSize: 10Gi
asserts:
- hasDocuments:
count: 3
- documentIndex: 0
isKind:
of: Deployment
of: PersistentVolumeClaim
- documentIndex: 0
matchRegex:
path: metadata.name
pattern: .*-mongodb$
- documentIndex: 0
equal:
path: spec.resources.requests.storage
value: 10Gi
- documentIndex: 1
isKind:
of: Deployment
- documentIndex: 1
equal:
path: spec.template.spec.volumes[0].name
value: mongodb-data
- documentIndex: 0
- documentIndex: 1
isNotNull:
path: spec.template.spec.volumes[0].persistentVolumeClaim
- documentIndex: 0
- documentIndex: 1
matchRegex:
path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName
pattern: .*-mongodb$
- documentIndex: 0
- documentIndex: 1
isNull:
path: spec.template.spec.volumes[0].emptyDir
- documentIndex: 2
isKind:
of: Service

- it: should use emptyDir when persistence is disabled
- it: should use emptyDir when persistence is disabled and not create PVC
set:
mongodb:
enabled: true
persistence:
enabled: false
asserts:
- hasDocuments:
count: 2 # Only Deployment and Service, no PVC
- documentIndex: 0
isKind:
of: Deployment
Expand All @@ -71,11 +92,16 @@ tests:
- documentIndex: 0
isNull:
path: spec.template.spec.volumes[0].persistentVolumeClaim
- documentIndex: 1
isKind:
of: Service

- it: should include livenessProbe with tcpSocket when enabled
set:
mongodb:
enabled: true
persistence:
enabled: false # To ensure predictable document ordering
asserts:
- documentIndex: 0
isSubset:
Expand All @@ -92,6 +118,8 @@ tests:
set:
mongodb:
enabled: true
persistence:
enabled: false # To ensure predictable document ordering
asserts:
- documentIndex: 0
isSubset:
Expand All @@ -108,6 +136,8 @@ tests:
set:
mongodb:
enabled: true
persistence:
enabled: false # To ensure predictable document ordering
livenessProbe:
enabled: false
asserts:
Expand All @@ -119,6 +149,8 @@ tests:
set:
mongodb:
enabled: true
persistence:
enabled: false # To ensure predictable document ordering
readinessProbe:
enabled: false
asserts:
Expand All @@ -130,6 +162,8 @@ tests:
set:
mongodb:
enabled: true
persistence:
enabled: false # To ensure predictable document ordering
livenessProbe:
enabled: true
initialDelaySeconds: 20
Expand All @@ -152,6 +186,8 @@ tests:
set:
mongodb:
enabled: true
persistence:
enabled: false # To ensure predictable document ordering
readinessProbe:
enabled: true
initialDelaySeconds: 5
Expand All @@ -169,3 +205,63 @@ tests:
periodSeconds: 20
timeoutSeconds: 3
failureThreshold: 2

- it: should not create PVC when mongodb is disabled
set:
mongodb:
enabled: false
persistence:
enabled: true # Even with persistence enabled, no PVC should be created
asserts:
- hasDocuments:
count: 0 # No resources should be created

- it: should include keep annotation on PVC when global.keepPVC is true
set:
mongodb:
enabled: true
persistence:
enabled: true
global:
keepPVC: true
asserts:
- documentIndex: 0
isKind:
of: PersistentVolumeClaim
- documentIndex: 0
equal:
path: metadata.annotations["helm.sh/resource-policy"]
value: keep

- it: should not include keep annotation on PVC when global.keepPVC is false
set:
mongodb:
enabled: true
persistence:
enabled: true
global:
keepPVC: false
asserts:
- documentIndex: 0
isKind:
of: PersistentVolumeClaim
- documentIndex: 0
isNull:
path: metadata.annotations["helm.sh/resource-policy"]

- it: should use global storageClassName when specified
set:
mongodb:
enabled: true
persistence:
enabled: true
global:
storageClassName: fast-ssd
asserts:
- documentIndex: 0
isKind:
of: PersistentVolumeClaim
- documentIndex: 0
equal:
path: spec.storageClassName
value: fast-ssd
4 changes: 4 additions & 0 deletions charts/hdx-oss-v2/tests/node-selector_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ tests:
- it: should apply nodeSelector and tolerations to MongoDB deployment
set:
mongodb:
persistence:
enabled: false # Disable PVC to have predictable document order
nodeSelector:
node-role: database
tolerations:
Expand Down Expand Up @@ -254,6 +256,8 @@ tests:
value: clickhouse
effect: NoExecute
mongodb:
persistence:
enabled: false # Disable PVC to have predictable document order
nodeSelector:
component: database
storage: standard
Expand Down
Loading