-
Notifications
You must be signed in to change notification settings - Fork 169
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
Support vault cacert bytes env #507
Changes from all commits
854ae71
0584c89
d50e787
c66100d
b28d518
ef1efc5
89a252b
8287054
45c63a0
da6722b
f2b80fa
ca52e6f
93ed4d9
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 |
---|---|---|
|
@@ -17,4 +17,4 @@ | |
|
||
# Output directory for binaries built in CircleCI | ||
/pkg | ||
/dist/ | ||
/dist/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,13 @@ func (a *Agent) ContainerEnvVars(init bool) ([]corev1.EnvVar, error) { | |
} | ||
} | ||
|
||
if a.Vault.CACertBytes != "" { | ||
envs = append(envs, corev1.EnvVar{ | ||
Name: "VAULT_CACERT_BYTES", | ||
Value: decodeIfBase64(a.Vault.CACertBytes), | ||
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. I guess going back to my previous comment, is there any reason not to make b64 encoding a requirement? The formatting of certs with all their carriage returns is to me frustrating at best trying to get into string values. 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. I don't see the benefit of making b64 required. Supporting the raw PEM is nice because it's how the environment variable is eventually consumed anyway, and supporting b64 is nice because as you say it can be frustrating when there are multiple levels of interpretation in the automation that gets the value into place. |
||
}) | ||
} | ||
|
||
// Add IRSA AWS Env variables for vault containers | ||
if a.Vault.AuthType == "aws" { | ||
envMap := a.getAwsEnvsFromContainer(a.Pod) | ||
|
@@ -160,3 +167,12 @@ func (a *Agent) ContainerEnvVars(init bool) ([]corev1.EnvVar, error) { | |
|
||
return envs, nil | ||
} | ||
|
||
func decodeIfBase64(s string) string { | ||
decoded, err := base64.StdEncoding.DecodeString(s) | ||
if err == nil { | ||
return string(decoded) | ||
} | ||
|
||
return s | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
global: | ||
tlsDisable: false | ||
injector: | ||
image: | ||
pullPolicy: Never | ||
affinity: null | ||
agentImage: | ||
tag: 1.15.0 | ||
server: | ||
image: | ||
tag: 1.15.0 | ||
dev: | ||
enabled: true | ||
logLevel: debug | ||
# >- to convert to a single line with no line breaks. | ||
extraArgs: >- | ||
-dev-tls | ||
-dev-tls-cert-dir=/tmp | ||
-dev-tls-san=vault.default.svc.cluster.local | ||
-dev-tls-san=vault.default.svc | ||
-dev-tls-san=vault.default | ||
-dev-tls-san=vault | ||
extraEnvironmentVars: | ||
VAULT_CACERT: /tmp/vault-ca.pem |
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.
Is this expected to be b64 encoded? Should we specify one way or another?
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.
It can be PEM-encoded or base64. I added some comments in d50e787 to document the optional base64 encoding.