Skip to content

Commit e095219

Browse files
authored
feat: Optimize experience for out of the box installs (#15)
1 parent 1693bca commit e095219

12 files changed

+760
-15
lines changed

charts/hdx-oss-v2/data/config.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
<timezone>UTC</timezone>
2828
<mlock_executable>false</mlock_executable>
2929

30+
{{- if .Values.clickhouse.prometheus.enabled }}
31+
<!-- Prometheus exporter -->
32+
<prometheus>
33+
<endpoint>{{ .Values.clickhouse.prometheus.endpoint }}</endpoint>
34+
<port>{{ .Values.clickhouse.prometheus.port }}</port>
35+
<metrics>true</metrics>
36+
<events>true</events>
37+
<asynchronous_metrics>true</asynchronous_metrics>
38+
<errors>true</errors>
39+
</prometheus>
40+
{{- end }}
41+
3042
<!-- Query log. Used only for queries with setting log_queries = 1. -->
3143
<query_log>
3244
<database>system</database>

charts/hdx-oss-v2/data/users.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
<app>
2626
<password>{{ .Values.clickhouse.config.users.appUserPassword }}</password>
2727
<networks>
28-
<ip>10.0.0.0/8</ip> <!-- Kubernetes cluster IP range -->
28+
{{- if .Values.clickhouse.config.clusterCidrs }}
29+
{{- range .Values.clickhouse.config.clusterCidrs }}
30+
<ip>{{ . }}</ip>
31+
{{- end }}
32+
{{- else }}
33+
<ip>10.0.0.0/8</ip> <!-- Default fallback -->
34+
{{- end }}
2935
<host_regexp>.*\.svc\.cluster\.local$</host_regexp>
3036
</networks>
3137
<profile>readonly</profile>
@@ -39,12 +45,19 @@
3945
<otelcollector>
4046
<password>{{ .Values.clickhouse.config.users.otelUserPassword }}</password>
4147
<networks>
48+
{{- if .Values.clickhouse.config.clusterCidrs }}
49+
{{- range .Values.clickhouse.config.clusterCidrs }}
50+
<ip>{{ . }}</ip>
51+
{{- end }}
52+
{{- else }}
53+
<ip>10.0.0.0/8</ip> <!-- Default fallback -->
54+
{{- end }}
4255
<host_regexp>.*\.svc\.cluster\.local$</host_regexp>
4356
</networks>
4457
<profile>default</profile>
4558
<quota>default</quota>
4659
<grants>
47-
<query>GRANT SELECT,INSERT,SHOW ON default.*</query>
60+
<query>GRANT SELECT,INSERT,CREATE,SHOW ON default.*</query>
4861
</grants>
4962
</otelcollector>
5063
</users>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ spec:
6464
- port: {{ .Values.clickhouse.nativePort }}
6565
targetPort: {{ .Values.clickhouse.nativePort }}
6666
name: native
67+
{{- if .Values.clickhouse.prometheus.enabled }}
68+
- port: {{ .Values.clickhouse.prometheus.port }}
69+
targetPort: {{ .Values.clickhouse.prometheus.port }}
70+
name: prometheus
71+
{{- end }}
6772
selector:
6873
{{- include "hdx-oss.selectorLabels" . | nindent 4 }}
6974
app: clickhouse

charts/hdx-oss-v2/templates/configmaps/app-configmap.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ data:
1717
NEXT_PUBLIC_SERVER_URL: "http://localhost:{{ .Values.hyperdx.apiPort }}"
1818
OTEL_SERVICE_NAME: "hdx-oss-api"
1919
USAGE_STATS_ENABLED: "{{ .Values.hyperdx.usageStatsEnabled | default true }}"
20-
CRON_IN_APP_DISABLED: "{{ .Values.tasks.enabled | default false }}"
20+
CRON_IN_APP_DISABLED: "{{ .Values.tasks.enabled | default false }}"
21+
OPAMP_PORT: "{{ .Values.hyperdx.opampPort }}"
22+
OTEL_EXPORTER_OTLP_ENDPOINT: "{{ tpl .Values.hyperdx.otelExporterEndpoint . }}"

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ spec:
4949
secretKeyRef:
5050
name: {{ include "hdx-oss.fullname" . }}-app-secrets
5151
key: api-key
52+
{{- if .Values.hyperdx.defaultConnections }}
53+
- name: DEFAULT_CONNECTIONS
54+
value: {{ tpl .Values.hyperdx.defaultConnections . | quote }}
55+
{{- end }}
56+
{{- if .Values.hyperdx.defaultSources }}
57+
- name: DEFAULT_SOURCES
58+
value: {{ tpl .Values.hyperdx.defaultSources . | quote }}
59+
{{- end }}
5260
{{- with .Values.hyperdx.env }}
5361
{{- toYaml . | nindent 12 }}
5462
{{- end }}

charts/hdx-oss-v2/templates/otel-collector-deployment.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,23 @@ spec:
3030
env:
3131
- name: CLICKHOUSE_ENDPOINT
3232
value: "{{ .Values.otel.clickhouseEndpoint | default (printf "tcp://%s-clickhouse:%v?dial_timeout=10s" (include "hdx-oss.fullname" .) .Values.clickhouse.nativePort) }}"
33+
- name: CLICKHOUSE_SERVER_ENDPOINT
34+
value: "{{ .Values.otel.clickhouseEndpoint | default (printf "%s-clickhouse:%v" (include "hdx-oss.fullname" .) .Values.clickhouse.nativePort) }}"
35+
{{- if .Values.clickhouse.prometheus.enabled }}
36+
- name: CLICKHOUSE_PROMETHEUS_METRICS_ENDPOINT
37+
value: "{{ .Values.otel.clickhousePrometheusEndpoint | default (printf "%s-clickhouse:%v" (include "hdx-oss.fullname" .) .Values.clickhouse.prometheus.port ) }}"
38+
{{- end }}
39+
- name: OPAMP_SERVER_URL
40+
value: {{ .Values.otel.opampServerUrl | default (printf "%s-app:%v" (include "hdx-oss.fullname" .) .Values.hyperdx.opampPort ) }}
3341
- name: HYPERDX_LOG_LEVEL
3442
value: {{ .Values.hyperdx.logLevel }}
43+
- name: HYPERDX_API_KEY
44+
valueFrom:
45+
secretKeyRef:
46+
name: {{ include "hdx-oss.fullname" . }}-app-secrets
47+
key: api-key
3548
- name: CLICKHOUSE_USER
36-
value: {{ .Values.clickhouse.config.users.otelUser }}
49+
value: "otelcollector"
3750
- name: CLICKHOUSE_PASSWORD
3851
value: {{ .Values.clickhouse.config.users.otelUserPassword }}
3952
---

charts/hdx-oss-v2/templates/secrets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
{{- include "hdx-oss.labels" . | nindent 4 }}
77
type: Opaque
88
data:
9-
api-key: {{ "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | b64enc }}
9+
api-key: {{ .Values.hyperdx.apiKey | b64enc }}
1010
{{- if .Values.clickhouse.enabled }}
1111
---
1212
apiVersion: v1
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
suite: Test ClickHouse Users Configuration
2+
templates:
3+
- clickhouse-deployment.yaml
4+
tests:
5+
- it: should render Deployment with users volume mount
6+
asserts:
7+
- isKind:
8+
of: Deployment
9+
documentIndex: 0
10+
- contains:
11+
path: spec.template.spec.containers[0].volumeMounts
12+
content:
13+
name: users
14+
mountPath: /etc/clickhouse-server/users.xml
15+
subPath: users.xml
16+
documentIndex: 0
17+
- contains:
18+
path: spec.template.spec.volumes
19+
content:
20+
name: users
21+
configMap:
22+
name: RELEASE-NAME-hdx-oss-v2-clickhouse-users
23+
documentIndex: 0
24+
25+
- it: should render users ConfigMap with default values
26+
asserts:
27+
- isKind:
28+
of: ConfigMap
29+
documentIndex: 3
30+
- equal:
31+
path: metadata.name
32+
value: RELEASE-NAME-hdx-oss-v2-clickhouse-users
33+
documentIndex: 3
34+
- isNotEmpty:
35+
path: data
36+
documentIndex: 3
37+
38+
- it: should render users ConfigMap with custom clusterCidrs
39+
set:
40+
clickhouse:
41+
config:
42+
users:
43+
appUserPassword: "customapppass"
44+
otelUserPassword: "customotelpass"
45+
clusterCidrs:
46+
- "10.0.0.0/8"
47+
- "172.16.0.0/12"
48+
- "192.168.0.0/16"
49+
asserts:
50+
- isKind:
51+
of: ConfigMap
52+
documentIndex: 3
53+
- equal:
54+
path: metadata.name
55+
value: RELEASE-NAME-hdx-oss-v2-clickhouse-users
56+
documentIndex: 3
57+
- isNotEmpty:
58+
path: data
59+
documentIndex: 3
60+
61+
- it: should render users ConfigMap with single clusterCidr
62+
set:
63+
clickhouse:
64+
config:
65+
users:
66+
appUserPassword: "singleapppass"
67+
otelUserPassword: "singleotelpass"
68+
clusterCidrs:
69+
- "10.244.0.0/16"
70+
asserts:
71+
- isKind:
72+
of: ConfigMap
73+
documentIndex: 3
74+
- equal:
75+
path: metadata.name
76+
value: RELEASE-NAME-hdx-oss-v2-clickhouse-users
77+
documentIndex: 3
78+
- isNotEmpty:
79+
path: data
80+
documentIndex: 3
81+
82+
- it: should render users ConfigMap with empty clusterCidrs
83+
set:
84+
clickhouse:
85+
config:
86+
users:
87+
appUserPassword: "emptyapppass"
88+
otelUserPassword: "emptyotelpass"
89+
clusterCidrs: []
90+
asserts:
91+
- isKind:
92+
of: ConfigMap
93+
documentIndex: 3
94+
- equal:
95+
path: metadata.name
96+
value: RELEASE-NAME-hdx-oss-v2-clickhouse-users
97+
documentIndex: 3
98+
- isNotEmpty:
99+
path: data
100+
documentIndex: 3
101+
102+
- it: should render users ConfigMap with custom passwords
103+
set:
104+
clickhouse:
105+
config:
106+
users:
107+
appUserPassword: "mySecretAppPassword"
108+
otelUserPassword: "mySecretOtelPassword"
109+
clusterCidrs:
110+
- "10.0.0.0/8"
111+
asserts:
112+
- isKind:
113+
of: ConfigMap
114+
documentIndex: 3
115+
- equal:
116+
path: metadata.name
117+
value: RELEASE-NAME-hdx-oss-v2-clickhouse-users
118+
documentIndex: 3
119+
- isNotEmpty:
120+
path: data
121+
documentIndex: 3
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
suite: Test Default Environment Variables
2+
templates:
3+
- hyperdx-deployment.yaml
4+
tests:
5+
- it: should add DEFAULT_CONNECTIONS env var when configured with secrets
6+
set:
7+
hyperdx:
8+
env:
9+
- name: DEFAULT_CONNECTIONS
10+
valueFrom:
11+
secretKeyRef:
12+
name: hyperdx-connections
13+
key: connections-json
14+
asserts:
15+
- contains:
16+
path: spec.template.spec.containers[0].env
17+
content:
18+
name: DEFAULT_CONNECTIONS
19+
valueFrom:
20+
secretKeyRef:
21+
name: hyperdx-connections
22+
key: connections-json
23+
24+
- it: should add DEFAULT_SOURCES env var when configured with plain value
25+
set:
26+
hyperdx:
27+
env:
28+
- name: DEFAULT_SOURCES
29+
value: '[{"name":"HyperDX Logs","kind":"log","connection":"Local ClickHouse"}]'
30+
asserts:
31+
- contains:
32+
path: spec.template.spec.containers[0].env
33+
content:
34+
name: DEFAULT_SOURCES
35+
value: '[{"name":"HyperDX Logs","kind":"log","connection":"Local ClickHouse"}]'
36+
37+
- it: should add DEFAULT_SOURCES env var when configured with secrets
38+
set:
39+
hyperdx:
40+
env:
41+
- name: DEFAULT_SOURCES
42+
valueFrom:
43+
secretKeyRef:
44+
name: hyperdx-sources
45+
key: sources-json
46+
asserts:
47+
- contains:
48+
path: spec.template.spec.containers[0].env
49+
content:
50+
name: DEFAULT_SOURCES
51+
valueFrom:
52+
secretKeyRef:
53+
name: hyperdx-sources
54+
key: sources-json
55+
56+
- it: should add both DEFAULT_CONNECTIONS and DEFAULT_SOURCES when configured
57+
set:
58+
hyperdx:
59+
env:
60+
- name: DEFAULT_CONNECTIONS
61+
valueFrom:
62+
secretKeyRef:
63+
name: hyperdx-connections
64+
key: connections-json
65+
- name: DEFAULT_SOURCES
66+
valueFrom:
67+
secretKeyRef:
68+
name: hyperdx-sources
69+
key: sources-json
70+
asserts:
71+
- contains:
72+
path: spec.template.spec.containers[0].env
73+
content:
74+
name: DEFAULT_CONNECTIONS
75+
valueFrom:
76+
secretKeyRef:
77+
name: hyperdx-connections
78+
key: connections-json
79+
- contains:
80+
path: spec.template.spec.containers[0].env
81+
content:
82+
name: DEFAULT_SOURCES
83+
valueFrom:
84+
secretKeyRef:
85+
name: hyperdx-sources
86+
key: sources-json
87+
88+
- it: should include DEFAULT_CONNECTIONS and DEFAULT_SOURCES by default
89+
asserts:
90+
- isNotEmpty:
91+
path: spec.template.spec.containers[0].env[?(@.name=="DEFAULT_CONNECTIONS")]
92+
- isNotEmpty:
93+
path: spec.template.spec.containers[0].env[?(@.name=="DEFAULT_SOURCES")]
94+
95+
- it: should not include DEFAULT_CONNECTIONS when set to empty string
96+
set:
97+
hyperdx:
98+
defaultConnections: ""
99+
asserts:
100+
- notContains:
101+
path: spec.template.spec.containers[0].env
102+
content:
103+
name: DEFAULT_CONNECTIONS
104+
105+
- it: should not include DEFAULT_SOURCES when set to empty string
106+
set:
107+
hyperdx:
108+
defaultSources: ""
109+
asserts:
110+
- notContains:
111+
path: spec.template.spec.containers[0].env
112+
content:
113+
name: DEFAULT_SOURCES
114+
115+
- it: should work with multiline JSON value for DEFAULT_SOURCES
116+
set:
117+
hyperdx:
118+
env:
119+
- name: DEFAULT_SOURCES
120+
value: |
121+
[
122+
{
123+
"name": "HyperDX Logs",
124+
"kind": "log",
125+
"connection": "Local ClickHouse",
126+
"from": {
127+
"databaseName": "default",
128+
"tableName": "logs"
129+
}
130+
}
131+
]
132+
asserts:
133+
- contains:
134+
path: spec.template.spec.containers[0].env
135+
content:
136+
name: DEFAULT_SOURCES
137+
value: |
138+
[
139+
{
140+
"name": "HyperDX Logs",
141+
"kind": "log",
142+
"connection": "Local ClickHouse",
143+
"from": {
144+
"databaseName": "default",
145+
"tableName": "logs"
146+
}
147+
}
148+
]

0 commit comments

Comments
 (0)