Skip to content
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

feat: add AGENT_INJECT_VAULT_AUTH_PATH option to the injector #185

Merged
merged 1 commit into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: add AGENT_INJECT_VAULT_AUTH_PATH option to the injector
* Add related unit tests
  • Loading branch information
rasta-rocket committed Mar 3, 2020
commit 2816f6ab5551c187e3ae4df43e0d46436dbdb841
2 changes: 2 additions & 0 deletions templates/injector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
{{- else }}
value: {{ include "vault.scheme" . }}://{{ template "vault.fullname" . }}.{{ .Release.Namespace }}.svc:{{ .Values.server.service.port }}
{{- end }}
- name: AGENT_INJECT_VAULT_AUTH_PATH
value: {{ .Values.injector.authPath }}
- name: AGENT_INJECT_VAULT_IMAGE
value: "{{ .Values.injector.agentImage.repository }}:{{ .Values.injector.agentImage.tag }}"
{{- if .Values.injector.certs.secretName }}
Expand Down
45 changes: 39 additions & 6 deletions test/unit/injector-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@ load _helpers
yq -r '.spec.template.spec.containers[0].env' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.[4].name' | tee /dev/stderr)
yq -r '.[5].name' | tee /dev/stderr)
[ "${actual}" = "AGENT_INJECT_TLS_CERT_FILE" ]

local actual=$(echo $object |
yq -r '.[4].value' | tee /dev/stderr)
yq -r '.[5].value' | tee /dev/stderr)
[ "${actual}" = "/etc/webhook/certs/test.crt" ]

local actual=$(echo $object |
yq -r '.[5].name' | tee /dev/stderr)
yq -r '.[6].name' | tee /dev/stderr)
[ "${actual}" = "AGENT_INJECT_TLS_KEY_FILE" ]

local actual=$(echo $object |
yq -r '.[5].value' | tee /dev/stderr)
yq -r '.[6].value' | tee /dev/stderr)
[ "${actual}" = "/etc/webhook/certs/test.key" ]
}

Expand All @@ -147,11 +147,11 @@ load _helpers
yq -r '.spec.template.spec.containers[0].env' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.[4].name' | tee /dev/stderr)
yq -r '.[5].name' | tee /dev/stderr)
[ "${actual}" = "AGENT_INJECT_TLS_AUTO" ]

local actual=$(echo $object |
yq -r '.[5].name' | tee /dev/stderr)
yq -r '.[6].name' | tee /dev/stderr)
[ "${actual}" = "AGENT_INJECT_TLS_AUTO_HOSTS" ]
}

Expand Down Expand Up @@ -189,3 +189,36 @@ load _helpers
yq -r '.[2].value' | tee /dev/stderr)
[ "${actual}" = "http://not-external-test-vault.default.svc:8200" ]
}

@test "injector/deployment: default authPath" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/injector-deployment.yaml \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].env' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.[3].name' | tee /dev/stderr)
[ "${actual}" = "AGENT_INJECT_VAULT_AUTH_PATH" ]

local actual=$(echo $object |
yq -r '.[3].value' | tee /dev/stderr)
[ "${actual}" = "auth/kubernetes" ]
}

@test "injector/deployment: custom authPath" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/injector-deployment.yaml \
--set 'injector.authPath=auth/k8s' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].env' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.[3].name' | tee /dev/stderr)
[ "${actual}" = "AGENT_INJECT_VAULT_AUTH_PATH" ]

local actual=$(echo $object |
yq -r '.[3].value' | tee /dev/stderr)
[ "${actual}" = "auth/k8s" ]
}
rasta-rocket marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 4 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ injector:
repository: "vault"
tag: "1.3.2"

# Mount Path of the Vault Kubernetes Auth Method.
authPath: "auth/kubernetes"

# namespaceSelector is the selector for restricting the webhook to only
# specific namespaces. This should be set to a multiline string.
# See https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#matching-requests-namespaceselector
Expand Down Expand Up @@ -124,7 +127,7 @@ server:
# shareProcessNamespace enables process namespace sharing between Vault and the extraContainers
# This is useful if Vault must be signaled, e.g. to send a SIGHUP for log rotation
shareProcessNamespace: false

# extraArgs is a string containing additional Vault server arguments.
extraArgs: ""

Expand Down