The password for loki is stored in a file for us, ...
# fluent-bit
a
The password for loki is stored in a file for us, and we don't want to provide this as a string in helm chart. It there any option/way to provide the password from file in FB?
Copy code
basic_auth:
            username: loki
            password_file: /etc/secrets/password-file
p
You can mount secrets as env vars and use it that way
a
Can this be done via Helm Chart of FB?
I am still not sure, how this can be used? Please share some context where I can read about it.
p
Sure, there's an envFrom section in the helm chart and even one that supports templating
If you have a secret for the password then you can mount that as an env var to use in the config. That's pretty common K8S usage, the main downside is you have to recreate the pod when the secret changes.
I imagine/hope at the moment the file you are making is essentially projected from a secret in which case it should be simple enough to switch it to an env var instead
once you have an env var you can just reference it in the config as
${VAR}
a
Gotcha ..
Something like this will work? The secret is saved without Key ...
Copy code
env:
      - name: LOKI_PASSWORD
        valueFrom:
          secretRef:
            name: loki-access-secret
    config:
      outputs:
        - name: "loki"
          match: "*"
          host: "loki.google.com"
          uri: "/loki/api/v1/push"
          port: 3100
          http_user: loki
          http_passwd: ${LOKI_PASSWORD}
          labels:
            cluster: test
p
yeah should work
a
Getting this error now:
Copy code
[2025/07/03 13:35:55] [error] [upstream] connection #47 to tcp://xx.xxx.xx.xx:3100 timed out after 10 seconds (connection timeout)
[2025/07/03 13:35:55] [error] [output:loki:loki.0] no upstream connections available
Looks like the credentials didn't went correctly ..
p
or the connection details are wrong
a
Loki is on 443, but now the tls thing is not working ..
p
have you turned on TLS?
tls on
what's your full config? it's hard to help with pieces
a
This is not working: http_passwd ${LOKI_PASSWORD}
When I gave the password directly, it worked ..
Copy code
values:
    env:
      - name: LOKI_PASSWORD
        valueFrom:
          secretKeyRef:
            name: loki-access-secret
            key: password-file
    config:
      outputs: |
        [OUTPUT]
            name        loki
            match       *
            host        loki-xxx.com
            uri         /loki/api/v1/push
            port        443
            http_user   loki
            http_passwd ${LOKI_PASSWORD}
            tls         on
            tls.verify  off
            compress    gzip
            labels      cluster=test
This is my complete values file ..
p
sure and is the actual environment variable set in your pod
it is just text substitution if it is so I bet something is wrong with it - maybe you need to decode it from base64 or something
a
Yes, base64 is correct. there is no issue ..
Actually, the env variable is not showing up inside the pod as well.
p
yeah so that's why then
if it's not there it'll be empty
check the pod spec to confirm the secret is being used to set the variable
if not then its an issue with your helm config
a
Secret is there, I can see inside the pod, It is showing up in env variable.
But, it is not getting replaced inside the cm when it is being read by the service ..
p
that does not matter mate, the CM is mounted into the pod and fluent bit uses the env var
${VAR}
means to use an environment variables
a
No, this is not working ..
The value is not getting substituted ..
p
if the environment variable is set on the pod it will be substituted into the config at runtime
a
Ok, this is working. It's my bad the credentials had '\n' encoded in them.
Thanks a lot for your help !!
Now the main work starts. Replacing FB with Promtail ..