lgtm-stack

by Spartan

Helm chartv0.20.0

LGTM Lite (Prometheus, Alertmanager, Grafana, Loki, Alloy, Tempo, OTel Operator) as ArgoCD Applications

About this chart

lgtm-stack

LGTM Lite as ArgoCD Applications: Prometheus + Alertmanager (kube-prometheus-stack), Grafana, Loki, Alloy, Tempo and the OpenTelemetry Operator, with the Spartan presets built in. The chart renders ArgoCD Application CRs (app of apps), not the workloads themselves, so each component keeps its own sync wave, retries and ignored diffs.

A project installs it as one Application and keeps one values file. Updating the stack is a chart version bump.

Tenant dashboard delivery

Tenant organization mapping and confined parent folders are enabled exactly when at least one tenant has non-empty tenants[].grafana.viewers or editors groups. The rule applies to the whole tenant list. Dashboard delivery starts per tenant when tenants[].grafana.orgId is set and requires org mapping to be enabled. When at least one tenant has an org id, the main sidecar watches only grafana.tenantDashboards.platformNamespaces (default [monitoring]). This list must be nonempty and must not contain any tenant namespace. Delivery overrides through extraContainers, extraVolumes, extraVolumeMounts, extraObjects, sidecar.dashboards.searchNamespace or the generated dashboardProviders.tenant-dashboardproviders.yaml key in components.grafana.values are rejected. Without any org ids, dashboard delivery settings and validations do not apply; the main sidecar is unchanged.

Set tenants[].grafana.orgId only after the org exists, using the numeric id logged by the tenant-orgs job. Grafana org ids autoincrement and are not reused; after a Grafana DB reset or org deletion, unset the stale orgId or re-read it from the job log before the next sync. A provider for a missing org makes Grafana exit 1. First add tenant Grafana groups and sync without orgId to create the org and folder; a second change sets its id. A tenant without an id gets no dashboard sidecar, providers or sentinel. Never delete the org or reset the Grafana database while its id is set. For recovery, unset orgId then sync so Grafana starts without the missing-org provider.

Each configured tenant gets a sidecar watching its namespaces, two providers in its org and folder with uid equal to the tenant id, and an unlabelled home ConfigMap delivered through Grafana's extraObjects. The protected <tenant>-home dashboard prevents deletion of the parent folder. Git dashboards are read-only; copy them into the tenant folder to edit them.

Tenant dashboards appear within about 30 seconds through provider polling. The tenant sidecar holds no Grafana credential. The sidecar can still fetch .url annotated keys; no Grafana credential is sent with those requests. Only the parent folder's permission list is replaced. Grants a tenant creates on its own sub-folders stay; this is harmless because the Grafana org is the confinement boundary and sub-folders cannot leave the parent. Tenant dashboard ids general and volume, and ids that cause generated volume or provider name collisions, are rejected. Tenant ConfigMaps use this shape:

apiVersion: v1
kind: ConfigMap
metadata:
  name: alpha-dashboard-overview
  namespace: alpha-dev
  labels:
    grafana_dashboard: "1"
data:
  overview.json: |
    {"uid":"alpha-overview","title":"Overview","panels":[]}

Use tenant-prefixed uids, never <tenant>-home; omit top-level id and __inputs. Use datasource uids prometheus, loki, tempo, with tenant namespace filters. Files land flat in the tenant folder; grafana_folder annotations are ignored. ConfigMaps must be on Grafana's cluster: a production Grafana cannot watch ConfigMaps on a separate development cluster. Both dashboard mounts are outside /tmp/dashboards so the main-org provider cannot load tenant files.

Install

The project's ArgoCD repo wraps the chart, so Dependabot's helm ecosystem opens a PR for every new version. The scaffold is templates/lgtm-stack/ in spartan-sre-wiki.

# lgtm-stack/Chart.yaml
apiVersion: v2
name: lgtm-stack-<cluster>
version: 1.0.0
dependencies:
  - name: lgtm-stack
    version: 0.11.0
    repository: https://spartan-stratos.github.io/helm-charts
# lgtm-stack/values.yaml (values go under the dependency name)
lgtm-stack:
  argocd:
    project: <argocd project>
    destination: { name: <target cluster> }
  cluster:
    name: <cluster name>
# apps/lgtm-stack.yaml, read by the project's root Application
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: lgtm-stack
  namespace: argocd
