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

Add extraPorts to the server's Service resource #1092

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Unreleased

Features:
* server: New `extraPorts` option for adding ports to the Vault's server Service.

## 0.29.1 (November 20, 2024)

Bugs:
Expand Down
3 changes: 3 additions & 0 deletions templates/server-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ spec:
- name: https-internal
port: 8201
targetPort: 8201
{{- if .Values.server.service.extraPorts -}}
{{ toYaml .Values.server.service.extraPorts | nindent 4}}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "vault.name" . }}
{{- if eq (.Values.server.service.instanceSelector.enabled | toString) "true" }}
Expand Down
25 changes: 25 additions & 0 deletions test/unit/server-service.bats
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,29 @@ load _helpers
. | tee /dev/stderr |
yq -r '.spec.ipFamilies' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "server/Service: adds extra ports" {
cd `chart_dir`

# Test that it defines it
local object=$(helm template \
--show-only templates/server-service.yaml \
--set 'server.service.extraPorts[0].name=foo' \
--set 'server.service.extraPorts[0].port=1111' \
--set 'server.service.extraPorts[0].targetPort=2222' \
. | tee /dev/stderr |
yq -r '.spec.ports[2] | select(.name == "foo")' | tee /dev/stderr)

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

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

local actual=$(echo $object |
yq -r '.targetPort' | tee /dev/stderr)
[ "${actual}" = "2222" ]
}
6 changes: 6 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,12 @@
},
"targetPort": {
"type": "integer"
},
"extraPorts": {
"type": [
"null",
"array"
]
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,13 @@ server:
# to the service.
annotations: {}

# extraPorts is a list of extra ports. Specified as a YAML list.
# Useful if you host additional services inside your Vault pod(s).
extraPorts: null
# - name: extra
# port: 9000
# targetPort: 9000

# This configures the Vault Statefulset to create a PVC for data
# storage when using the file or raft backend storage engines.
# See https://developer.hashicorp.com/vault/docs/configuration/storage to know more
Expand Down
Loading