cluster-loki

by startxfr

Helm chartv21.3.412App 6.5.1GPL-3.0-or-laterVerified publisher

Configure the Loki log store (LokiStack) of OpenShift Logging with the Red Hat Loki operator

About this chart

Cluster Chart : Loki

Configure the Loki log store (LokiStack) of OpenShift Logging with the Red Hat Loki operator.

This chart is part of the cluster-xxx startx helm chart series that doesn't necessarily deploy pods but rather represent a cluster configuration state orchestrated by gitops tools like ArgoCD.

It deploys the complete Loki log store of OpenShift Logging 6:

  • the Red Hat Loki operator (subscription loki-operator in openshift-operators-redhat, AllNamespaces OperatorGroup) through the operator sub-chart
  • the LokiStack instance (logging-loki in openshift-logging) with its size, storage schemas, object storage secret, retention, limits, replication, ruler and infra node placement
  • the object storage Secret read by the LokiStack, either from the chart values or from an External Secrets store
  • the optional AlertingRule, RecordingRule and RulerConfig CRs evaluated by the LokiStack ruler

The LokiStack is the log store of the OpenShift Logging collector: deploy the collector and its ClusterLogForwarder with the cluster-logging chart and reference the LokiStack name (logging-loki) in its lokiStack output.

Requirements and guidelines

Read the startx helm-repository homepage for more information on how to use these resources.

The LokiStack needs an object storage bucket (AWS S3, S3 compatible like MinIO or OpenShift Data Foundation, Azure, GCS, Swift or Alibaba Cloud) and a storage class for its persistent volumes. The object storage credentials must be available in a Secret of the LokiStack namespace (lokistack.storage.secret.name, default logging-loki-s3) before the LokiStack becomes ready.

Embedded use by cluster-logging

The cluster-logging chart declares this chart as an optional dependency with the alias loki (loki.enabled: true). In this embedded mode only the lokistack, storageSecret, alertingRules, recordingRules and rulerConfig blocks are used: the project and operator sub-charts of cluster-loki stay disabled because cluster-logging already creates the openshift-logging namespace and installs the Loki operator through its own operatorLoki block. The standalone deployment described below is meant for clusters where the Loki log store is managed independently from the logging collector.

Deploy this helm chart on openshift

1. Connect to your Openshift cluster

oc login -t <token> <cluster-url>

2. Install the repository

helm repo add startx https://helm-repository.readthedocs.io/en/latest/repos/stable/

3. Get information about this chart

helm show chart startx/cluster-loki

4. Install this chart

Default values

The default values render nothing: every block is disabled because the LokiStack needs cluster specific data (object storage bucket and credentials). Enable the LokiStack and its object storage secret with your own values:

  • Deploy the LokiStack CR (openshift-logging/logging-loki), size 1x.small, storage class gp3-csi, schema v13, tenancy mode openshift-logging, 7 days of retention
  • Deploy the object storage Secret (openshift-logging/logging-loki-s3) read by the LokiStack
  • The operator subscription and namespace are managed separately via the operator and project sub-charts (both disabled by default)
# base configuration running default configuration
helm install cluster-loki startx/cluster-loki \
  --set lokistack.enabled=true \
  --set storageSecret.enabled=true \
  --set storageSecret.data.bucketnames=<bucket> \
  --set storageSecret.data.endpoint=https://s3.eu-west-3.amazonaws.com \
  --set storageSecret.data.region=eu-west-3 \
  --set storageSecret.data.access_key_id=<access-key> \
  --set storageSecret.data.access_key_secret=<secret-key>

Full deployment with operator and project

Enable the Loki operator subscription and the openshift-logging namespace alongside the LokiStack. Add operatorNamespace.enabled=true when nothing else creates the openshift-operators-redhat namespace of the operator (the cluster-config chart creates it with redhat.operators: true):

helm install cluster-loki startx/cluster-loki \
  --set project.enabled=true \
  --set operator.enabled=true \
  --set operatorNamespace.enabled=true \
  --set lokistack.enabled=true \
  --set storageSecret.enabled=true \
  --set storageSecret.data.bucketnames=<bucket> \
  --set storageSecret.data.endpoint=https://s3.eu-west-3.amazonaws.com \
  --set storageSecret.data.region=eu-west-3 \
  --set storageSecret.data.access_key_id=<access-key> \
  --set storageSecret.data.access_key_secret=<secret-key>

Set operator.operatorGroup.enabled=false when an OperatorGroup already exists in openshift-operators-redhat (for example created by the operatorLoki or operatorElastic block of another STARTX chart): a namespace must hold a single OperatorGroup.

Other available values

helm install cluster-loki startx/cluster-loki -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-loki/values-startx.yaml --set lokistack.enabled=true

Values files