spec:
  project: <argocd project>
  destination:
    name: in-cluster        # the ArgoCD cluster: the chart renders Application CRs
    namespace: argocd
  source:
    repoURL: <this repo>
    targetRevision: master
    path: lgtm-stack
    helm:
      releaseName: lgtm-stack
  syncPolicy:
    automated: { prune: true, selfHeal: true }

The AppProject must allow this Helm repository, the upstream chart repositories in values.yaml, the ArgoCD namespace on the ArgoCD cluster (for the Application CRs) and the target cluster. It must also allow the cluster-scoped kinds the charts render: Namespace, CustomResourceDefinition, ClusterRole, ClusterRoleBinding, MutatingWebhookConfiguration and ValidatingWebhookConfiguration.

Before the first sync, the target cluster needs the gp3-enc-retain StorageClass (EBS CSI driver, gp3, encrypted, Retain, WaitForFirstConsumer, expansion allowed). The eks-lgtm Terraform module creates it with the node.

What gets created

ApplicationWaveSource
lgtm-cluster-info10ConfigMap monitoring-cluster-info (CLUSTER_NAME, read by Alloy)
lgtm-prometheus-operator-crds20prometheus-operator-crds
lgtm-kube-prometheus-stack30kube-prometheus-stack + presets/kube-prometheus-stack.yaml
lgtm-pvc-fill-rules31PrometheusRule lgtm-pvc-fill
lgtm-alertmanager-config32AlertmanagerConfig slack (only with alerting.slack.enabled)
lgtm-service-rules33PrometheusRule lgtm-service-red from alerting.rules.services
lgtm-workload-rules34PrometheusRule lgtm-workloads from alerting.rules.workloads
lgtm-stack-rules35PrometheusRule lgtm-stack: Loki, Tempo or Alloy dropping data
lgtm-grafana40grafana + presets/grafana.yaml (+ grafana-sso-<provider>.yaml)
lgtm-dashboards41Dashboard ConfigMaps from files/dashboards/
lgtm-project42The project folder: its dashboards and rules (only with project.enabled)
lgtm-log-rules49Tenant rule ConfigMap read permissions, platform canary and ruler health alerts (only with logRules.enabled and tenant namespaces)
lgtm-loki50loki + presets/loki.yaml
lgtm-grafana-datasources51Loki and Tempo datasource ConfigMaps
lgtm-alloy52alloy + presets/alloy.yaml
lgtm-tempo60tempo + presets/tempo.yaml
lgtm-opentelemetry-operator61opentelemetry-operator + presets/opentelemetry-operator.yaml
lgtm-instrumentation62Instrumentation monitoring/default

Everything lands in namespace monitoring; the presets reference each other through *.monitoring.svc.cluster.local. Apps send OTLP to http://alloy.monitoring.svc.cluster.local:4318.

The plain manifests (rows without an upstream chart) are rendered by this same chart in addon mode: their Applications point back at lgtm-stack at the same version, so the whole stack moves with one version.

Values

Each component's Helm values are built in this order, later wins:

  1. presets/<component>.yaml
  2. placement: nodeSelector and tolerations at every pod path the chart has (e.g. all six in kube-prometheus-stack)
  3. settings derived from the top-level values (cluster.name, grafana.*, alerting.*)
  4. components.<component>.values

The merge is key by key and keeps false, "" and null from the later layer; a null removes the upstream chart's default. Lists are replaced, not appended.

