Grafana の初期パスワードを忘れた

題名そのまんまです。Secret に設定されているのでそれを参照します。私は、Prometheus Operator を使って環境を作成しましたが、他でも手順は同じです。 まずは、Secret の確認。

kubectl -n monitoring get secrets
NAME                                                          TYPE                                  DATA   AGE
default-token-khm2r                                           kubernetes.io/service-account-token   3      31d
jaeger-operator-token-xhppz                                   kubernetes.io/service-account-token   3      31d
prometheus-grafana                                            Opaque                                3      31d
prometheus-grafana-test-token-ngb6k                           kubernetes.io/service-account-token   3      31d
prometheus-grafana-token-l5b79                                kubernetes.io/service-account-token   3      31d
prometheus-kube-state-metrics-token-52h22                     kubernetes.io/service-account-token   3      31d
prometheus-operator-token-fns8q                               kubernetes.io/service-account-token   3      31d
prometheus-prometheus-node-exporter-token-hzdsm               kubernetes.io/service-account-token   3      31d
prometheus-prometheus-oper-admission                          Opaque                                3      31d
prometheus-prometheus-oper-operator-token-dl4hg               kubernetes.io/service-account-token   3      31d
prometheus-prometheus-oper-prometheus-token-wh28n             kubernetes.io/service-account-token   3      31d
prometheus-prometheus-prometheus-oper-prometheus              Opaque                                1      31d
prometheus-prometheus-prometheus-oper-prometheus-tls-assets   Opaque                                0      31d
sh.helm.release.v1.prometheus.v1                              helm.sh/release.v1                    1      31d

これの prometheus-grafana ってやつに含まれています。

kubectl -n monitoring get secrets prometheus-grafana -o json
{
    "apiVersion": "v1",
    "data": {
        "admin-password": "cHJvbS1vcGVyYXRvcg==",
        "admin-user": "YWRtaW4=",
        "ldap-toml": ""
    },
    "kind": "Secret",
    "metadata": {
        "annotations": {
            "meta.helm.sh/release-name": "prometheus",
            "meta.helm.sh/release-namespace": "monitoring"
        },
        "creationTimestamp": "2021-12-20T12:35:25Z",
        "labels": {
            "app.kubernetes.io/instance": "prometheus",
            "app.kubernetes.io/managed-by": "Helm",
            "app.kubernetes.io/name": "grafana",
            "app.kubernetes.io/version": "6.7.3",
            "helm.sh/chart": "grafana-5.0.18"
        },
        "name": "prometheus-grafana",
        "namespace": "monitoring",
        "resourceVersion": "284323",
        "uid": "9856672f-b874-4640-9d1c-b84113bd7044"
    },
    "type": "Opaque"

なので、これでOK。

kubectl -n monitoring get secrets prometheus-grafana -o jsonpath='{.data.admin-password}' | base64 -d