Example values files shipped with the chart, to use with helm install -f <file> :

  • startx : STARTX cluster configuration, see values.yaml for the parameters (see values-startx.yaml)
  • startx_noinfra : STARTX cluster configuration, see values.yaml for the parameters (see values-startx_noinfra.yaml)
  • examples/argocd/ : 5 example manifest(s) (see the ArgoCD or usage sections)
helm install cluster-loki startx/cluster-loki -f https://raw.githubusercontent.com/startxfr/helm-repository/master/charts/cluster-loki/values-startx.yaml

Deploy with ArgoCD

Deploy via ArgoCD Application

Deploy cluster-loki using three dedicated ArgoCD Applications - one per concern - all sharing the same AppProject:

git clone https://gitlab.com/startx1/helm.git
cd helm-repository/charts/cluster-loki/examples/argocd/
oc apply -k .
ApplicationWaveConcernDestination
cluster-loki-project"1"project.enabled: true (namespace openshift-logging)openshift-logging
cluster-loki-operator"5"operator.enabled: true (Loki operator subscription)openshift-operators-redhat
cluster-loki-app"10"lokistack.enabled: true (LokiStack CR)openshift-logging

The automated sync policy ensures ArgoCD reconciles each concern independently whenever the chart or values drift from the desired state. The cluster-loki-app Application ignores the /metadata/finalizers added by the operator on the LokiStack. The object storage secret is not part of the examples: add storageSecret.enabled: true with your values (or an ExternalSecret) to the cluster-loki-app Application, or create it by hand before the sync.

External secrets

The object storage secret (storageSecret) can come from an external store (Vault, AWS Secrets Manager...) through the External Secrets Operator instead of the chart values. With storageSecret.externalSecret.enabled: true, the chart renders an ExternalSecret producing the Secret lokistack.storage.secret.name in the LokiStack namespace, with the keys of your choice, so the LokiStack referencing it is unchanged. Without externalSecret, the chart keeps rendering the Secret from storageSecret.data.

externalSecretDefaults:
  secretStoreRef:
    name: vault-backend
    kind: ClusterSecretStore
storageSecret:
  enabled: true
  externalSecret:
    enabled: true
    dataFrom:
      - extract:
          key: ocp/logging/loki-s3

An externalSecret block accepts secretStoreRef and refreshInterval (defaults: externalSecretDefaults), remoteRefs (map of secret key to ESO remoteRef) and the raw ESO fields data, dataFrom and template. Rendering fails when no store is set or when no key source is provided.

Values dictionary

context values dictionary

KeyDefaultDescription
context.scopemyscopeName of the global scope for this application
context.clusterdefaultName of the cluster running this application
context.environmentmyenvName of the environment (dev, factory, preprod, prod)
context.componentmycomponentComponent name of this application
context.appdefault-lokiApplication name
context.version6.5.1Version name of this application

externalSecretDefaults values dictionary

KeyDefaultDescription
externalSecretDefaults.apiVersionexternal-secrets.io/v1API version of the ExternalSecret CRD
externalSecretDefaults.refreshInterval1hHow often the Secret is refreshed from the external store
externalSecretDefaults.secretStoreRef.name""Name of the store to read from (required when a secret uses ESO)
externalSecretDefaults.secretStoreRef.kindClusterSecretStoreKind of the store (SecretStore or ClusterSecretStore)

operatorNamespace values dictionary

KeyDefaultDescription
operatorNamespace.enabledfalseCreate the Red Hat operator namespace (keep disabled when cluster-config manages it)
operatorNamespace.nameopenshift-operators-redhatName of the operator namespace (must match operator.subscription.namespace)

lokistack values dictionary

KeyDefaultDescription
lokistack.enabledfalseEnable the creation of the LokiStack CR
lokistack.hookedfalseDeploy as a Helm/ArgoCD post-sync hook
lokistack.namelogging-lokiName of the LokiStack (referenced by the ClusterLogForwarder lokiStack output)
lokistack.size1x.smallDeployment size (1x.demo, 1x.pico, 1x.extra-small, 1x.small or 1x.medium)
lokistack.storageClassNamegp3-csiStorage class of the Loki persistent volumes
lokistack.managementStateManagedManagement state (Managed or Unmanaged)
lokistack.infra_enabledfalsePlace every Loki component on the infra nodes (nodeSelector + NoSchedule/NoExecute tolerations)
lokistack.tenants.modeopenshift-loggingTenancy mode (openshift-logging, openshift-network, static, dynamic or passthrough)
lokistack.storage.schemas[{v13, 2024-10-01}]List of storage schemas (version v11, v12 or v13 and effectiveDate)
lokistack.storage.secret.name

Deploy cluster-loki with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has cluster-loki 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 chartcluster-loki is pinned at v21.3.412 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