Promtail basic auth using kubernetes secret

I can’t find any documentation on this, and it’s very possible it’s just my admittedly limited understanding of helm.

I’m simply trying to use basic auth to connect to the Loki instance while using a Kubernetes secret instead of plaintext credentials in the helm values

This works perfect:

  snippets:
    extraClientConfigs: |
      basic_auth:
        username: myusername
        password: mypassword

I created a secret like this:

kubectl create secret generic loki-credentials -n monitoring --from-literal=password="mypassword" --from-literal=username="myusername"

and now I want to use that in the values.yaml file.

This is what I got so far:

extraEnv:
  - name: LOKI_USERNAME
    valueFrom:
      secretKeyRef:
        name: loki-credentials
        key: username
  - name: LOKI_PASSWORD
    valueFrom:
      secretKeyRef:
        name: loki-credentials
        key: password

extraArgs:
  - -client.external-labels=stack=development
  - -config.expand-env=true

config:
  serverPort: 3101
  lokiAddress: myurl
  snippets:
    extraClientConfigs: |
      basic_auth:
        username: ${LOKI_USERNAME}
        password: ${LOKI_PASSWORD}
 Chart version: 3.1.0
 Promtail version: 2.1.0

Any help would be much appreciated!

its a bit of a time consuming question that goes beyond a normal question. if you need support on that you can write me a pm and we will find a solution

turns out my password wasn’t saving correctly, a “$” in the string was causing issues. More details on https://stackoverflow.com/questions/66462924/promtail-basic-auth-using-kubernetes-secret-in-helm-values-yaml

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.