Skip to content

Commit

Permalink
Support Vault server running with TLS (#874)
Browse files Browse the repository at this point in the history
* Change vault cluster in acceptance tests to only run with TLS. All tests will run against vault with TLS because that is the use case we think will be the most valuable for users to test
* Support adding Vault CA as a secret to pods that will be using vault agent. We need to add two annotations to pods:
      * vault.hashicorp.com/agent-extra-secret with the value of the vault CA secret name. The secret will be mounted to vault agent at /vault/custom path. See docs here
      * vault.hashicorp.com/ca-cert - with the path of the ca file inside the vault agent container. This should be /vault/custom/<secret key>
* Most pods will only need those annotations. The server pods also need the Vault CA secret to be mounted as a volume because it needs the CA to be on the file system for the vault connect CA provider.
  • Loading branch information
ishustava committed Dec 2, 2021
1 parent 45a9f7f commit cc449e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions acceptance/tests/vault/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ func TestVault(t *testing.T) {
_, err = vaultClient.Logical().Write("consul/data/secret/gossip", params)
require.NoError(t, err)

vaultCASecret := vault.CASecretName(vaultReleaseName)

// Bootstrap TLS creates the CA infrastructure required for ServerTLS and also creates the `consul-server` roles.
bootstrapTLS(t, vaultClient, consulReleaseName)

Expand Down
10 changes: 10 additions & 0 deletions charts/consul/test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,16 @@ load _helpers
[ "${actual}" = "true" ]
}

@test "server/StatefulSet: CA certificate is specified when TLS is enabled" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-statefulset.yaml \
--set 'global.tls.enabled=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].readinessProbe.exec.command | join(" ") | contains("--cacert /consul/tls/ca/tls.crt")' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "server/StatefulSet: HTTP is disabled in agent when httpsOnly is enabled" {
cd `chart_dir`
local actual=$(helm template \
Expand Down

0 comments on commit cc449e4

Please sign in to comment.