Skip to content

Commit

Permalink
Add vault-k8s metrics configurable (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonodonnell authored Aug 20, 2020
1 parent 4d6e79d commit 117fff7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions templates/injector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ spec:
- name: AGENT_INJECT_SET_SECURITY_CONTEXT
value: "false"
{{- end }}
{{- if .Values.injector.metrics.enabled }}
- name: AGENT_INJECT_TELEMETRY_PATH
value: "/metrics"
{{- end }}
{{- include "vault.extraEnvironmentVars" .Values.injector | nindent 12 }}
args:
- agent-inject
Expand Down
17 changes: 17 additions & 0 deletions test/unit/injector-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ load _helpers
[ "${actual}" = "250m" ]
}

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

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

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

@test "injector/deployment: manual TLS environment vars" {
cd `chart_dir`
local object=$(helm template \
Expand Down
4 changes: 4 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ injector:
# True if you want to enable vault agent injection.
enabled: true

# If true, will enable a node exporter metrics endpoint at /metrics.
metrics:
enabled: false

# External vault server address for the injector to use. Setting this will
# disable deployment of a vault server along with the injector.
externalVaultAddr: ""
Expand Down

0 comments on commit 117fff7

Please sign in to comment.