Token/secret from file #24362
-
QuestionI need to load a secret from file (eg Right now, I've modified the helm chart I'm thinking that maybe there could a generic approach to this (values from files) in vector config processing OR at least in the helm chart. I'd be happy to create a PR if there's some direction on the preferred approach. Vector Configcommand:
- /bin/sh
- -c
- |
export KUBE_TOKEN="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"
exec /usr/local/bin/vector --config-dir "/etc/vector/"
customConfig:
sources:
...
pod_metrics:
type: prometheus_scrape
endpoints:
- https://kubernetes.default.svc/api/v1/nodes/$VECTOR_SELF_NODE_NAME/proxy/metrics/cadvisor
auth:
strategy: bearer
token: "$KUBE_TOKEN"
tls:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
...Vector LogsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Hi @fopina, you might want to look into the built in secret management which is likely what you're looking for. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I noticed Kubernete service account tokens are valid for 1 hour, the Vector secrets backend loads the token/file on boot only doesn't refresh it thus would become invalid, unless I'm mistaken, checked with Codex on Vector v0.54.0 (latest as of today). There's no way to set activeDeadlineSeconds in the vector dev helm chart, so either the Vector code has to change to refresh secret values, which is nicer imo, or the helm chart should have the option to set activeDeadlineSeconds so the pod can be recreated every hour. A temporary fix possible now is to set these args to the Vector helm chart, on any changes to the serviceaccount dir it will reload the config which will repopulate the secrets: Whole Codex code trace on Vector not refreshing secret backend secretsHere is the full execution path proving why flowchart TD
A[Vector startup or reload signal] --> B[load_from_paths_with_provider_and_secrets]
B --> C[SecretBackendLoader::retrieve_secrets]
C --> D[DirectoryBackend::retrieve]
D --> E[Read files once per requested key]
E --> F[Inject resolved values into config]
F --> G[Runtime uses concrete token string]
H[Token file rotates on disk] --> I{Any config reload event?}
I -- No --> J[No call back into retrieve_secrets]
I -- Yes --> B
Code path with references:
Why this means “no automatic refresh after boot”
So the precise claim is:
@thomasqueirozb could you reopen this please A side note secret backend name cannot contain dashes, if it contains dashes it will simply set the token to literraly SECRET[...] without substituting it, tried wrapping "SECRET[...]" in quotes, same issue How I confirmed the SECRET name limitationCan be tested by creating a service with a pod that prints the token sent by Vector like so: Details |
Beta Was this translation helpful? Give feedback.
Hi @fopina, you might want to look into the built in secret management which is likely what you're looking for.