From e31e70ea0b36717a5e3b38e99aeec32b22c0043c Mon Sep 17 00:00:00 2001 From: Dimitar Zafirov <45163383+mitashkistz@users.noreply.github.com> Date: Thu, 16 Feb 2023 20:49:07 +0200 Subject: [PATCH] Add extraPorts property (#841) --- CHANGELOG.md | 3 +++ templates/server-statefulset.yaml | 3 +++ test/unit/server-statefulset.bats | 23 +++++++++++++++++++++++ values.schema.json | 6 ++++++ values.yaml | 6 ++++++ 5 files changed, 41 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a647c2a8..063fd0925 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Unreleased +Features: +* server: New `extraPorts` option for adding ports to the Vault server statefulset [GH-841](https://github.com/hashicorp/vault-helm/pull/841) + ## 0.23.0 (November 28th, 2022) Changes: diff --git a/templates/server-statefulset.yaml b/templates/server-statefulset.yaml index 4defbb524..d7a34acb6 100644 --- a/templates/server-statefulset.yaml +++ b/templates/server-statefulset.yaml @@ -148,6 +148,9 @@ spec: name: https-internal - containerPort: 8202 name: {{ include "vault.scheme" . }}-rep + {{- if .Values.server.extraPorts -}} + {{ toYaml .Values.server.extraPorts | nindent 12}} + {{- end }} {{- if .Values.server.readinessProbe.enabled }} readinessProbe: {{- if .Values.server.readinessProbe.path }} diff --git a/test/unit/server-statefulset.bats b/test/unit/server-statefulset.bats index 6206e115e..e56ce8449 100755 --- a/test/unit/server-statefulset.bats +++ b/test/unit/server-statefulset.bats @@ -1806,3 +1806,26 @@ load _helpers yq -r '.spec.template.spec.hostNetwork' | tee /dev/stderr) [ "${actual}" = "true" ] } + +#-------------------------------------------------------------------- +# extraPorts + +@test "server/standalone-StatefulSet: adds extra ports" { + cd `chart_dir` + + # Test that it defines it + local object=$(helm template \ + --show-only templates/server-statefulset.yaml \ + --set 'server.extraPorts[0].containerPort=1111' \ + --set 'server.extraPorts[0].name=foo' \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.containers[0].ports[] | select(.name == "foo")' | tee /dev/stderr) + + local actual=$(echo $object | + yq -r '.containerPort' | tee /dev/stderr) + [ "${actual}" = "1111" ] + + local actual=$(echo $object | + yq -r '.name' | tee /dev/stderr) + [ "${actual}" = "foo" ] +} diff --git a/values.schema.json b/values.schema.json index c18395700..c52c20088 100644 --- a/values.schema.json +++ b/values.schema.json @@ -593,6 +593,12 @@ "extraArgs": { "type": "string" }, + "extraPorts": { + "type": [ + "null", + "array" + ] + }, "extraContainers": { "type": [ "null", diff --git a/values.yaml b/values.yaml index f007e12a0..08e9f21f0 100644 --- a/values.yaml +++ b/values.yaml @@ -456,6 +456,12 @@ server: # extraArgs is a string containing additional Vault server arguments. extraArgs: "" + # extraPorts is a list of extra ports. Specified as a YAML list. + # This is useful if you need to add additional ports to the statefulset in dynamic way. + extraPorts: null + # - containerPort: 8300 + # name: http-monitoring + # Used to define custom readinessProbe settings readinessProbe: enabled: true