I install Vault helm chart using values.yaml file and I want to execute Vault commands via postStart as follows:
extraEnvironmentVars:
VAULT_API_ADDR: http://127.0.0.1:8200
VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200
VAULT_ADDR: http://127.0.0.1:8200
postStart:
- /bin/sh
- -c
- “vault login root”
However I get error connection refused:
Exec lifecycle hook ([/bin/sh -c vault login root]) for Container “vault” in Pod “vault-0_m4d-system(1f4c49cd-c2e5-4370-96c0-1679c8c625b1)” failed - error: command ‘/bin/sh -c vault login root’ exited with 2: Error authenticating: error looking up token: Get “http://127.0.0.1:8200/v1/auth/token/lookup-self”: dial tcp 127.0.0.1:8200: connect: connection refused
, message: “Error authenticating: error looking up token: Get “http://127.0.0.1:8200/v1/auth/token/lookup-self”: dial tcp 127.0.0.1:8200: connect: connection refused\n”
when running the Vault login command within the pod manually (with kubectl exec) the command executes ok.