Files
cozystack/packages/extra/monitoring/templates/workloadmonitors.yaml
T
Alexey Artamonov 27b7376bb9 feat(monitoring): add a shared-central tracing topology
A per-tenant traces backend costs every tenant its own VictoriaTraces
stack. A tenant can now send new spans to one shared store in
tenant-root instead, switched on by _namespace.tracingCentral, which
the tenant chart publishes and the apps API does not let an
application set. tenant-root decides whether it hosts that store, with
tracingCentralHost next to a cluster-mode store named generic.

VictoriaTraces takes the tenant account from request headers and does
no authorization of its own, so other tenants reach the store only
through a vmauth in tenant-root; tenant-root itself, with whoever it
admits to its Grafana, stays inside the trust boundary. Each central
tenant gets a VMUser that pins an account derived from its namespace
name and UID for both writes and reads and caps its requests in
flight, which the collector's two export senders stay under; its
collector exports and its Grafana reads with credentials the chart
generates and keeps, and vmauth overrides any account a client sends.
The chart owns those credentials because the operator publishes a
VMUser's own Secret only once a VMAuth selects it; the collector rolls
when they change, since it reads them at start. The vmauth internal
routes, whose /metrics names every tenant's user, are served on a port
tenants cannot reach, and the vmauth is sized by a VPA, spread across
nodes under a disruption budget, has a WorkloadMonitor like the other
monitoring workloads, and may reach the apiserver, where its
config-reloader reads its config Secret.

Renders refuse the states in which spans would be dropped with every
object Ready: a central tenant while tenant-root hosts nothing,
tenant-root dropping the hosting while central tenants remain, and
the host flag without a store to host. Each refusal reads the other
side at render time, so a concurrent opt-in and stop-hosting can pass
both; the values text names that race and its recovery. At run time
tenant-root's release is not Ready while the vmauth has failed.
Only the collector's export moves: local stores the tenant still lists
keep rendering with their datasources, because the switch belongs to
the parent tenant and the stores to this one, and the one-store limit
of the collector holds in both modes, since turning central off makes
it export locally again. tenant-root never counts as central.

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-30 22:23:47 +03:00

216 lines
4.8 KiB
YAML

{{- range .Values.metricsStorages }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: {{ .name }}-vmstorage
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: vmstorage
selector:
app.kubernetes.io/component: monitoring
app.kubernetes.io/instance: {{ .name }}
app.kubernetes.io/name: vmstorage
version: {{ $.Chart.Version }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: {{ .name }}-vmselect
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: vmselect
selector:
app.kubernetes.io/component: monitoring
app.kubernetes.io/instance: {{ .name }}
app.kubernetes.io/name: vmselect
version: {{ $.Chart.Version }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: {{ .name }}-vminsert
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: vminsert
selector:
app.kubernetes.io/component: monitoring
app.kubernetes.io/instance: {{ .name }}
app.kubernetes.io/name: vminsert
version: {{ $.Chart.Version }}
{{- end }}
{{- range .Values.metricsStorages }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: vmalert-{{ .name }}
spec:
replicas: 1
minReplicas: 1
kind: monitoring
type: vmalert
selector:
app.kubernetes.io/instance: vmalert-{{ .name }}
app.kubernetes.io/name: vmalert
version: {{ $.Chart.Version }}
{{- break }}
{{- end }}
{{- range .Values.logsStorages }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: {{ .name }}-vlstorage
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: vlstorage
selector:
app.kubernetes.io/component: monitoring
app.kubernetes.io/instance: {{ .name }}
app.kubernetes.io/name: vlstorage
version: {{ $.Chart.Version }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: {{ .name }}-vlselect
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: vlselect
selector:
app.kubernetes.io/component: monitoring
app.kubernetes.io/instance: {{ .name }}
app.kubernetes.io/name: vlselect
version: {{ $.Chart.Version }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: {{ .name }}-vlinsert
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: vlinsert
selector:
app.kubernetes.io/component: monitoring
app.kubernetes.io/instance: {{ .name }}
app.kubernetes.io/name: vlinsert
version: {{ $.Chart.Version }}
{{- end }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: grafana
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: grafana
selector:
app: grafana
version: {{ $.Chart.Version }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: grafana-db
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: postgres
selector:
cnpg.io/cluster: grafana-db
cnpg.io/podRole: instance
version: {{ $.Chart.Version }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: alerta-db
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: postgres
selector:
cnpg.io/cluster: alerta-db
cnpg.io/podRole: instance
version: {{ $.Chart.Version }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: alerta
spec:
replicas: 1
minReplicas: 1
kind: monitoring
type: alerta
selector:
app: alerta
release: alerta
version: {{ $.Chart.Version }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: alertmanager
spec:
replicas: 3
minReplicas: 2
kind: monitoring
type: alertmanager
selector:
app.kubernetes.io/instance: alertmanager
app.kubernetes.io/name: vmalertmanager
version: {{ $.Chart.Version }}
{{- /* The OTLP trace collector renders under the same gate as the collector
itself (tracingCollector.enabled AND either a local tracingStorages backend
or central mode), so tenant workload accounting covers it like every other
monitoring component. expectedReplicas tracks the configured replica count. */}}
{{- if and .Values.tracingCollector.enabled (or (include "monitoring.tracingCentral" .) (not (empty .Values.tracingStorages))) }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: otel-traces
spec:
replicas: {{ .Values.tracingCollector.replicas }}
minReplicas: 1
kind: monitoring
type: otel-collector
selector:
app.kubernetes.io/name: otel-traces
version: {{ $.Chart.Version }}
{{- end }}
{{- if include "monitoring.tracingCentralStore" . }}
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
name: vmauth-traces-central
spec:
replicas: 2
minReplicas: 1
kind: monitoring
type: vmauth
selector:
app.kubernetes.io/instance: traces-central
app.kubernetes.io/name: vmauth
version: {{ $.Chart.Version }}
{{- end }}