diff --git a/.changeset/fair-houses-begin.md b/.changeset/fair-houses-begin.md new file mode 100644 index 0000000..5455379 --- /dev/null +++ b/.changeset/fair-houses-begin.md @@ -0,0 +1,5 @@ +--- +"helm-charts": patch +--- + +fix: relocate mongodb volume persistence field + handle the case when CH pvc is disabled diff --git a/charts/hdx-oss-v2/templates/claims/persistent-volume-claims.yaml b/charts/hdx-oss-v2/templates/claims/persistent-volume-claims.yaml index f10d23d..ad3e0dc 100644 --- a/charts/hdx-oss-v2/templates/claims/persistent-volume-claims.yaml +++ b/charts/hdx-oss-v2/templates/claims/persistent-volume-claims.yaml @@ -1,4 +1,4 @@ -{{- if .Values.persistence.mongodb.enabled }} +{{- if .Values.mongodb.persistence.enabled }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -13,6 +13,6 @@ spec: {{- end }} resources: requests: - storage: {{ .Values.persistence.mongodb.size }} + storage: {{ .Values.mongodb.persistence.dataSize }} --- -{{- end }} \ No newline at end of file +{{- end }} diff --git a/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml b/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml index c7329b5..03ff190 100644 --- a/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml +++ b/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml @@ -46,9 +46,19 @@ spec: configMap: name: {{ include "hdx-oss.fullname" . }}-clickhouse-users - name: data + {{- if .Values.clickhouse.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ include "hdx-oss.fullname" . }}-clickhouse-data + {{- else }} emptyDir: {} + {{- end }} - name: logs + {{- if .Values.clickhouse.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ include "hdx-oss.fullname" . }}-clickhouse-logs + {{- else }} emptyDir: {} + {{- end }} --- apiVersion: v1 kind: Service diff --git a/charts/hdx-oss-v2/templates/mongodb-deployment.yaml b/charts/hdx-oss-v2/templates/mongodb-deployment.yaml index e80498d..0b30a13 100644 --- a/charts/hdx-oss-v2/templates/mongodb-deployment.yaml +++ b/charts/hdx-oss-v2/templates/mongodb-deployment.yaml @@ -28,8 +28,12 @@ spec: mountPath: /data/db volumes: - name: mongodb-data + {{- if .Values.mongodb.persistence.enabled }} persistentVolumeClaim: claimName: {{ include "hdx-oss.fullname" . }}-mongodb + {{- else }} + emptyDir: {} + {{- end }} --- apiVersion: v1 kind: Service diff --git a/charts/hdx-oss-v2/tests/clickhouse-deployment_test.yaml b/charts/hdx-oss-v2/tests/clickhouse-deployment_test.yaml index 4ee255a..9051fde 100644 --- a/charts/hdx-oss-v2/tests/clickhouse-deployment_test.yaml +++ b/charts/hdx-oss-v2/tests/clickhouse-deployment_test.yaml @@ -71,4 +71,78 @@ tests: path: spec.storageClassName - documentIndex: 5 isNull: - path: spec.storageClassName \ No newline at end of file + path: spec.storageClassName + + - it: should use PVCs when persistence is enabled + set: + clickhouse: + enabled: true + persistence: + enabled: true + dataSize: 10Gi + logSize: 5Gi + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.volumes[2].name + value: data + - documentIndex: 0 + isNotNull: + path: spec.template.spec.volumes[2].persistentVolumeClaim + - documentIndex: 0 + matchRegex: + path: spec.template.spec.volumes[2].persistentVolumeClaim.claimName + pattern: .*-clickhouse-data$ + - documentIndex: 0 + isNull: + path: spec.template.spec.volumes[2].emptyDir + - documentIndex: 0 + equal: + path: spec.template.spec.volumes[3].name + value: logs + - documentIndex: 0 + isNotNull: + path: spec.template.spec.volumes[3].persistentVolumeClaim + - documentIndex: 0 + matchRegex: + path: spec.template.spec.volumes[3].persistentVolumeClaim.claimName + pattern: .*-clickhouse-logs$ + - documentIndex: 0 + isNull: + path: spec.template.spec.volumes[3].emptyDir + + - it: should use emptyDir when persistence is disabled + set: + clickhouse: + enabled: true + persistence: + enabled: false + asserts: + - hasDocuments: + count: 4 + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.volumes[2].name + value: data + - documentIndex: 0 + isNotNull: + path: spec.template.spec.volumes[2].emptyDir + - documentIndex: 0 + isNull: + path: spec.template.spec.volumes[2].persistentVolumeClaim + - documentIndex: 0 + equal: + path: spec.template.spec.volumes[3].name + value: logs + - documentIndex: 0 + isNotNull: + path: spec.template.spec.volumes[3].emptyDir + - documentIndex: 0 + isNull: + path: spec.template.spec.volumes[3].persistentVolumeClaim \ No newline at end of file diff --git a/charts/hdx-oss-v2/tests/mongodb-deployment_test.yaml b/charts/hdx-oss-v2/tests/mongodb-deployment_test.yaml index 4e470bd..2c2c8a0 100644 --- a/charts/hdx-oss-v2/tests/mongodb-deployment_test.yaml +++ b/charts/hdx-oss-v2/tests/mongodb-deployment_test.yaml @@ -24,4 +24,50 @@ tests: enabled: false asserts: - hasDocuments: - count: 0 \ No newline at end of file + count: 0 + + - it: should use PVC when persistence is enabled + set: + mongodb: + enabled: true + persistence: + enabled: true + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.volumes[0].name + value: mongodb-data + - documentIndex: 0 + isNotNull: + path: spec.template.spec.volumes[0].persistentVolumeClaim + - documentIndex: 0 + matchRegex: + path: spec.template.spec.volumes[0].persistentVolumeClaim.claimName + pattern: .*-mongodb$ + - documentIndex: 0 + isNull: + path: spec.template.spec.volumes[0].emptyDir + + - it: should use emptyDir when persistence is disabled + set: + mongodb: + enabled: true + persistence: + enabled: false + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.volumes[0].name + value: mongodb-data + - documentIndex: 0 + isNotNull: + path: spec.template.spec.volumes[0].emptyDir + - documentIndex: 0 + isNull: + path: spec.template.spec.volumes[0].persistentVolumeClaim \ No newline at end of file diff --git a/charts/hdx-oss-v2/tests/persistence_test.yaml b/charts/hdx-oss-v2/tests/persistence_test.yaml index c586f02..6263b89 100644 --- a/charts/hdx-oss-v2/tests/persistence_test.yaml +++ b/charts/hdx-oss-v2/tests/persistence_test.yaml @@ -6,10 +6,10 @@ tests: set: global: storageClass: "custom-storage-class" - persistence: - mongodb: + mongodb: + persistence: enabled: true - size: 15Gi + dataSize: 15Gi asserts: - isKind: of: PersistentVolumeClaim @@ -25,8 +25,8 @@ tests: - it: should not create PVCs when persistence is disabled set: - persistence: - mongodb: + mongodb: + persistence: enabled: false asserts: - hasDocuments: @@ -36,10 +36,10 @@ tests: set: global: storageClass: "" - persistence: - mongodb: + mongodb: + persistence: enabled: true - size: 10Gi + dataSize: 10Gi asserts: - isKind: of: PersistentVolumeClaim diff --git a/charts/hdx-oss-v2/tests/pvc_test.yaml b/charts/hdx-oss-v2/tests/pvc_test.yaml index 8e80356..f5cc27c 100644 --- a/charts/hdx-oss-v2/tests/pvc_test.yaml +++ b/charts/hdx-oss-v2/tests/pvc_test.yaml @@ -4,10 +4,10 @@ templates: tests: - it: should render mongodb pvc correctly when enabled set: - persistence: - mongodb: + mongodb: + persistence: enabled: true - size: 10Gi + dataSize: 10Gi global: storageClass: standard asserts: @@ -28,8 +28,8 @@ tests: - it: should not render mongodb pvc when disabled set: - persistence: - mongodb: + mongodb: + persistence: enabled: false asserts: - hasDocuments: @@ -37,10 +37,10 @@ tests: - it: should not include storageClassName when global.storageClass is empty set: - persistence: - mongodb: + mongodb: + persistence: enabled: true - size: 10Gi + dataSize: 10Gi global: storageClass: "" asserts: @@ -51,10 +51,10 @@ tests: - it: should not include storageClassName when global.storageClass is not set set: - persistence: - mongodb: + mongodb: + persistence: enabled: true - size: 10Gi + dataSize: 10Gi asserts: - isKind: of: PersistentVolumeClaim diff --git a/charts/hdx-oss-v2/values.yaml b/charts/hdx-oss-v2/values.yaml index 92603f7..ce47dab 100644 --- a/charts/hdx-oss-v2/values.yaml +++ b/charts/hdx-oss-v2/values.yaml @@ -155,6 +155,9 @@ mongodb: image: "mongo:5.0.14-focal" port: 27017 enabled: true + persistence: + enabled: true + dataSize: 10Gi clickhouse: image: "clickhouse/clickhouse-server:24-alpine" @@ -205,11 +208,6 @@ otel: # Clickhouse database to send logs/traces/metrics to. Defaults to "default" clickhouseDatabase: "default" -persistence: - mongodb: - enabled: true - size: 10Gi - tasks: enabled: false checkAlerts: