loki
Renders Loki Operator LokiStacks, AlertingRules, RecordingRules and RulerConfigs from inventory parameters.
- Latest
- 1.0.1 ·
- License
- Apache-2.0
- Owners
- Moep90
- Source
- github.com/kadet-hub/generators · 0 repo stars, shared by 35 generators
- Thumbs up
- 👍 0 on GitHub Discussions
- Popularity
- 17 · 359 pulls
Request a feature Report a problem
Badge
Show the latest listed version in your README. shields.io draws the badge from this page's badge.json, which every catalog build updates; once no version is listed, it reads "not listed".
[](https://kadet-hub.org/generators/loki/)
Loki Generator
Published on kadet-hub: pin a released version by digest from its catalog page.
Built for Loki Operator 0.11.0 (loki.grafana.com/v1). The compiled output is not checked against JSON Schemas: the upstream CRDs are AGPL-3.0-only, so this generator does not ship them.
Kapitan kadet generator for Loki Operator resources:
- LokiStack: a managed Loki deployment
- AlertingRule: LogQL alerting rules for one tenant
- RecordingRule: LogQL recording rules for one tenant
- RulerConfig: ruler settings (Alertmanager, remote write) for a LokiStack
The object storage Secret belongs in the kubernetes generator.
Usage
Kapitan Configuration
parameters:
kapitan:
dependencies:
- type: oci
source: ghcr.io/kadet-hub/loki@sha256:<digest>
output_path: lib/loki
compile:
- output_path: manifests/loki/
input_type: kadet
output_type: yml
input_paths:
- lib/lokiInventory Contract
All keys live under parameters.generators.loki.
| Key | Kind | Output key |
|---|---|---|
namespace |
Default namespace. Falls back to parameters.namespace, then default. |
|
loki_stacks.<name> |
LokiStack | <namespace>/<name>-lokistack |
alerting_rules.<name> |
AlertingRule | <namespace>/<name>-alertingrule |
recording_rules.<name> |
RecordingRule | <namespace>/<name>-recordingrule |
ruler_configs.<name> |
RulerConfig | <namespace>/<name>-rulerconfig |
The CRDs define no shortNames, so the suffix is the lowercase kind.
Every resource accepts namespace, labels, annotations and spec; rules also accept loki_stack. Precedence, lowest first: generator defaults, spec, flat keys and shorthands. A flat key replaces the same field from spec and logs a warning.
Flat keys are the snake_case spelling of the CRD spec fields; values pass through unchanged:
| Kind | Flat keys |
|---|---|
| LokiStack | size, storage, storage_class_name, hash_ring, limits, management_state, network_policies, proxy, replication, rules, template, tenants |
| AlertingRule, RecordingRule | tenant_id, groups |
| RulerConfig | alertmanager, evaluation_interval, overrides, poll_interval, remote_write |
The deprecated replicationFactor is not a flat key; use replication.factor.
LokiStack Defaults
The generator fills these fields only where neither spec nor a flat key sets them.
| Input | Result |
|---|---|
storage: <type> |
storage.secret with name: <stack name>-<type> and type: <type> |
storage without schemas |
storage.schemas: [{version: v13, effectiveDate: "2023-10-15"}] |
tenants without mode |
mode: passthrough if the block has passthrough, dynamic if it has authorization.opa, static if it has authorization.roles or authorization.roleBindings; otherwise no mode |
rules.enabled: true without rules.selector |
selector.matchLabels on loki.grafana.com/lokistack: <stack name>, plus a namespaceSelector on kubernetes.io/metadata.name for the namespaces of its rules outside the stack namespace |
The storage shorthand follows the Secret naming of the operator’s object storage guide (lokistack-dev-s3 for the stack lokistack-dev). <type> is one of s3, azure, gcs, swift, alibabacloud. A Secret with another name, a credentialMode or tls needs the full storage block.
Without schemas the CRD applies v11 from 2020-10-11 (CRD default), and the operator then sets the StorageNeedsSchemaUpdate warning because the latest schema is not v13 (status). The API recommends the latest schema with a past effective date for a new stack (API), and Loki calls v13 the recommended schema (Loki schema docs). The date is fixed to keep the output deterministic. It is the one the operator’s own examples use (tenancy modes).
A stack that already runs on the CRD default keeps v11 in status.storage.schemas. The operator’s webhook rejects an update that drops it or adds a schema with a past date (validation). For such a stack, set storage.schemas to its current entries plus v13 with an effective date in the future.
The CRD default for tenants.mode is openshift-logging. It works only on OpenShift and rejects custom authentication and authorization. The derived mode is the only one the operator’s mode validation accepts for that block; see the tenancy modes guide. The operator’s default configuration enables the gateway (config), and a stack without tenants is then degraded (gateway). Set tenants on every stack.
Rules are bound to a stack by the label loki.grafana.com/lokistack: <stack name>. A rule gets it for the stack named in its loki_stack; without loki_stack, rules are bound to the only stack when loki_stacks has exactly one entry. A labels entry with the same key wins. The operator selects rules by rules.selector, and a stack without a selector loads none (rule discovery, nil selector). It searches only the stack namespace unless rules.namespaceSelector matches other namespaces (design). The namespace selector uses the label Kubernetes sets on every namespace (Kubernetes docs), so the generator does not need to label namespaces. The operator documents no label convention of its own. Its samples select on openshift.io/cluster-monitoring (sample), which marks a namespace for monitoring rather than naming a stack. An explicit selector or namespaceSelector is never changed, and rules bound by other labels stay as they are.
Not defaulted:
size: depends on the daily log volume, from 50 GB/day for1x.picoto 2 TB/day for1x.medium(sizing). Required by the CRD.storage_class_name: depends on the cluster. Required by the CRD.replication.factor: the operator sets 2 for every size except1x.demo(sizes).- Retention: Loki deletes nothing unless
limits.global.retentionor a tenant retention is set (config). There is no vendor default; setlimits.global.retention.daysor a lifecycle rule on the bucket. - Other CRD defaults (
managementState: Managed,evaluationInterval: 1m,pollInterval: 1m) are left to the API server.
A RulerConfig applies to the LokiStack with the same name in the same namespace.
Example
parameters:
generators:
loki:
namespace: logging
loki_stacks:
logs:
size: 1x.small
storage: s3
storage_class_name: standard
limits:
global:
retention:
days: 30
tenants:
authentication:
- tenantName: application
tenantId: application
oidc:
secret:
name: application-oidc
issuerURL: https://idp.example.com/
authorization:
roles:
- name: read-write
permissions: [read, write]
resources: [logs]
tenants: [application]
roleBindings:
- name: developers
roles: [read-write]
subjects:
- kind: group
name: developers
rules:
enabled: true
alerting_rules:
high-error-rate:
tenant_id: application
groups:
- name: errors
interval: 1m
rules:
- alert: HighErrorRate
expr: sum(rate({app="web"} |= "error" [5m])) > 10
for: 10m
labels:
severity: warning
recording_rules:
request-rates:
tenant_id: application
groups:
- name: rates
interval: 1m
rules:
- record: web:requests:rate5m
expr: sum(rate({app="web"}[5m]))
ruler_configs:
logs:
evaluation_interval: 1m
alertmanager:
endpoints:
- http://alertmanager.monitoring.svc:9093The logs stack compiles to the logs-s3 Secret reference, the v13 schema, tenants.mode: static and a rules selector on loki.grafana.com/lokistack: logs, the label both rules get.
Versions
Add a version's inventory entry, then compile with the consumer workflow, which verifies the artifact and runs Kapitan in the sandbox.
Free of charge, as is and on a best-effort basis: use at your own risk, and review the compiled output before you apply it. Terms
This catalog was built from index serial 47. Set index_serial: 47 in .kapitan-sandbox.yaml and the consumer workflow refuses any older index, so a rolled-back index cannot bring back a yanked version.
Checks find known patterns; they do not prove a generator safe. What a listing covers
| Version | Built for (schema-checked) |
|---|---|
| 1.0.1 | not recorded |
| 1.0.0 | not recorded |
1.0.1#
Inventory
parameters:
kapitan:
dependencies:
- type: oci
source: ghcr.io/kadet-hub/loki:1.0.1@sha256:5831d87fdf232c8b89fef0a75752eaa55d6ca62b23f9e78e95355d759a3a50d6
output_path: lib/loki
Verify
gh attestation verify \
oci://ghcr.io/kadet-hub/loki@sha256:5831d87fdf232c8b89fef0a75752eaa55d6ca62b23f9e78e95355d759a3a50d6 \
--owner kadet-hub \
--cert-identity https://github.com/kadet-hub/registry/.github/workflows/release.yml@refs/heads/main
Transparency log: Rekor entry 3244142055, in Sigstore's public, append-only log, so the attestation stays checkable independent of this site.
- Kapitan declared
- >=0.36.3,<0.37
- Kapitan checked
- 0.36.3
- Backends checked
- not recorded
- With --cache
- not recorded
- krab
- compatible
- Built for (schema-checked)
- not recorded
- Source
- loki-v1.0.1 ·
9166cb30e0ae4874bc8f229c6a6823eff7451d04· loki - Binaries
- none
- Output capabilities
- none
- Digest
sha256:5831d87fdf232c8b89fef0a75752eaa55d6ca62b23f9e78e95355d759a3a50d6
Checks
Checked by the release run on , gate at ba634ff54963.
- Secrets gitleaks 8.30.1
No secret matched the marketplace's gitleaks rules. - Malware ClamAV 1.5.4
No file matched a ClamAV signature. - Malicious package heuristics GuardDog 3.2.0
No GuardDog threat rule matched. - Dangerous code Semgrep 1.180.0
No marketplace Semgrep rule matched, such as eval, subprocess or network calls. - Python errors Ruff 0.17.0
No syntax error or undefined name (Ruff, error rules only). - File tree tree_check.py
No symlink, executable or banned file; imports within the allowlist. - Sandboxed compile gVisor 20261005, Kapitan 0.36.3
The fixture compiled without network, with decoy credentials; no undeclared program ran, no decoy was read. - Output capabilities Conftest 0.71.1
The compiled output uses only the capabilities the manifest declares. - CI detection Kapitan 0.36.3
The output is the same with CI variables set.
Output diff
No output diff recorded: this version was published before the release run recorded one.
1.0.0#
Inventory
parameters:
kapitan:
dependencies:
- type: oci
source: ghcr.io/kadet-hub/loki:1.0.0@sha256:da8bf0a4665df2d2d572c285f2a4d06fbba42430d1fc054030d9f3e07415844e
output_path: lib/loki
Verify
gh attestation verify \
oci://ghcr.io/kadet-hub/loki@sha256:da8bf0a4665df2d2d572c285f2a4d06fbba42430d1fc054030d9f3e07415844e \
--owner kadet-hub \
--cert-identity https://github.com/kadet-hub/registry/.github/workflows/release.yml@refs/heads/main
Transparency log: Rekor entry 3210094622, in Sigstore's public, append-only log, so the attestation stays checkable independent of this site.
- Kapitan declared
- >=0.36.3,<0.37
- Kapitan checked
- 0.36.3
- Backends checked
- not recorded
- With --cache
- not recorded
- krab
- compatible
- Built for (schema-checked)
- not recorded
- Source
- loki-v1.0.0 ·
cd660d06c2e97a2bc842f0e75475f639a82f128d· loki - Binaries
- none
- Output capabilities
- none
- Digest
sha256:da8bf0a4665df2d2d572c285f2a4d06fbba42430d1fc054030d9f3e07415844e
Checks
Checked by the release run on , gate at a6abb26ac69c.
- Secrets gitleaks 8.30.1
No secret matched the marketplace's gitleaks rules. - Malware ClamAV 1.5.4
No file matched a ClamAV signature. - Malicious package heuristics GuardDog 3.2.0
No GuardDog threat rule matched. - Dangerous code Semgrep 1.180.0
No marketplace Semgrep rule matched, such as eval, subprocess or network calls. - Python errors Ruff 0.17.0
No syntax error or undefined name (Ruff, error rules only). - File tree tree_check.py
No symlink, executable or banned file; imports within the allowlist. - Sandboxed compile gVisor 20261005, Kapitan 0.36.3
The fixture compiled without network, with decoy credentials; no undeclared program ran, no decoy was read. - Output capabilities Conftest 0.71.1
The compiled output uses only the capabilities the manifest declares. - CI detection Kapitan 0.36.3
The output is the same with CI variables set.
Output diff
No output diff recorded: this version was published before the release run recorded one.