Skip to content

This guide describes how to change passwords for Monitoring and all components in it during installation and during the work.

Set passwords during deployment

During deploy you can specify admin users and passwords for the next components:

  • Grafana
  • VMAuth

Note: Because the VMAuth used as a proxy to external access for all VictoriaMetrics components it means that it's enough to change specific users and passwords only for VMAuth. Other components have no auth inside the Cloud.

Grafana deploy

In current versions the single source of truth for Grafana admin credentials is the grafana-admin-credentials Secret. The Secret is mounted read-only at /etc/grafana-admin, and grafana.ini reads these keys through Grafana's file provider ($__file{...}) rather than through environment variables:

  • GF_SECURITY_ADMIN_USER
  • GF_SECURITY_ADMIN_PASSWORD

The rendered ConfigMap therefore holds only file references, never the credentials themselves.

During deployment you can configure these credentials via values.yaml:

grafana:
  # Main way to specify admin credentials for Grafana.
  # These values are used to render the grafana-admin-credentials Secret when
  # grafana.disableDefaultAdminSecret=false (default).
  security:
    admin_user: admin
    admin_password: admin

Behaviour:

  • By default admin_user and admin_password are set to admin/admin.
  • If you set any of them to an empty string "", Monitoring Operator will:
  • on first installation: generate a random value and store it in the Secret;
  • on subsequent upgrades: keep the existing value from the Secret.
  • For backward compatibility, if the old section grafana.config.security.admin_user / grafana.config.security.admin_password is specified, its non-empty values override grafana.security.* only when rendering the Secret. New configurations should use grafana.security.*.

The grafana.disableDefaultAdminSecret flag controls who is responsible for creating the admin credentials Secret:

grafana:
  # false (default): Helm renders grafana-admin-credentials from grafana.security.*
  #                  and Grafana reads it from the mounted Secret.
  # true:            user is fully responsible for creating the Secret
  #                  {grafana-name}-admin-credentials with the required keys:
  #                  GF_SECURITY_ADMIN_USER and GF_SECURITY_ADMIN_PASSWORD.
  disableDefaultAdminSecret: false
  • When disableDefaultAdminSecret=false (default), Helm always creates/updates the grafana-admin-credentials Secret based on values from grafana.security.* (or legacy config.security.*, if present).
  • When disableDefaultAdminSecret=true, Helm does not create the Secret. Grafana reads the credentials from the Secret only if it exists. If the Secret is absent, the operator omits the security.admin_user and security.admin_password settings, so Grafana starts and falls back to its built-in default (admin/admin) and login is still possible. Once you create the Secret, the next reconciliation adds the settings. Grafana Operator does not use these credentials: it authenticates against the Grafana API with a projected ServiceAccount token (JWT).

Other external users and their passwords can't be set during deploy. During deploy you can specify only which auth provides will use in Grafana.

If Grafana was configured use a Basic Auth so you can use the official guide to change their passwords https://grafana.com/docs/grafana/latest/administration/user-management/user-preferences/.

Note: Please pay attention that if you are using OAuth2 or LDAP, or other external identity providers you need to manage users and their passwords in these identity providers.

VMAuth deploy

To specify VMAuth user during deploy you have to to add following in the deployment parameters:

victoriametrics:
  vmUser:
    install: true
    username: prometheus
    password: prometheus

Also, it's possible to specify the password of user from the Secret.

Warning! The Secret with a password must be pre-created before deploy.

victoriametrics:
  vmUser:
    install: true
    username: prometehus
    passwordRef:
      name: vmauth-secret  # the Secret name
      key: pass            # the key name inside the Secret

Change passwords after deploy

This section describes how to change user credentials in runtime.

Note: After you will change credentials please do not forget to change them in the CMDB parameters.

Grafana admin password change

To change Grafana's admin password you need to edit grafana-admin-credentials secret.

Find it in the namespace with Monitoring, for example using a command:

kubectl get secret -n <monitoring-namespace> grafana-admin-credentials
kubectl get secret -n <monitoring-namespace> grafana-admin-credentials

NAME                        TYPE     DATA   AGE
grafana-admin-credentials   Opaque   2      4h10m

And next need to edit it and change password:

