-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConfigMap with missing vault section should default to env vars #353
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package agent | |
|
||
import ( | ||
"encoding/base64" | ||
"strconv" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
@@ -64,6 +65,48 @@ func (a *Agent) ContainerEnvVars(init bool) ([]corev1.EnvVar, error) { | |
Name: "VAULT_CONFIG", | ||
Value: b64Config, | ||
}) | ||
} else { | ||
// set up environment variables to access Vault since "vault" section may not be present in the config | ||
if a.Vault.Address != "" { | ||
envs = append(envs, corev1.EnvVar{ | ||
Name: "VAULT_ADDR", | ||
Value: a.Vault.Address, | ||
}) | ||
} | ||
if a.Vault.CACert != "" { | ||
envs = append(envs, corev1.EnvVar{ | ||
Name: "VAULT_CACERT", | ||
Value: a.Vault.CACert, | ||
}) | ||
} | ||
if a.Vault.CAKey != "" { | ||
envs = append(envs, corev1.EnvVar{ | ||
Name: "VAULT_CAPATH", | ||
Value: a.Vault.CAKey, | ||
}) | ||
} | ||
if a.Vault.ClientCert != "" { | ||
envs = append(envs, corev1.EnvVar{ | ||
Name: "VAULT_CLIENT_CERT", | ||
Value: a.Vault.ClientCert, | ||
}) | ||
} | ||
if a.Vault.ClientKey != "" { | ||
envs = append(envs, corev1.EnvVar{ | ||
Name: "VAULT_CLIENT_KEY", | ||
Value: a.Vault.ClientKey, | ||
}) | ||
} | ||
envs = append(envs, corev1.EnvVar{ | ||
Name: "VAULT_SKIP_VERIFY", | ||
Value: strconv.FormatBool(a.Vault.TLSSkipVerify), | ||
}) | ||
if a.Vault.TLSServerName != "" { | ||
envs = append(envs, corev1.EnvVar{ | ||
Name: "VAULT_TLS_SERVER_NAME", | ||
Value: a.Vault.TLSServerName, | ||
}) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. Namespace isn't part of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. I only targeted the things that are in the |
||
} | ||
|
||
// Add IRSA AWS Env variables for vault containers | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Just making sure I understand) It looks like all these can be overridden by the user with annotations from https://www.vaultproject.io/docs/platform/k8s/injector/annotations#vault-annotations? So like for the vault address, the order of precedence would be:
vault
stanza in configmapvault.hashicorp.com/service
We may want to add a note about this new behavior in or adjacent to https://www.vaultproject.io/docs/platform/k8s/injector/examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I believe that is correct. I'll double-check it before merging, and add a ticket to update those docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I confirmed that
vault.hashicorp.com/service
will override the agent containerVAULT_ADDR
settings.