github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/docs/sources/installation/tanka.md (about)

     1  ---
     2  title: Tanka
     3  weight: 10
     4  ---
     5  # Install Grafana Loki with Tanka
     6  
     7  [Tanka](https://tanka.dev) is a reimplementation of
     8  [Ksonnet](https://ksonnet.io) that Grafana Labs created after Ksonnet was
     9  deprecated. Tanka is used by Grafana Labs to run Grafana Loki in production.
    10  
    11  The Tanka installation runs the Loki cluster in microservices mode.
    12  
    13  ## Prerequisites
    14  
    15  Install the latest version of Tanka (version v0.17.1 or a more recent version) for the `tk env`
    16  commands. Prebuilt binaries for Tanka can be found at the [Tanka releases
    17  URL](https://github.com/grafana/tanka/releases).
    18  
    19  In your config repo, if you don't have a Tanka application, create a folder and
    20  call `tk init` inside of it. Then create an environment for Loki and provide the
    21  URL for the Kubernetes API server to deploy to (e.g., `https://localhost:6443`):
    22  
    23  ```
    24  mkdir <application name>
    25  cd <application name>
    26  tk init
    27  tk env add environments/loki --namespace=loki --server=<Kubernetes API server>
    28  ```
    29  
    30  Install `jsonnet-bundler` (`jb`), find instructions for your platform in Tanka's [installation docs](https://tanka.dev/install#jsonnet-bundler).
    31  
    32  ## Deploying
    33  
    34  Download and install the Loki and Promtail module using `jb` (version v0.4.0 or a more recent version):
    35  
    36  ```bash
    37  jb init  # not required if you already ran `tk init`
    38  jb install github.com/grafana/loki/production/ksonnet/loki@main
    39  jb install github.com/grafana/loki/production/ksonnet/promtail@main
    40  ```
    41  
    42  Revise the YAML contents of `environments/loki/main.jsonnet`, updating these variables:
    43  
    44  - Update the `username`, `password`, and the relevant `htpasswd` variable values.
    45  - Update the S3 or GCS variable values, depending on your object storage type. See [storage_config](https://grafana.com/docs/loki/latest/configuration/#storage_config) for more configuration details.
    46  - Remove from the configuration the S3 or GCS object storage variables that are not part of your setup.
    47  - Update the value of `boltdb_shipper_shared_store` to the type of object storage you are using. Options are `gcs`, `s3`, `azure`, or `filesystem`. Update the `object_store` variable under the `schema_config` section to the same value. 
    48  - Update the Promtail configuration `container_root_path` variable's value to reflect your root path for the Docker daemon. Run `docker info | grep "Root Dir"` to acquire your root path.
    49  - Update the `from` value in the Loki `schema_config` section to no more than 14 days prior to the current date. The `from` date represents the first day for which the `schema_config` section is valid. For example, if today is `2021-01-15`, set `from` to `2021-01-01`. This recommendation is based on Loki's default acceptance of log lines up to 14 days in the past. The `reject_old_samples_max_age` configuration variable controls the acceptance range.
    50  
    51  
    52  ```jsonnet
    53  local gateway = import 'loki/gateway.libsonnet';
    54  local loki = import 'loki/loki.libsonnet';
    55  local promtail = import 'promtail/promtail.libsonnet';
    56  
    57  loki + promtail + gateway {
    58    _config+:: {
    59      namespace: 'loki',
    60      htpasswd_contents: 'loki:$apr1$H4yGiGNg$ssl5/NymaGFRUvxIV1Nyr.',
    61  
    62      // S3 variables -- Remove if not using s3
    63      storage_backend: 's3,dynamodb',
    64      s3_access_key: 'key',
    65      s3_secret_access_key: 'secret access key',
    66      s3_address: 'url',
    67      s3_bucket_name: 'loki-test',
    68      dynamodb_region: 'region',
    69  
    70      // GCS variables -- Remove if not using gcs
    71      storage_backend: 'bigtable,gcs',
    72      bigtable_instance: 'instance',
    73      bigtable_project: 'project',
    74      gcs_bucket_name: 'bucket',
    75  
    76      //Set this variable based on the type of object storage you're using.
    77      boltdb_shipper_shared_store: 'my-object-storage-backend-type',
    78  
    79      //Update the object_store and from fields
    80      loki+: {
    81        schema_config: {
    82          configs: [{
    83            from: 'YYYY-MM-DD',
    84            store: 'boltdb-shipper',
    85            object_store: 'my-object-storage-backend-type',
    86            schema: 'v11',
    87            index: {
    88              prefix: '%s_index_' % $._config.table_prefix,
    89              period: '%dh' % $._config.index_period_hours,
    90            },
    91          }],
    92        },
    93      },
    94  
    95      //Update the container_root_path if necessary
    96      promtail_config+: {
    97        clients: [{
    98          scheme:: 'http',
    99          hostname:: 'gateway.%(namespace)s.svc' % $._config,
   100          username:: 'loki',
   101          password:: 'password',
   102          container_root_path:: '/var/lib/docker',
   103        }],
   104      },
   105  
   106      replication_factor: 3,
   107      consul_replicas: 1,
   108    },
   109  }
   110  ```
   111  
   112  Run `tk show environments/loki` to see the manifests that will be deployed to
   113  the cluster. Run `tk apply environments/loki` to deploy the manifests.