Agent Sidecar Injector reads secret with delay

Hello!

I use Agent Sidecar Injector in Kubernetes and it reads secrets with a delay.
If my pod starts with this entrypoint script,

SECRETS=$(ls /vault/secrets)

for secretFile in $SECRETS; do
cat /vault/secrets/$secretFile >> /vaultEnvs
done

file /vaultEnvs is empty.
But if I add a few seconds pause before it, everything is OK

sleep 15

SECRETS=$(ls /vault/secrets)

for secretFile in $SECRETS; do
cat /vault/secrets/$secretFile >> /vaultEnvs
done

Is it possible for Agent Sidecar Injector read secret immediately without a delay?

1 Like

Is your pod an init-container or a normal running container?

In case you run an init-container, you can add the following annotation to ensure correct startup order vault.hashicorp.com/agent-init-first.

If you want to ensure that the secrets are pre-populated (this is done in another init-container), you can use the http://vault.hashicorp.com/agent-pre-populate annotation. This can be done for both the type of containers.

1 Like