Closed fizzamahdi closed 1 year ago
The templating language supports POST, but it's implicit, similar to how curl
will automatically switch to POST
if you provide body data. I think this modification should make it work (filling in the appropriate k8s namespace that you want the creds to be created in):
vault.hashicorp.com/agent-inject-template-token: |
{{- with secret "kubernetes/puas/us-east-1/maas-k8s/creds/k8s-secrets-engine-example" kubernetes_namespace=foo -}}
{{ index .Data.service_account_token }}
{{- end }}
Thank you for the clarification! Just adding the body worked for me.
Unlike the AWS and Database Secrets Engines where the "creds/:name" endpoints support GET requests, the Kubernetes Secrets Engine's "creds/:name" endpoint only supports POST requests. That type of request is currently not supported by the vault-agent container that gets injected into pods by the Vault Agent Injector.
Will the Vault Agent be able to support this in the future?
Current setup
We have two EKS clusters and there is an application in cluster A that needs access to the Kubernetes API in cluster B. A workload in Cluster A authenticatea to Vault via a kubernetes auth method for Cluster A and the Vault role has a policy attached to it that gives it the ability to read credentials from a kubernetes secrets engine for Cluster B.
Here are the specific:
test-role-list-pods
)kubernetes/puas/us-east-1/maas-k8s/
)k8s-secrets-engine-example
)k8s-auth-example
)kubernetes-puas-ana-k8s
)k8s-auth-example
)vault-k8s-secrets-engine-example
):vault-k8s:1.1.0
vault:1.12.1
Error message
The vault-agent-init container in a vault-k8s-secrets-engine-example pod has the following error message:
Additional info
We were using the vault agent to pull a long-lived static kubernetes service account token from a KV secrets engine, so we want to switch over to using the kubernetes secrets engine. However, since we are using EKS, we have an option of using AWS credentials to get a kubernetes token (i.e. aws eks get-token) as a workaround if needed.