hashicorp / vault-helm

Helm chart to install Vault and other associated components.
Mozilla Public License 2.0
1.05k stars 868 forks source link

Cannot use HOSTNAME env var in VAULT_API_ADDR env var #993

Closed raphaelzoellner closed 5 months ago

raphaelzoellner commented 5 months ago

Describe the bug With the current helm chart one cannot use the predefined HOSTNAME environment variable in the predefined VAULT_API_ADDR variable due to the order of the defined environment variables.

To Reproduce Install the helm chart and set a value for server.ha.apiAddr to https://$(HOSTNAME).my-vault-helm-release-name-internal.my-namespace.svc.cluster.local:8200. This will render literally, not replacing the HOSTNAME variable reference due to the order of the environment variables defined in the StatefulSet. https://github.com/regiocom/vault-helm-fork/blob/ad64f921b5985d7862f9c62909f14796e8a199c2/templates/server-statefulset.yaml#L104-L117

Expected behavior One can use the predefined HOSTNAME variable when setting server.ha.apiAddr. This allows to issue TLS Certificates that are not bound to Pod IPs, but rather to the Pod DNS Entries managed by the StatefulSet which will only change when adding or removing replicas to/from the StatefulSet. https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id

Environment

Chart values:

server:
  ha:
    apiAddr: "https://$(HOSTNAME).my-vault-helm-release-name-internal.my-namespace.svc.cluster.local:8200"