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 0407207..cd99ccf 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..8ff00b3 --- /dev/null +++ b/charts/hdx-oss-v2/tests/clickhouse-service_test.yaml @@ -0,0 +1,84 @@ +suite: Test Clickhouse Service +templates: + - clickhouse-deployment.yaml +tests: + - it: should use LoadBalancer type when configured + set: + clickhouse: + service: + type: LoadBalancer + asserts: + - documentIndex: 1 + equal: + path: spec.type + value: LoadBalancer + + - it: should use NodePort type when configured + set: + clickhouse: + service: + type: NodePort + asserts: + - documentIndex: 1 + 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: + - documentIndex: 1 + equal: + path: metadata.annotations["service.beta.kubernetes.io/aws-load-balancer-internal"] + value: "true" + - documentIndex: 1 + 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: + clickhouse: + service: + annotations: {} + asserts: + - documentIndex: 1 + 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: + - documentIndex: 1 + equal: + path: spec.type + value: LoadBalancer + - documentIndex: 1 + equal: + path: metadata.annotations["cloud.google.com/load-balancer-type"] + value: "Internal" + - documentIndex: 1 + 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: + - documentIndex: 1 + 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