Hi,
We are testing HCP managed vault. Use case is (EKS) Cluster to HCP Vault on AWS. For now we are tesing public adress in HCP Vault.
Followed the tutorial HCP Vault with Amazon Elastic Kubernetes Service | Vault - HashiCorp Learn .
We have also tested the same configuration against open source vault cluster in our eks cluster, and there it works…
We have enabled:
1: vault auth enable Kubernetes
2: create auth/kubernetes/config as dokumentet in tutorial
3: vault secrets enable transit
4: vault write -f transit/keys/test
5. created the following policy test
path "transit/encrypt/test" {
capabilities = [ "update" ]
}
path "transit/decrypt/test" {
capabilities = [ "update" ]
}
6: created service account vault-auth in namespace (EKS)
7:
vault write auth/kubernetes/role/test bound_service_account_names=vault-auth bound_service_account_namespaces=*** policies=test ttl=24h
We test the policy with login to admin in HCP:
$ vault write transit/encrypt/transit1 plaintext=$(base64 <<< "some message")
Key Value
--- -----
ciphertext vault:v1:VaMZu3aXDSZd/S2gv6qgXi8YnzYSlA7/emQFPePRwvpeWfMBaItVjAw=
key_version 1
Test case 1:
We have connections from our eks cluster to HCP Vault with auth kubernetes token, so there everything works.
# curl -GET http://127.0.0.1:8200/v1/auth/token/lookup-self | jq -r ".data"
{
"creation_time": 1654091353,
"creation_ttl": 86400,
"display_name": "admin-auth-kubernetes-test-vault-auth",
"entity_id": "***..2d09d5c3",
"expire_time": "2022-06-02T13:49:14.686409588Z",
"explicit_max_ttl": 0,
"issue_time": "2022-06-01T13:49:13.051170384Z",
"last_renewal": "2022-06-01T13:49:14.686409708Z",
"last_renewal_time": 1654091354,
"meta": {
"role": "test",
"service_account_name": "vault-auth",
"service_account_namespace": "namespace",
"service_account_secret_name": "",
"service_account_uid": "cef0a8af-f279-*****"
},
"namespace_path": "admin/,
............
Test case 2:
We create a new policy for transit in order to give access to the key, but when trying to use the key we get a permission denied.
Polyci created, as per documentation the following policy should work:
But we always got permission denied agianst HCP vault.
path "transit/*" { capabilities = [ "update" ] }
path "transit/encrypt/test" {
capabilities = [ "update" ]
}
path "transit/decrypt/test" {
capabilities = [ "update" ]
}
# curl -s request POST --data '{"plaintext": "'`echo ***** | base64`'"}' http://127.0.0.1:8200/v1/transit/encrypt/test | jq .
{
"errors": [
"1 error occurred:\n\t* permission denied\n\n"