Skip to content

Commit 40f2e89

Browse files
authored
feat: support servicetype and annotations for clickhouse svc (#66)
1 parent aa52509 commit 40f2e89

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

.changeset/crazy-dogs-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"helm-charts": patch
3+
---
4+
5+
feat: support servicetype and annotations for clickhouse svc

charts/hdx-oss-v2/templates/clickhouse-deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ metadata:
7474
name: {{ include "hdx-oss.fullname" . }}-clickhouse
7575
labels:
7676
{{- include "hdx-oss.labels" . | nindent 4 }}
77+
{{- if .Values.clickhouse.service.annotations }}
78+
annotations:
79+
{{- with .Values.clickhouse.service.annotations }}
80+
{{- toYaml . | nindent 4 }}
81+
{{- end }}
82+
{{- end }}
7783
spec:
84+
type: {{ .Values.clickhouse.service.type | default "ClusterIP" }}
7885
ports:
7986
- port: {{ .Values.clickhouse.port }}
8087
targetPort: {{ .Values.clickhouse.port }}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
suite: Test Clickhouse Service
2+
templates:
3+
- clickhouse-deployment.yaml
4+
tests:
5+
- it: should use LoadBalancer type when configured
6+
set:
7+
clickhouse:
8+
service:
9+
type: LoadBalancer
10+
asserts:
11+
- documentIndex: 1
12+
equal:
13+
path: spec.type
14+
value: LoadBalancer
15+
16+
- it: should use NodePort type when configured
17+
set:
18+
clickhouse:
19+
service:
20+
type: NodePort
21+
asserts:
22+
- documentIndex: 1
23+
equal:
24+
path: spec.type
25+
value: NodePort
26+
27+
- it: should render service annotations when provided
28+
set:
29+
clickhouse:
30+
service:
31+
annotations:
32+
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
33+
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
34+
asserts:
35+
- documentIndex: 1
36+
equal:
37+
path: metadata.annotations["service.beta.kubernetes.io/aws-load-balancer-internal"]
38+
value: "true"
39+
- documentIndex: 1
40+
equal:
41+
path: metadata.annotations["service.beta.kubernetes.io/aws-load-balancer-type"]
42+
value: "nlb"
43+
44+
- it: should not render annotations section when annotations are empty
45+
set:
46+
clickhouse:
47+
service:
48+
annotations: {}
49+
asserts:
50+
- documentIndex: 1
51+
isNull:
52+
path: metadata.annotations
53+
54+
- it: should combine LoadBalancer type with annotations
55+
set:
56+
clickhouse:
57+
service:
58+
type: LoadBalancer
59+
annotations:
60+
cloud.google.com/load-balancer-type: "Internal"
61+
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
62+
asserts:
63+
- documentIndex: 1
64+
equal:
65+
path: spec.type
66+
value: LoadBalancer
67+
- documentIndex: 1
68+
equal:
69+
path: metadata.annotations["cloud.google.com/load-balancer-type"]
70+
value: "Internal"
71+
- documentIndex: 1
72+
equal:
73+
path: metadata.annotations["service.beta.kubernetes.io/azure-load-balancer-internal"]
74+
value: "true"
75+
76+
- it: should fallback to ClusterIP when service type is not specified
77+
set:
78+
clickhouse:
79+
service: {}
80+
asserts:
81+
- documentIndex: 1
82+
equal:
83+
path: spec.type
84+
value: ClusterIP

charts/hdx-oss-v2/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,16 @@ clickhouse:
235235
# operator: "Equal"
236236
# value: "value1"
237237
# effect: "NoSchedule"
238+
239+
# Service configuration
240+
service:
241+
type: ClusterIP # Use ClusterIP for security. For external access, use ingress with proper TLS and authentication
242+
# Service-level annotations (applied to the Kubernetes service resource)
243+
annotations: {}
244+
# Example service annotations:
245+
# service.beta.kubernetes.io/aws-load-balancer-internal: "true"
246+
# cloud.google.com/load-balancer-type: "Internal"
247+
238248
persistence:
239249
enabled: true
240250
dataSize: 10Gi

0 commit comments

Comments
 (0)