From b1c314ceae8b9f8697fee0d10d34039887837d7b Mon Sep 17 00:00:00 2001 From: Aviansh Gupta Date: Fri, 4 Jul 2025 22:01:18 +0530 Subject: [PATCH 1/3] feat: support servicetype and annotations for clickhouse svc --- .changeset/crazy-dogs-beg.md | 5 ++ .../templates/clickhouse-deployment.yaml | 7 ++ .../tests/clickhouse-service_test.yaml | 75 +++++++++++++++++++ charts/hdx-oss-v2/values.yaml | 10 +++ 4 files changed, 97 insertions(+) create mode 100644 .changeset/crazy-dogs-beg.md create mode 100644 charts/hdx-oss-v2/tests/clickhouse-service_test.yaml diff --git a/.changeset/crazy-dogs-beg.md b/.changeset/crazy-dogs-beg.md new file mode 100644 index 0000000..e12c5f4 --- /dev/null +++ b/.changeset/crazy-dogs-beg.md @@ -0,0 +1,5 @@ +--- +"helm-charts": patch +--- + +feat: support servicetype and annotations for clickhouse svc diff --git a/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml b/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml index 66c0176..81bd58d 100644 --- a/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml +++ b/charts/hdx-oss-v2/templates/clickhouse-deployment.yaml @@ -74,7 +74,14 @@ metadata: name: {{ include "hdx-oss.fullname" . }}-clickhouse labels: {{- include "hdx-oss.labels" . | nindent 4 }} + {{- if .Values.clickhouse.service.annotations }} + annotations: + {{- with .Values.clickhouse.service.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} spec: + type: {{ .Values.clickhouse.service.type | default "ClusterIP" }} ports: - port: {{ .Values.clickhouse.port }} targetPort: {{ .Values.clickhouse.port }} diff --git a/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml b/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml new file mode 100644 index 0000000..1a8e677 --- /dev/null +++ b/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml @@ -0,0 +1,75 @@ +suite: Test Clickhouse Service +templates: + - clickhouse-deployment.yaml +tests: + - it: should use LoadBalancer type when configured + set: + clickhouse: + service: + type: LoadBalancer + asserts: + - equal: + path: spec.type + value: LoadBalancer + + - it: should use NodePort type when configured + set: + clickhouse: + service: + type: NodePort + asserts: + - equal: + path: spec.type + value: NodePort + + - it: should render service annotations when provided + set: + clickhouse: + service: + annotations: + service.beta.kubernetes.io/aws-load-balancer-internal: "true" + service.beta.kubernetes.io/aws-load-balancer-type: "nlb" + asserts: + - equal: + path: metadata.annotations["service.beta.kubernetes.io/aws-load-balancer-internal"] + value: "true" + - equal: + path: metadata.annotations["service.beta.kubernetes.io/aws-load-balancer-type"] + value: "nlb" + + - it: should not render annotations section when annotations are empty + set: + hyperdx: + service: + annotations: {} + asserts: + - isNull: + path: metadata.annotations + + - it: should combine LoadBalancer type with annotations + set: + clickhouse: + service: + type: LoadBalancer + annotations: + cloud.google.com/load-balancer-type: "Internal" + service.beta.kubernetes.io/azure-load-balancer-internal: "true" + asserts: + - equal: + path: spec.type + value: LoadBalancer + - equal: + path: metadata.annotations["cloud.google.com/load-balancer-type"] + value: "Internal" + - equal: + path: metadata.annotations["service.beta.kubernetes.io/azure-load-balancer-internal"] + value: "true" + + - it: should fallback to ClusterIP when service type is not specified + set: + clickhouse: + service: {} + asserts: + - equal: + path: spec.type + value: ClusterIP diff --git a/charts/hdx-oss-v2/values.yaml b/charts/hdx-oss-v2/values.yaml index 7b86a60..c45d811 100644 --- a/charts/hdx-oss-v2/values.yaml +++ b/charts/hdx-oss-v2/values.yaml @@ -235,6 +235,16 @@ clickhouse: # operator: "Equal" # value: "value1" # effect: "NoSchedule" + + # Service configuration + service: + type: ClusterIP # Use ClusterIP for security. For external access, use ingress with proper TLS and authentication + # Service-level annotations (applied to the Kubernetes service resource) + annotations: {} + # Example service annotations: + # service.beta.kubernetes.io/aws-load-balancer-internal: "true" + # cloud.google.com/load-balancer-type: "Internal" + persistence: enabled: true dataSize: 10Gi From 50de2db68ddbec6f0457c156988843adb56a0ad9 Mon Sep 17 00:00:00 2001 From: Aviansh Gupta Date: Fri, 4 Jul 2025 22:43:28 +0530 Subject: [PATCH 2/3] fix: unittest --- charts/hdx-oss-v2/tests/clickhouse-service_test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml b/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml index 1a8e677..cf35f05 100644 --- a/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml +++ b/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml @@ -39,7 +39,7 @@ tests: - it: should not render annotations section when annotations are empty set: - hyperdx: + clickhouse: service: annotations: {} asserts: From 1f8e1bcf90f6bec459bd97644c324ed05fc8a0d9 Mon Sep 17 00:00:00 2001 From: Aviansh Gupta Date: Mon, 7 Jul 2025 21:45:57 +0530 Subject: [PATCH 3/3] fix: unittest - documentIndex added --- .../tests/clickhouse-service_test.yaml | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml b/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml index cf35f05..8ff00b3 100644 --- a/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml +++ b/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml @@ -8,7 +8,8 @@ tests: service: type: LoadBalancer asserts: - - equal: + - documentIndex: 1 + equal: path: spec.type value: LoadBalancer @@ -18,7 +19,8 @@ tests: service: type: NodePort asserts: - - equal: + - documentIndex: 1 + equal: path: spec.type value: NodePort @@ -30,10 +32,12 @@ tests: service.beta.kubernetes.io/aws-load-balancer-internal: "true" service.beta.kubernetes.io/aws-load-balancer-type: "nlb" asserts: - - equal: + - documentIndex: 1 + equal: path: metadata.annotations["service.beta.kubernetes.io/aws-load-balancer-internal"] value: "true" - - equal: + - documentIndex: 1 + equal: path: metadata.annotations["service.beta.kubernetes.io/aws-load-balancer-type"] value: "nlb" @@ -43,7 +47,8 @@ tests: service: annotations: {} asserts: - - isNull: + - documentIndex: 1 + isNull: path: metadata.annotations - it: should combine LoadBalancer type with annotations @@ -55,13 +60,16 @@ tests: cloud.google.com/load-balancer-type: "Internal" service.beta.kubernetes.io/azure-load-balancer-internal: "true" asserts: - - equal: + - documentIndex: 1 + equal: path: spec.type value: LoadBalancer - - equal: + - documentIndex: 1 + equal: path: metadata.annotations["cloud.google.com/load-balancer-type"] value: "Internal" - - equal: + - documentIndex: 1 + equal: path: metadata.annotations["service.beta.kubernetes.io/azure-load-balancer-internal"] value: "true" @@ -70,6 +78,7 @@ tests: clickhouse: service: {} asserts: - - equal: + - documentIndex: 1 + equal: path: spec.type value: ClusterIP