From 117fff79bc2e5f504e581c38725aa8410db33bf5 Mon Sep 17 00:00:00 2001 From: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com> Date: Thu, 20 Aug 2020 19:03:12 -0400 Subject: [PATCH] Add vault-k8s metrics configurable (#372) --- templates/injector-deployment.yaml | 4 ++++ test/unit/injector-deployment.bats | 17 +++++++++++++++++ values.yaml | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/templates/injector-deployment.yaml b/templates/injector-deployment.yaml index 8768f7d..17f28b5 100644 --- a/templates/injector-deployment.yaml +++ b/templates/injector-deployment.yaml @@ -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 diff --git a/test/unit/injector-deployment.bats b/test/unit/injector-deployment.bats index 9e09e42..30cd2df 100755 --- a/test/unit/injector-deployment.bats +++ b/test/unit/injector-deployment.bats @@ -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 \ diff --git a/values.yaml b/values.yaml index 48b8823..271fda7 100644 --- a/values.yaml +++ b/values.yaml @@ -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: ""