Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dashboards-include-release-namespace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"helm-charts": minor
---

feat: add `hyperdx.dashboards.includeReleaseNamespace` (default `true`, unchanged behaviour). Set it to `false` with `hyperdx.dashboards.namespaces: [<ns>]` to confine the dashboard watcher, and its ConfigMap read access, to the listed namespaces: the chart then renders a namespaced Role and RoleBinding in each listed namespace, no ClusterRole, and nothing in the release namespace. Those objects are named `<fullname>-<release namespace>-dashboard-provisioner-scoped`, distinct from the RoleBindings the cross-namespace mode renders, so the flag can be flipped either way on an existing install: no upgrade has to change an existing RoleBinding's `roleRef`. The render fails if it is `false` with no namespaces listed, or with inline `configMaps` while the release namespace is not watched.
2 changes: 1 addition & 1 deletion charts/clickstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Documented values below. Undocumented keys (operator CRD passthrough fields, sub
| global.imageRegistry | string | `""` | Optional prefix for container images (e.g. registry.example.com/). |
| hyperdx.autoscaling | object | `{"enabled":false,"spec":{}}` | HorizontalPodAutoscaler for HyperDX. spec is passed through verbatim (autoscaling/v2). Do not include scaleTargetRef — the chart auto-wires it. When enabled, omit deployment.replicas; disabling autoscaling reverts to deployment.replicas (default 1). |
| hyperdx.config | object | `{"API_PORT":"8000","APP_PORT":"3000","CLICKHOUSE_ENDPOINT":"tcp://{{ include \"clickstack.clickhouse.svc\" . }}:{{ .Values.clickhouse.nativePort }}?dial_timeout=10s","CLICKHOUSE_PROMETHEUS_METRICS_ENDPOINT":"{{ include \"clickstack.clickhouse.svc\" . }}:{{ .Values.clickhouse.prometheus.port }}","CLICKHOUSE_SERVER_ENDPOINT":"{{ include \"clickstack.clickhouse.svc\" . }}:{{ .Values.clickhouse.nativePort }}","CLICKHOUSE_USER":"otelcollector","ENABLE_PROMQL":"{{ if .Values.hyperdx.promql.enabled }}true{{ else }}false{{ end }}","FRONTEND_URL":"http://localhost:3000","HDX_EXPORTER_ENABLED":"{{ if .Values.hyperdx.config.NEXT_PUBLIC_OTEL_EXPORTER_OTLP_ENDPOINT }}true{{ else }}false{{ end }}","HYPERDX_API_PORT":"8000","HYPERDX_APP_PORT":"3000","HYPERDX_LOG_LEVEL":"info","HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE":"default","HYPERDX_OTEL_EXPORTER_TABLES_TTL":"720h","MONGO_URI":"mongodb://hyperdx:{{ .Values.hyperdx.secrets.MONGODB_PASSWORD }}@{{ include \"clickstack.mongodb.svc\" . }}:27017/hyperdx?authSource=hyperdx","NEXT_PUBLIC_ENABLE_PROMQL":"{{ if .Values.hyperdx.promql.enabled }}true{{ else }}false{{ end }}","OPAMP_PORT":"4320","OPAMP_SERVER_URL":"http://{{ include \"clickstack.hyperdx.fullname\" . }}:{{ .Values.hyperdx.ports.opamp }}","OTEL_EXPORTER_OTLP_ENDPOINT":"http://{{ include \"clickstack.otel.fullname\" . }}:4318","OTEL_SERVICE_NAME":"hdx-oss-api","RUN_SCHEDULED_TASKS_EXTERNALLY":"false","USAGE_STATS_ENABLED":"true"}` | Shared non-sensitive environment variables (clickstack-config ConfigMap). Used by HyperDX and OTEL collector via envFrom. Values support tpl expressions. Override entries with plain strings to point at external services. Changes to the rendered ConfigMap roll the HyperDX Deployment; the otel-collector rolls on every helm upgrade. |
| hyperdx.dashboards | object | `{"configMaps":{},"enabled":false,"namespaces":[],"rbac":{"create":true},"resources":{"limits":{"cpu":"50m","memory":"128Mi"},"requests":{"cpu":"10m","memory":"64Mi"}},"sidecarImage":"kiwigrid/k8s-sidecar:2.10.1","sidecarPullPolicy":"IfNotPresent"}` | Dashboard provisioning: upserts dashboard JSON into MongoDB (matched by name, never deletes). Provide dashboards inline via configMaps, or label ConfigMaps hyperdx.io/dashboard: "true" for a k8s-sidecar watcher to discover. |
| hyperdx.dashboards | object | `{"configMaps":{},"enabled":false,"includeReleaseNamespace":true,"namespaces":[],"rbac":{"create":true},"resources":{"limits":{"cpu":"50m","memory":"128Mi"},"requests":{"cpu":"10m","memory":"64Mi"}},"sidecarImage":"kiwigrid/k8s-sidecar:2.10.1","sidecarPullPolicy":"IfNotPresent"}` | Dashboard provisioning: upserts dashboard JSON into MongoDB (matched by name, never deletes). Provide dashboards inline via configMaps, or label ConfigMaps hyperdx.io/dashboard: "true" for a k8s-sidecar watcher to discover. |
| hyperdx.deployment | object | `{"annotations":{},"containerSecurityContext":{},"defaultConnections":"[\n {\n \"name\": \"Local ClickHouse\",\n \"host\": \"http://{{ include \"clickstack.clickhouse.svc\" . }}:8123\",\n \"port\": 8123,\n \"username\": \"app\",\n \"password\": \"{{ .Values.hyperdx.secrets.CLICKHOUSE_APP_PASSWORD }}\"\n }\n]\n","defaultSources":"[\n {\n \"from\": {\n \"databaseName\": \"default\",\n \"tableName\": \"otel_logs\"\n },\n \"kind\": \"log\",\n \"timestampValueExpression\": \"Timestamp\",\n \"name\": \"Logs\",\n \"displayedTimestampValueExpression\": \"Timestamp\",\n \"implicitColumnExpression\": \"Body\",\n \"serviceNameExpression\": \"ServiceName\",\n \"bodyExpression\": \"Body\",\n \"eventAttributesExpression\": \"LogAttributes\",\n \"resourceAttributesExpression\": \"ResourceAttributes\",\n \"defaultTableSelectExpression\": \"Timestamp,ServiceName,SeverityText,Body\",\n \"severityTextExpression\": \"SeverityText\",\n \"traceIdExpression\": \"TraceId\",\n \"spanIdExpression\": \"SpanId\",\n \"connection\": \"Local ClickHouse\",\n \"traceSourceId\": \"Traces\",\n \"metricSourceId\": \"Metrics\"\n },\n {\n \"from\": {\n \"databaseName\": \"default\",\n \"tableName\": \"otel_traces\"\n },\n \"kind\": \"trace\",\n \"timestampValueExpression\": \"Timestamp\",\n \"name\": \"Traces\",\n \"displayedTimestampValueExpression\": \"Timestamp\",\n \"implicitColumnExpression\": \"SpanName\",\n \"serviceNameExpression\": \"ServiceName\",\n \"eventAttributesExpression\": \"SpanAttributes\",\n \"resourceAttributesExpression\": \"ResourceAttributes\",\n \"defaultTableSelectExpression\": \"Timestamp,ServiceName,StatusCode,round(Duration/1e6),SpanName\",\n \"traceIdExpression\": \"TraceId\",\n \"spanIdExpression\": \"SpanId\",\n \"durationExpression\": \"Duration\",\n \"durationPrecision\": 9,\n \"parentSpanIdExpression\": \"ParentSpanId\",\n \"spanNameExpression\": \"SpanName\",\n \"spanKindExpression\": \"SpanKind\",\n \"statusCodeExpression\": \"StatusCode\",\n \"statusMessageExpression\": \"StatusMessage\",\n \"spanEventsValueExpression\": \"Events\",\n \"spanLinksValueExpression\": \"Links\",\n \"connection\": \"Local ClickHouse\",\n \"logSourceId\": \"Logs\",\n \"sessionSourceId\": \"Sessions\",\n \"metricSourceId\": \"Metrics\"\n },\n {\n \"from\": {\n \"databaseName\": \"default\",\n \"tableName\": \"\"\n },\n \"kind\": \"metric\",\n \"timestampValueExpression\": \"TimeUnix\",\n \"name\": \"Metrics\",\n \"resourceAttributesExpression\": \"ResourceAttributes\",\n \"metricTables\": {\n \"gauge\": \"otel_metrics_gauge\",\n \"histogram\": \"otel_metrics_histogram\",\n \"sum\": \"otel_metrics_sum\",\n \"summary\": \"otel_metrics_summary\",\n \"exponential histogram\": \"otel_metrics_exponential_histogram\"\n },\n \"connection\": \"Local ClickHouse\",\n \"logSourceId\": \"Logs\"\n },\n {\n \"from\": {\n \"databaseName\": \"default\",\n \"tableName\": \"hyperdx_sessions\"\n },\n \"kind\": \"session\",\n \"timestampValueExpression\": \"TimestampTime\",\n \"name\": \"Sessions\",\n \"resourceAttributesExpression\": \"ResourceAttributes\",\n \"connection\": \"Local ClickHouse\",\n \"traceSourceId\": \"Traces\"\n },\n {\n \"from\": {\n \"databaseName\": \"default\",\n \"tableName\": \"metrics_ts\"\n },\n \"kind\": \"promql\",\n \"timestampValueExpression\": \"timestamp\",\n \"name\": \"PromQL\",\n \"connection\": \"Local ClickHouse\"\n }\n]\n","deploymentAnnotations":{},"env":[],"existingConfigConnectionsKey":"connections.json","existingConfigSecret":"","existingConfigSourcesKey":"sources.json","image":{"pullPolicy":"IfNotPresent","repository":"docker.hyperdx.io/hyperdx/hyperdx","tag":null},"initContainers":[],"labels":{},"livenessProbe":{"enabled":true,"failureThreshold":3,"initialDelaySeconds":10,"path":"/health","periodSeconds":30,"timeoutSeconds":5},"nodeSelector":{},"podAnnotations":{},"podLabels":{},"podSecurityContext":{},"priorityClassName":"","readinessProbe":{"enabled":true,"failureThreshold":3,"initialDelaySeconds":1,"path":"/ready","periodSeconds":10,"timeoutSeconds":5},"replicas":1,"resources":{},"tolerations":[],"topologySpreadConstraints":[],"useExistingConfigSecret":false,"volumeMounts":[],"volumes":[],"waitForMongodb":{"image":"busybox@sha256:1fcf5df59121b92d61e066df1788e8df0cc35623f5d62d9679a41e163b6a0cdb","pullPolicy":"IfNotPresent"}}` | HyperDX Deployment spec (image, probes, scheduling, init containers, volumes). defaultConnections/defaultSources JSON: set to "" to disable; use useExistingConfigSecret for external secrets. |
| hyperdx.deployment.env | list | `[]` | Extra environment variables for the HyperDX container, rendered verbatim (supports `valueFrom`, e.g. `secretKeyRef`). |
| hyperdx.deployment.existingConfigSecret | string | `""` | Secret containing connections and sources JSON when useExistingConfigSecret is true. |
Expand Down
40 changes: 31 additions & 9 deletions charts/clickstack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ user's setting (passwords, replicas, opt-outs) would fall back to the default.
{{/*
Fail fast on invalid dashboards input instead of surfacing Go template panics or
API-server rejections: unusable ServiceAccount config, a non-list or ill-typed
namespaces value, the contradictory ALL-plus-named-namespaces scope, malformed
namespaces value, the contradictory ALL-plus-named-namespaces scope, an empty scope
or unwatched inline dashboards when the release namespace is excluded, malformed
configMaps entries, and volume/mount names that collide with the provisioner's.
*/}}
{{- define "clickstack.hyperdx.validateDashboards" -}}
Expand All @@ -163,6 +164,12 @@ configMaps entries, and volume/mount names that collide with the provisioner's.
{{- fail "hyperdx.dashboards.namespaces: entries must be quoted strings" -}}
{{- end -}}
{{- end -}}
{{- if and (ne (include "clickstack.hyperdx.dashboardsIncludeReleaseNamespace" .) "true") (not $namespaces) -}}
{{- fail "hyperdx.dashboards.includeReleaseNamespace: false requires at least one entry in hyperdx.dashboards.namespaces (otherwise the watcher has nothing to watch)" -}}
{{- end -}}
{{- if and $dashboards.configMaps (ne (include "clickstack.hyperdx.dashboardsClusterWide" .) "true") (not (has .Release.Namespace (include "clickstack.hyperdx.effectiveNamespaces" . | splitList ","))) -}}
{{- fail "hyperdx.dashboards.configMaps: inline dashboards are created in the release namespace, which includeReleaseNamespace: false excludes from discovery; list the release namespace in hyperdx.dashboards.namespaces or ship the dashboards as labeled ConfigMaps in a watched namespace" -}}
{{- end -}}
{{- if and (eq (include "clickstack.hyperdx.dashboardsClusterWide" .) "true") (gt (len $namespaces) 1) -}}
{{- fail "hyperdx.dashboards.namespaces: \"ALL\" cannot be combined with specific namespaces (it already grants cluster-wide discovery)" -}}
{{- end -}}
Expand Down Expand Up @@ -200,15 +207,16 @@ configMaps entries, and volume/mount names that collide with the provisioner's.

{{/*
Namespaces the watcher discovers in for the non-ALL scope: the release namespace
plus any configured extras, deduped and comma-joined. Single source for both the
watcher NAMESPACE env and the per-namespace RoleBindings so watch scope and granted
scope can't drift.
(unless includeReleaseNamespace is false) plus any configured extras, deduped and
comma-joined. Single source for both the watcher NAMESPACE env and the per-namespace
RBAC objects so watch scope and granted scope can't drift.
*/}}
{{- define "clickstack.hyperdx.effectiveNamespaces" -}}
{{- $raw := default (list) (default (dict) .Values.hyperdx.dashboards).namespaces -}}
{{- $namespaces := ternary $raw (list) (kindIs "slice" $raw) -}}
{{- $base := ternary (list .Release.Namespace) (list) (eq (include "clickstack.hyperdx.dashboardsIncludeReleaseNamespace" .) "true") -}}
{{- $trimmed := list -}}
{{- range (concat (list .Release.Namespace) $namespaces) -}}
{{- range (concat $base $namespaces) -}}
{{- $trimmed = append $trimmed (trim (toString .)) -}}
{{- end -}}
{{- $trimmed | uniq | join "," -}}
Expand All @@ -225,12 +233,26 @@ Deployment, so the granted scope and the watched scope can't diverge. Renders "t
{{- end -}}

{{/*
Whether discovery spans more than one namespace (the effective, deduped set is larger
than just the release namespace). Selects the scoped ClusterRole + per-namespace
RoleBinding path over a plain namespaced Role. Renders "true" or "".
Whether discovery spans the release namespace plus at least one other namespace.
Selects the scoped ClusterRole + per-namespace RoleBinding path over namespaced
Roles. An effective set without the release namespace (includeReleaseNamespace:
false) gets a namespaced Role + RoleBinding in each target namespace instead, so
nothing is granted in the release namespace and no cluster-scoped object is
created. Renders "true" or "".
*/}}
{{- define "clickstack.hyperdx.dashboardsCrossNamespace" -}}
{{- if gt (len (include "clickstack.hyperdx.effectiveNamespaces" . | splitList ",")) 1 }}true{{- end -}}
{{- $effective := include "clickstack.hyperdx.effectiveNamespaces" . | splitList "," -}}
{{- if and (gt (len $effective) 1) (has .Release.Namespace $effective) }}true{{- end -}}
{{- end -}}

{{/*
Whether the release namespace is part of the watcher's discovery scope. A missing
key (e.g. an upgrade with --reuse-values from a chart version without it) keeps the
chart default of true. Renders "true" or "".
*/}}
{{- define "clickstack.hyperdx.dashboardsIncludeReleaseNamespace" -}}
{{- $dashboards := default (dict) .Values.hyperdx.dashboards -}}
{{- if or (not (hasKey $dashboards "includeReleaseNamespace")) $dashboards.includeReleaseNamespace }}true{{- end -}}
{{- end -}}

{{/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,37 @@ subjects:
namespace: {{ $.Release.Namespace }}
{{- end }}
{{- else }}
{{- /* Default: discovery scoped to the release namespace only — a namespaced Role, no cluster-scoped objects. */}}
{{- /* Default: discovery scoped to the release namespace only — a namespaced Role, no cluster-scoped objects. With includeReleaseNamespace: false, the same namespaced Role + RoleBinding pair is rendered in each target namespace instead, and nothing in the release namespace. Outside the release namespace the names are namespace-qualified like the cluster-scoped objects above, so two same-named releases can't collide in a shared target namespace, and carry a -scoped suffix so they never reuse the name of the cross-namespace path's RoleBinding (roleRef ClusterRole) in that namespace: roleRef is immutable, so flipping includeReleaseNamespace on an existing install would otherwise fail the upgrade. The suffix always survives: $clusterName is at most 149 characters (fullname and namespace are at most 63 each), well under the 253 RBAC names allow. */}}
{{- range $i, $ns := (include "clickstack.hyperdx.effectiveNamespaces" . | splitList ",") }}
{{- $name := ternary (printf "%s-dashboard-provisioner" $fullname) (printf "%s-scoped" $clusterName) (eq $ns $.Release.Namespace) }}
{{- if $i }}
---
{{- end }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ $fullname }}-dashboard-provisioner
namespace: {{ .Release.Namespace }}
name: {{ $name }}
namespace: {{ $ns }}
labels:
{{- include "clickstack.labels" . | nindent 4 }}
{{- include "clickstack.labels" $ | nindent 4 }}
rules:
{{- include "clickstack.hyperdx.dashboardRbacRules" . | nindent 2 }}
{{- include "clickstack.hyperdx.dashboardRbacRules" $ | nindent 2 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ $fullname }}-dashboard-provisioner
namespace: {{ .Release.Namespace }}
name: {{ $name }}
namespace: {{ $ns }}
labels:
{{- include "clickstack.labels" . | nindent 4 }}
{{- include "clickstack.labels" $ | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ $fullname }}-dashboard-provisioner
name: {{ $name }}
subjects:
- kind: ServiceAccount
name: {{ $saName }}
namespace: {{ .Release.Namespace }}
namespace: {{ $.Release.Namespace }}
{{- end }}
{{- end }}
{{- end }}
Loading
Loading