> kubectl edit secrets -n <monitoring-namespace> grafana-admin-credentials

This opens your default editor and allows you to update the base64 encoded Secret values in the data field, such as in the following example:

# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: Secret
metadata:
  name: grafana-admin-credentials
  ...
data:
  GF_SECURITY_ADMIN_PASSWORD: YWRtaW4=
  GF_SECURITY_ADMIN_USER: YWRtaW4=
type: Opaque

Update base64 encoded password and save the file. Close the editor to update the secret. Following message confirms the secret was edited successfully.

> kubectl edit secrets -n <monitoring-namespace> grafana-admin-credentials
secret/grafana-admin-credentials edited

With a custom grafana.name, the Secret is named <grafana-name>-admin-credentials.

What happens after the Secret is updated

Grafana applies the password from the Secret only when it creates the admin user, so Monitoring Operator writes the new password to the Grafana database itself. The operator watches the admin credentials Secret, so a change starts a PlatformMonitoring reconciliation within seconds, even when the periodic repair is disabled. The operator then:

  1. Writes the new password checksum to the checksum/admin-secret pod template annotation of the Grafana custom resource. Grafana Operator restarts the Grafana pod.
  2. Finds a ready pod of the <grafana-name>-deployment Deployment. Until one is ready, PlatformMonitoring stays In progress, and the operator retries every 10 seconds without reconciling the Grafana datasources.
  3. Runs grafana cli admin reset-admin-password with the password from the Secret in that pod.
  4. Records the synced password checksum in the monitoring.netcracker.com/grafana-admin-password-checksum annotation of the Grafana custom resource. If the reset fails or does not finish within 2 minutes, the operator retries it on the next reconciliation.

The operator also runs the reset once for a newly created Grafana custom resource, because it can use an existing database, for example the volume kept from a Grafana Operator v4 installation.

The reset is required when Grafana keeps its database on a persistent volume or in an external database. Only the password is synced: changing GF_SECURITY_ADMIN_USER does not rename an existing admin user.

The monitoring-operator logs show the following messages:

Grafana admin password changed; resetting it in the Grafana database
Resetting Grafana admin password
Grafana admin password reset

To check the new password, run:

kubectl port-forward -n <monitoring-namespace> svc/<grafana-name>-service 3000:3000
curl -u <admin-user>:<new-password> http://localhost:3000/api/org

Release/0.57 or less

NOTE: If you use monitoring release/0.57 version or less Grafana credentials are stored into grafana CR and platform monitoring CR.

To change Grafana's admin password you need to edit PlatformMonitoring CR. Find it in the namespace with Monitoring, for example using a command:

kubectl get -n <monitoring_namespace> platformmonitorings.monitoring.netcracker.com

Usually it has a name platformmonitoring:

kubectl get -n monitoring platformmonitorings.monitoring.netcracker.com

NAME                 AGE
platformmonitoring   11d

And next need to edit it and change password:

grafana:
  config:
    security:
      admin_user: admin
      admin_password: admin

Monitoring-operator will start reconcile process, update Grafana CR and re-create grafana pod with new credentials.

VMAuth password change

To change VMAuth credentials in runtime you need to edit PlatformMonitoring CR or a secret with a password.

In case if password specified in the CR, find it in the namespace with Monitoring, for example using a command:

kubectl get -n <monitoring_namespace> platformmonitorings.monitoring.netcracker.com

usually it have a name platformmonitoring:

❯ kubectl get -n monitoring platformmonitorings.monitoring.netcracker.com
NAME                 AGE
platformmonitoring   11d

And next need to edit it and change password:

victoriametrics:
  vmUser:
    install: true
    username: prometehus
    password: prometheus

In case if password specified in the Secret, you need to find this Secret and change content in it.

The name of the secret you can find in the CMDB or PlatformMonitoring CR:

victoriametrics:
  vmUser:
    passwordRef:
      name: vmauth-secret  # the Secret name
      key: pass            # the key name inside the Secret

After it edit a Secret:

kubectl edit -n <monitoring_namespace> secret <secret_name>

Note: Please keep in mind, that all values in the Secret stored in base64 encoding. And before edit or save data you must encode them in base64. In Linux you can use a command:

echo -n "<password>" | base64