Chapter 3. Install the Loki Operator


The Loki Operator deploys and manages a LokiStack instance that serves as the log store for logging for Red Hat OpenShift. You can install the Loki Operator by using the OpenShift CLI (oc) or the Red Hat OpenShift Logging web console.

3.1. Install the Loki Operator by using the CLI

Install the Loki Operator to manage the LokiStack log store by using the OpenShift CLI (oc).

Prerequisites

  • You have administrator permissions.
  • You have installed the OpenShift CLI (oc).
  • You have access to a supported object store.

Procedure

  1. Create a Namespace object for the Loki Operator:

    apiVersion: v1
    kind: Namespace
    metadata:
      name: openshift-operators-redhat
      labels:
        openshift.io/cluster-monitoring: "true"
    metadata.name
    You must specify openshift-operators-redhat as the namespace for the Loki Operator. The openshift-operators namespace might contain community Operators, which are untrusted and could publish metrics with the same name as OpenShift Container Platform metrics, causing conflicts.
    metadata.labels."openshift.io/cluster-monitoring"
    A string value that enables cluster monitoring to scrape this namespace.
  2. Apply the Namespace object by running the following command:

    $ oc apply -f <filename>.yaml
  3. Create an OperatorGroup object:

    apiVersion: operators.coreos.com/v1
    kind: OperatorGroup
    metadata:
      name: loki-operator
      namespace: openshift-operators-redhat
    spec:
      upgradeStrategy: Default
  4. Apply the OperatorGroup object by running the following command:

    $ oc apply -f <filename>.yaml
  5. Create a Subscription object for the Loki Operator:

    apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: loki-operator
      namespace: openshift-operators-redhat
    spec:
      channel: stable-6.6
      installPlanApproval: Automatic
      name: loki-operator
      source: redhat-operators
      sourceNamespace: openshift-marketplace
    spec.channel
    Specify stable-6.6 as the channel.
    spec.installPlanApproval
    If the approval strategy in the subscription is set to Automatic, the update process initiates as soon as a new Operator version is available in the selected channel. If the approval strategy is set to Manual, you must manually approve pending updates.
    spec.source

    Specify redhat-operators as the value. If your OpenShift Container Platform cluster is installed on a restricted network, also known as a disconnected cluster, specify the name of the CatalogSource object that you created when you configured Operator Lifecycle Manager (OLM).

    Warning

    A community loki-operator package also exists in the community-operators catalog source. You must specify redhat-operators to install the supported Red Hat version. Using the wrong source installs the upstream community version with different channel names.

  6. Apply the Subscription object by running the following command:

    $ oc apply -f <filename>.yaml
  7. Verify that the operator installed successfully by running the following command:

    $ oc get csv -n openshift-operators-redhat

    You get an output similar to the following example:

    NAME                                     DISPLAY         VERSION                PHASE
    loki-operator.v6.6.0   Loki Operator   6.6.0     Succeeded

Install the Loki Operator to manage the LokiStack log store from the OperatorHub by using the OpenShift Container Platform web console.

Prerequisites

  • You have administrator permissions.
  • You have access to the OpenShift Container Platform web console.
  • You have access to a supported object store (AWS S3, GCP, Azure, S3 Compatible storage, OpenShift Data Foundation, or Swift).

Procedure

  1. In the OpenShift Container Platform web console Administrator perspective:

    • For OpenShift Container Platform 4.19 or earlier, click Operators OperatorHub.
    • For OpenShift Container Platform 4.20 or later, click Ecosystem Software Catalog.
  2. Type Loki Operator in the Filter by keyword field. Click Loki Operator in the list of available Operators, and then click Install.

    Important

    The Community Loki Operator is not supported by Red Hat. Select the operator provided by Red Hat.

  3. Select stable-6.6 as the Update channel.

    The Loki Operator must be deployed to the global Operator group namespace openshift-operators-redhat, so the Installation mode and Installed Namespace are already selected. If this namespace does not already exist, it is created for you.

  4. Select Enable Operator-recommended cluster monitoring on this namespace.

    This option sets the openshift.io/cluster-monitoring: "true" label in the Namespace object. You must select this option to ensure that cluster monitoring scrapes the openshift-operators-redhat namespace.

  5. For Update approval select Automatic, then click Install.

    Note

    An Operator might display a Failed status before the installation completes. If the Operator installation completes with an InstallSucceeded message, refresh the page.

Verification

  1. Navigate to the Installed Operators page.
  2. Verify that the Loki Operator displays with a Status of Succeeded.

3.3. Create the openshift-logging namespace

The LokiStack instance and all logging workloads run in the openshift-logging namespace. Create this namespace if it does not already exist.

Procedure

  1. Create a Namespace object:

    apiVersion: v1
    kind: Namespace
    metadata:
      name: openshift-logging
      labels:
        openshift.io/cluster-monitoring: "true"
    metadata.name
    The openshift-logging namespace is dedicated for all logging workloads.
    metadata.labels."openshift.io/cluster-monitoring"
    A string value that enables cluster monitoring to scrape this namespace.
  2. Apply the Namespace object by running the following command:

    $ oc apply -f <filename>.yaml

3.4. Create the object storage secret

Create a secret with the credentials for your S3-compatible object store. The Loki Operator requires this secret to configure the LokiStack to store log data.

Procedure

  1. Create a Secret object with your object storage credentials. For provider-specific parameters, see the storage configuration documentation.

    Example Secret object for AWS S3

    apiVersion: v1
    kind: Secret
    metadata:
      name: logging-loki-s3
      namespace: openshift-logging
    stringData:
      access_key_id: <your_access_key_id>
      access_key_secret: <your_secret_access_key>
      bucketnames: <your_bucket_name>
      endpoint: <your_s3_endpoint>
      region: <your_region>

    metadata.name
    Use the name logging-loki-s3 to match the reference in the LokiStack CR.
    metadata.namespace
    You must create this secret in the openshift-logging namespace.
    access_key_id
    Your S3 access key ID.
    access_key_secret
    Your S3 secret access key.
    bucketnames
    The name of a pre-created S3 bucket, for example loki.
    endpoint
    The full endpoint URL. For AWS: https://s3.<region>.amazonaws.com. For S3 Compatible storage: https://s3.example.com:9000.
    region

    The S3 region, for example us-east-1.

    Note

    The field names access_key_id, access_key_secret, bucketnames, and endpoint are specific to the Loki Operator. They do not match the standard AWS SDK environment variable names.

  2. Apply the Secret object by running the following command:

    $ oc apply -f <filename>.yaml
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top