Integrate Vault with the Armory Scale Agent Service
Before you begin
- This guide is for experienced Kubernetes and Armory CD users.
- You have read the Armory Scale Agent overview.
Authenticate Agent with Vault
The Armory Scale Agent is compatible with properties Armory CD uses for storing secrets in HashiCorp Vault. You put configuration in armory-agent.yaml
in the secrets.vault.*
section. You refer to Vault secrets using the same syntax you use in configuring secrets for Armory CD. See the Referencing Secrets section for details.
This is an example of what the Kubernetes service account configuration looks like in Agent, using an encryptedFile:
reference for kubeconfigFile
:
|
|
Dynamically load accounts from Vault
This requires you to install the Vault Injector Sidecar.
The Armory Scale Agent detects changes in the configuration file and manages new accounts that it finds. This makes it possible to use a sidecar for
adding and removing accounts dynamically instead of having a static ConfigMap
. The Vault guide specifies the following syntax:
vault kv put secret/kubernetes account01=@kubeconfig.yaml
- Keep
kubeconfig
files in one Vault secret (in this casesecret/kubernetes
). - Each field name corresponds to an account name in Armory CD.
- Each field value is the contents of the
kubeconfigFile
used by that account.
Configuration template
Replace the configuration files and kubeconfig
files with Vault injector annotations to provide a template.
|
|
- Make sure to include the required Vault injector annotations like
vault.hashicorp.com/role
orvault.hashicorp.com/agent-configmap
that correspond to your environment. - Be aware of the version of Vault’s KV engine currently in your environment. This guide assumes you have the secret engine KV version 2. For KV version 1, you need to modify the template to use
{{ range $k, $v := .Data }}
instead. See the Templating Language’s Versioned Read section for more information. - This template expects
secret/kubernets
to hold thekubeconfig file
: Make sure to replace both line 16 and 18 in case that’s not the case in your environment. - Make sure to include all other Agent Options that you require in your environment.
After addressing the preceding points, save the template as armory-agent-vault-patch.yaml
and refer to it in your kustomization.yaml
:
|
|
Troubleshooting
Agent deployment is to appearing / There are no spin-armory-agent pods
- Check the following commands for any error or warning message:
kubectl describe desploy spin-armory-agent | sed -ne '/^Events:$/,$p'
kubectl describe rs -l cluster=spin-armory-agent | sed -ne '/^Events:$/,$p'
- Error message:
Error creating: admission webhook "vault.hashicorp.com" denied the request: error validating agent configuration: no Vault role found
:- Make sure that the annotations
vault.hashicorp.com/role
orvault.hashicorp.com/agent-configmap
are set and they correspond to your environment
- Make sure that the annotations
Agent gets stuck in status Init
- Check for logs of the injector with the following command:
kubectl logs deploy/spin-armory-agent -c vault-agent-init
. - Error message:
[WARN] (view) vault.read(secret/kubernetes): no secret exists at secret/data/kubernetes (retry attempt 1 after "250ms")
:- Make sure to update the reference in
armory-agent-vault-patch.yaml
to a secret that is accessible in your environment.
- Make sure to update the reference in
Agent is in Crash loop back off
- Check for logs of armory-agent with the following command
kubectl logs deploy/spin-armory-agent -c armory-agent
. - Error message:
Error registering vault config: vault configuration error
:- Make sure to update
armory-agent-vault-patch.yaml
to include the propertiessecrets.vault.*
that correspond to your environment.
- Make sure to update
- Error message
failed to load configuration: error fetching key \"data\"
:- Your vault KV engine is using version 2. Make sure the template in
armory-agent-vault-patch.yaml
is using{{ range $k, $v := .Data.data }}
.
- Your vault KV engine is using version 2. Make sure the template in
Agent registers with 0 servers
- Check for logs of vault injector with the following command:
kubectl logs -f deploy/spin-armory-agent -c vault-agent
. - Error message
missing dependency: vault.read(secret/kubernetes)
:- Your vault KV engine is using version 1. Make sure the template in
armory-agent-vault-patch.yaml
is using{{ range $k, $v := .Data }}
.
- Your vault KV engine is using version 1. Make sure the template in
Feedback
Was this page helpful?
Thank you for letting us know!
Sorry to hear that. Please tell us how we can improve.
Last modified August 18, 2023: (02b163b7)