<p>I am using Kubernetes to deploy my grafana dashboard and I am trying to  use Kubernetes Secrets  for saving grafana admin-password .. Here is my yaml file for secret</p>

<pre><code>    apiVersion: v1
    kind: Secret
    metadata:
      name: $APP_INSTANCE_NAME-grafana
      labels:
        app.kubernetes.io/name: $APP_INSTANCE_NAME
        app.kubernetes.io/component: grafana
    type: Opaque
    data:
      # By default, admin-user is set to `admin`
      admin-user: YWRtaW4=
      admin-password: "$GRAFANA_GENERATED_PASSWORD"
</code></pre>

<p>value for GRAFANA_GENERATED_PASSWORD is base64 encoded and exported like</p>

<pre><code>export GRAFANA_GENERATED_PASSWORD="$(echo -n $PASSWORD | base64)"
</code></pre>

<p>where PASSWORD is a variable which i exported on my machine like 
   <code>export PASSWORD=qwerty123</code></p>

<p>I am trying to pass  the value of GRAFANA_GENERATED_PASSWORD to the yaml file for secret like</p>

<pre><code>envsubst '$GRAFANA_GENERATED_PASSWORD'  &gt; "grafana_secret.yaml"
</code></pre>

<p>The yaml file after passing the base64 encoded value looks like </p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: kafka-monitor-grafana
  labels:
    app.kubernetes.io/name: kafka-monitor
    app.kubernetes.io/component: grafana
type: Opaque
data:
  # By default, admin-user is set to `admin`
  admin-user: YWRtaW4=
  admin-password: "cXdlcnR5MTIz"
</code></pre>

<p>After deploying all my objects i couldn't login to my dashboard using password qwerty123 which is encoded properly .. </p>

<p>But when i try to encode my password like 
<code>export GRAFANA_GENERATED_PASSWORD="$(echo -n 'qwerty123' | base64)</code>"</p>

<p>It is working properly and i can login to my dashboard using the password qwerty123 ..
Looks like the problem occur when i encode  my password using  a variable  ...
But i  have encode my password using a variable </p>

Pratheesh
<p>As mentioned in <strong>@Pratheesh</strong> comment, after deploy the grafana for the first time, the persistent volume was not deleted/recreated and the file <code>grafana.db</code> that contains the Grafana dashboard password still keeping the old password.</p>

<p>In order to solve, the PersistentVolume (pv) need to be deleted before apply the secret with the new password.</p>
