---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.0
alternate:
  - en/concepts/secrets-instance/config
  - en/datalens/concepts/secrets-instance/config.md
  - ru/concepts/secrets-instance/config
  - href: en/concepts/secrets-instance/config.md
    type: text/markdown
    title: Markdown version
csp:
  - script-src:
      - https://mc.yandex.ru
    img-src:
      - https://mc.yandex.ru
    connect-src:
      - https://mc.yandex.ru
      - wss://mc.yandex.ru
    child-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-ancestors:
      - 'blob:'
      - https://mc.yandex.ru
canonical: en/concepts/secrets-instance/config.html
title: Configuring DataLens On-premises secrets
description: >-
  This section describes how to configure secrets for deploying DataLens
  On-premises.
vcsPath: en/concepts/secrets-instance/config.md
---

# Configuring DataLens On-premises secrets

You can set secrets in two ways:

1. Via properties in the `values.yaml` [file](../create-instance.md#values-yaml) (recommended for first deployment).
1. Via an external [Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/), with a link in `secrets.ref`.

When using the `./init.sh` script, secrets are generated automatically on first [deployment](../create-instance.md#deployment) and stored in the Kubernetes cluster secrets.


## Example YAML configuration {#yaml-example}

```yaml
secrets:
  ref: null                              # Link to an external Kubernetes secret
  #
  # === RSA authentication keys (required) ===
  AUTH_TOKEN_PRIVATE_KEY: null           # Generated automatically on first deployment
  AUTH_TOKEN_PUBLIC_KEY: null            # Generated automatically on first deployment
  AUTH_PROVIDERS_CONFIG: null            # JSON array of providers (optional)
  AUTH_ADMIN_PASSWORD: null              # The admin password (generated automatically)
  AUTH_CALLBACK_COOKIE_SECRET: null      # Generated automatically
  #
  # === Security ===
  CSRF_SECRET: null                      # Generated automatically
  #
  # === Master tokens ===
  AUTH_MASTER_TOKEN: null                # Generated automatically
  US_MASTER_TOKEN: null                  # Generated automatically
  FILE_UPLOADER_MASTER_TOKEN: null       # Generated automatically
  EXPORT_DATA_VERIFICATION_KEY: null     # Generated automatically
  #
  # === Encryption keys ===
  CONTROL_API_CRYPTO_KEY: null           # Generated automatically
  #
  # === Docker Registry ===
  DOCKER_CONFIG_JSON: null               # Required if registry.private: true
  #
  # === PostgreSQL ===
  POSTGRES_PASSWORD_ROOT: null           # Generated automatically
  POSTGRES_PASSWORD_US: null             # Generated automatically
  POSTGRES_PASSWORD_COMPENG: null        # Generated automatically
  POSTGRES_PASSWORD_AUTH: null           # Generated automatically
  POSTGRES_PASSWORD_TEMPORAL: null       # Generated automatically
  POSTGRES_PASSWORD_META_MANAGER: null   # Generated automatically
  POSTGRES_PASSWORD_DEMO: null           # Generated automatically
  #
  # === Temporal RSA keys (for import/export) ===
  TEMPORAL_AUTH_PRIVATE_KEY: null        # Generated if features.export is enabled
  TEMPORAL_AUTH_PUBLIC_KEY: null         # Generated if features.export is enabled
  #
  # === Infrastructure components ===
  CLICKHOUSE_PASSWORD: null              # Generated automatically
  REDIS_PASSWORD: null                   # Generated automatically
  S3_ACCESS_KEY_ID: null                 # Generated automatically
  S3_SECRET_ACCESS_KEY: null             # Generated automatically
```

## Manual generation of RSA keys {#rsa-key-generation}

If you need to generate RSA keys manually, use the following commands:

```bash
# Generating a private key (4096 bit)
openssl genpkey -algorithm RSA -pkeyopt "rsa_keygen_bits:4096" -out private.pem

# Extracting a public key
openssl rsa -in private.pem -pubout -out public.pem

# Viewing content to insert into values.yaml
cat private.pem
cat public.pem
```

When specifying in `values.yaml`, use the multi-line YAML format:

```yaml
secrets:
  AUTH_TOKEN_PRIVATE_KEY: |
    -----BEGIN PRIVATE KEY-----
    MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQC...
    ...
    -----END PRIVATE KEY-----
  AUTH_TOKEN_PUBLIC_KEY: |
    -----BEGIN PUBLIC KEY-----
    MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA...
    ...
    -----END PUBLIC KEY-----
```

## DOCKER_CONFIG_JSON format {#docker-config-json}

Example configuration for a private registry:

```json
{
  "auths": {
    "registry.example.com": {
      "username": "user",
      "password": "password",
      "auth": "base64(user:password)"
    }
  }
}
```

Also see the example in the `./help/docker-config.example.json` file.


## Using an external Kubernetes secret {#external-secret}

If secrets already exist in the Kubernetes cluster, provide a link to the secret:

```yaml
secrets:
  ref: my-existing-secret
```

In which case all other values ​​in the `secrets` section will be ignored, and the system will use the values ​​from the specified Kubernetes secret.

The external secret must contain all the necessary keys with relevant names.


## Useful commands {#commands}

```bash
# To get the administrator password
./init.sh --get-admin-password

# To generate new RSA keys for authentication
./init.sh --auth-rsa-gen

# To generate new RSA keys for Temporal
./init.sh --temporal-rsa-gen

# To specify the authentication provider configuration file
./init.sh --auth-providers-config ./my-auth-config.json

# To create a PostgreSQL backup prior to rotation
./init.sh --dump-postgres

# To check pod statuses after rotation
./init.sh --kubectl get pods

# To view logs to diagnose issues
./init.sh --stern .
```

<!-- source: en/_includes/clickhouse-disclaimer.md -->
_ClickHouse® is a registered trademark of [ClickHouse, Inc](https://clickhouse.com)._
<!-- endsource: en/_includes/clickhouse-disclaimer.md -->