Useful commands

This tutorial contains essential commands for administering DataLens On-premises.

Getting all logs from all application containers

./init.sh --stern .

Collecting logs from a single service

./init.sh --stern --tail 100 --no-follow deployment/datalens-enterprise-auth

Getting all the K8s cluster's events within the current namespace

./init.sh --kubectl get events

Deploying on a reduced configuration

Recommended minimum configuration for optimal performance:

- vCPUs: 8
- RAM: 16 GB

This configuration may also be suitable for deployment:

- vCPUs: 4
- RAM: 8 GB

You can even further reduce resources, though you will experience performance degradation:

- vCPUs: 2
- RAM: 4 GB

To override resource allocations for specific services, provide the required values in the values.yaml file.

You only need to provide the values you want to override, e.g.:

application:
    control_api:
    replicas: 1
    version: '0.29.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 1
        memory: 512Mi
        limits:
        memory: 1024Mi
    data_api:
    replicas: 1
    version: '0.29.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 1
        memory: 512Mi
        limits:
        memory: 1024Mi
    ui:
    replicas: 1
    version: '0.95.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 0.5
        memory: 256Mi
        limits:
        memory: 512Mi
    us:
    replicas: 1
    version: '0.79.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 0.5
        memory: 512Mi
        limits:
        memory: 1024Mi
    auth:
    replicas: 1
    version: '0.34.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 1
        memory: 512Mi
        limits:
        memory: 1024Mi

The following configuration reduces resources even further:

application:
    control_api:
    replicas: 1
    version: '0.29.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 1
        memory: 256Mi
        limits:
        memory: 512Mi
    data_api:
    replicas: 1
    version: '0.29.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 1
        memory: 512Mi
        limits:
        memory: 1024Mi
    ui:
    replicas: 1
    version: '0.95.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 0.25
        memory: 256Mi
        limits:
        memory: 512Mi
    us:
    replicas: 1
    version: '0.79.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 0.5
        memory: 256Mi
        limits:
        memory: 512Mi
    auth:
    replicas: 1
    version: '0.34.0'
    maxSurge: 50%
    maxUnavailable: 0
    resources:
        requests:
        cpu: 1
        memory: 256Mi
        limits:
        memory: 512Mi

To apply the specified settings, run the ./init.sh --values ./values.yaml command.

Rolling back to a previous release

export KUBECONFIG="/etc/rancher/k3s/k3s.yaml"

./bin/helm-amd64 rollback datalens-enterprise -n datalens-enterprise

Debugging LDAP integration

ldapsearch \
-H ldap://localhost:8389 \
-x \
-D cn=admin,dc=example,dc=org \
-w admin \
-b ou=users,dc=example,dc=org \
"(uid=bob)"
ldapsearch \
-H ldap://localhost:8389 \
-x \
-D cn=admin,dc=example,dc=org \
-w admin \
-b ou=groups,dc=example,dc=org \
"(&(objectClass=groupOfNames)(member=uid=bob,ou=users,dc=example,dc=org))"

Generating a new administrator password

echo ""
echo "Generate DataLens password hash..."

PASSWORD_LENGTH=32

PASSWORD_VALUE=$(openssl rand -base64 "${PASSWORD_LENGTH}" | tr -dc a-zA-Z0-9 | head -c "${PASSWORD_LENGTH}")

SALT=$(openssl rand 16)
SALT_HEX=$(echo -n "${SALT}" | od -A n -t x1 -v | tr -d ' \n')
SALT_BASE64URL=$(echo -n "${SALT}" | base64 | tr '+/' '-_' | tr -d '=')

echo "  new admin password: ${PASSWORD_VALUE}"

KEY_LENGTH=64
COST_ITERATIONS=16384
BLOCK_SIZE=8
PARALLELIZATION=1
MAX_MEMORY_BYTES=33554432

KEY_BASE64URL=$(
  openssl kdf -keylen "${KEY_LENGTH}" \
    -kdfopt "pass:${PASSWORD_VALUE}" -kdfopt "hexsalt:${SALT_HEX}" \
    -kdfopt "n:${COST_ITERATIONS}" -kdfopt "r:${BLOCK_SIZE}" -kdfopt "p:${PARALLELIZATION}" \
    -kdfopt "maxmem_bytes:${MAX_MEMORY_BYTES}" \
    -binary scrypt | base64 | tr '+/' '-_' | tr -d '='
)

PASSWORD_HASH="${SALT_BASE64URL}:${KEY_BASE64URL}"
    
echo "  new hash: ${PASSWORD_HASH}"

Updating the administrator password in the database

psql \
    --host "${POSTGRES_HOST}" \
    --port "${POSTGRES_PORT}" \
    --username "${POSTGRES_USER_AUTH}" \
    --dbname "${POSTGRES_DB_AUTH}" <<-EOSQL
  UPDATE auth_users SET password = '${PASSWORD_HASH}' WHERE login = 'admin';
EOSQL

Access deniedauthorization error

  1. Check that the secrets are populated correctly:

    secrets.AUTH_TOKEN_PRIVATE_KEY 
    secrets.AUTH_TOKEN_PUBLIC_KEY
    
  2. If you used the values.yaml file deployment mode, you will need to generate these secrets manually.

    Here is an example of the values.yaml file:

    KUBECONFIG=~/.kube/config ./init.sh --values ./values.deploy.yaml --ingress-domain <domain> --disable-postgres
    

    Key generation command:

    openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096
    

Login loop on successful authorization

  • Check the UI_APP_ENDPOINT value in the Auth service: the authorization cookie is issued to this value.
  • If the user logs in via a different endpoint, an incorrect cookie value will be used during authorization.

Getting CONTROL_API_CRYPTO_KEYfrom K8s secrets

./init.sh --kubectl get secret datalens-enterprise-secrets -o jsonpath='{.data.CONTROL_API_CRYPTO_KEY}' | base64 -d; echo

The output will remain base64-encoded. This is not an error but the correct base64 key value you need to save.

Recovering a workbook by its ID

 ./init.sh --kubectl exec -it deploy/datalens-enterprise-us -- node -e "fetch('http://localhost:8080/private/v2/workbooks/<WORKBOOK_ID>/restore',{method:'POST',headers:{'content-type':'application/json','x-us-master-token':process.env.MASTER_TOKEN}}).then(r=>r.json()).then(console.log)"

Where <WORKBOOK_ID> is the workbook ID.

Getting a list of deleted workbooks:

./init.sh --pg sh -c 'psql -U "${POSTGRES_USER}" -d "${POSTGRES_DB_US}" -c "SELECT encode_id(workbook_id) AS workbook_id,deleted_at FROM workbooks WHERE deleted_at IS NOT NULL"'

Copy and paste the exact command from above. You do not need to fill in any values.

Results

You have learned the essential commands for successfully administering DataLens On-premises.