ValueDefaultDescription
argocd.project""AppProject for the Applications. Required
argocd.destination.name / .server""Target cluster. One is required
argocd.namespaceargocdNamespace of the Application CRs
argocd.namePrefixlgtm-Application name prefix
argocd.syncPolicyautomated, retry 10Shared syncPolicy. RespectIgnoreDifferences=true is added where diffs are ignored
cluster.name""cluster label on metrics, logs and Slack messages. Required
tenantIsolation.enabledfalseEnable tenant logs and traces only when backend tenant authentication is enabled
logRules.enabledfalseEnable tenant Loki rules; requires Loki, tenant isolation and explicit Loki authentication
logRules.sidecar.imagedocker.io/kiwigrid/k8s-sidecar:2.11.2Rule ConfigMap watcher image
logRules.sidecar.resourcesrequests: 10m CPU, 64Mi; memory limit: 128MiResources per tenant sidecar
logRules.limits.maxRuleGroupsPerTenant / .maxRulesPerRuleGroup10 / 10Maximum groups per tenant and rules per group
tenants[].ruleNamespacestenant's namespacesSubset containing rule ConfigMaps on the Loki cluster
placement.nodeSelector / .tolerations{} / []Pin every pod, e.g. to a dedicated node. Alloy and node-exporter (DaemonSets that read their own node) take only the tolerations, so they run on every node the tolerations admit; with a nodeSelector Alloy's Service uses internalTrafficPolicy: Cluster. To cover node pools with other taints, override both DaemonSets' tolerations under components
grafana.domain""root_url and Ingress host
grafana.ingress.enabled / .className / .annotationsfalse / alb / {}Grafana Ingress
grafana.sso.providernonekeycloak or github adds the matching preset; settings in grafana.sso.<provider>
alerting.slack.enabledfalseSlack receiver for warning and critical alerts
alerting.slack.secretName / .secretKeyalert-slack / webhook-urlSecret holding the Slack webhook URL
components.<c>.enabledtrueDrop a component
components.<c>.chartpinnedUpstream chart repoURL, name and version
components.<c>.values{}Any value of the upstream chart, merged last
components.<c>.ignoreDifferences[]Appended to the built-in list
addons.<a>.enabledtrueclusterInfo, pvcFillRules, stackRules, grafanaDatasources, instrumentation, dashboards
alerting.rules.services.*on, see Service alertsRED alerts per service; thresholds, minRequestRate, overrides.<service>
alerting.rules.workloads.*on, memoryLimitRatio: 0.9See Workload alerts
project.enabledfalseSync the project folder (dashboards and rules) from the project's repo, see Project folder
project.repoURL / .path / .targetRevision"" / "" / HEADWhere that folder is. repoURL and path are required
self.*this chart's repo and versionWhere the addon Applications pull this chart; set repoURL (git), path and targetRevision to test a branch

NetworkPolicy

networkPolicy.enabled defaults to false. Enabling it creates a separate lgtm-network-policy addon Application. Its four ingress-only policies fence Loki, Tempo, Prometheus and Alertmanager pods in namespace. They allow pods from that namespace and namespaces in networkPolicy.allowFromNamespaces (default []) on all ports. Grafana, the gateway, Alloy and prom-label-proxy are not fenced. Egress is unchanged. This is a no-op unless the cluster CNI enforces NetworkPolicy. Check kubelet probe reachability when enforcement is turned on.

Rollback: set networkPolicy.enabled: false, sync, and verify the lgtm-network-policy child Application and its four NetworkPolicies are pruned. Before turning the gateway's log or trace forwarding on for a tenant, check that each SDK's logs and spans carry the resource k8s.namespace.name; otherwise they are dropped.

Tenant receiver lists must contain at least one receiver, and receiver paths must start with /. Gateway logs and traces without a resource namespace are dropped; namespace-less metrics remain accepted for ruler namespace injection.

Secrets

The presets expect these Secrets in monitoring. They are not created by the chart; use External Secrets or create them by hand.

SecretKeysUsed by
grafana-adminadmin-user, admin-passwordGrafana admin. Set components.grafana.values.admin.existingSecret: "" to let the Grafana chart generate one
grafana-secret-keysecret-keyGrafana secret_key
grafana-oauthclient-secretGrafana SSO, with grafana.sso.provider set
alerting.slack.secretNamealerting.slack.secretKeySlack webhook URL. Required for Alertmanager reconciliation when Slack is enabled

With alerting.slack.enabled, both the webhook Secret and AlertmanagerConfig slack must exist in monitoring. The operator fails reconciliation with failed to get global AlertmanagerConfig when the global configuration is missing; a missing webhook Secret also prevents reconciliation. Create the Secret before enabling Slack and sync the configuration addon.

Tenant isolation

Namespace-scoped kube-state-metrics and kubelet series gain tenant=<id> so tenant rulers using prom-label-proxy can query their pods and containers; tenant relabel rules precede preserved consumer lists.

Tenant ids must match ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$ and contain at most 30 characters. They use lowercase letters, digits and internal hyphens, starting and ending with a letter or digit. The configured platformTenant (default platform) fake (Loki) and single-tenant (Tempo) are reserv

Deploy lgtm-stack with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has lgtm-stack on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartlgtm-stack is pinned at v0.20.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply