Add configurable nodeport (#152)

This commit is contained in:
Jason O'Donnell 2019-12-18 12:22:19 -05:00 committed by GitHub
parent 36d6c283e4
commit 268c2418d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 1 deletions

View file

@ -32,6 +32,9 @@ spec:
- name: http
port: {{ .Values.server.service.port }}
targetPort: {{ .Values.server.service.targetPort }}
{{- if and (.Values.server.service.nodePort) (eq (.Values.server.service.type | toString) "NodePort") }}
nodePort: {{ .Values.server.service.nodePort }}
{{- end }}
- name: internal
port: 8201
targetPort: 8201

View file

@ -303,3 +303,59 @@ load _helpers
yq -r '.spec.ports[0].targetPort' | tee /dev/stderr)
[ "${actual}" = "80" ]
}
@test "server/Service: nodeport can set" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-service.yaml \
--set 'server.dev.enabled=true' \
--set 'server.service.type=NodePort' \
--set 'server.service.nodePort=30008' \
. | tee /dev/stderr |
yq -r '.spec.ports[0].nodePort' | tee /dev/stderr)
[ "${actual}" = "30008" ]
local actual=$(helm template \
-x templates/server-service.yaml \
--set 'server.ha.enabled=true' \
--set 'server.service.type=NodePort' \
--set 'server.service.nodePort=30009' \
. | tee /dev/stderr |
yq -r '.spec.ports[0].nodePort' | tee /dev/stderr)
[ "${actual}" = "30009" ]
local actual=$(helm template \
-x templates/server-service.yaml \
--set 'server.service.type=NodePort' \
--set 'server.service.nodePort=30010' \
. | tee /dev/stderr |
yq -r '.spec.ports[0].nodePort' | tee /dev/stderr)
[ "${actual}" = "30010" ]
}
@test "server/Service: nodeport can't set when type isn't NodePort" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-service.yaml \
--set 'server.dev.enabled=true' \
--set 'server.service.nodePort=30008' \
. | tee /dev/stderr |
yq -r '.spec.ports[0].nodePort' | tee /dev/stderr)
[ "${actual}" = "null" ]
local actual=$(helm template \
-x templates/server-service.yaml \
--set 'server.ha.enabled=true' \
--set 'server.service.nodePort=30009' \
. | tee /dev/stderr |
yq -r '.spec.ports[0].nodePort' | tee /dev/stderr)
[ "${actual}" = "null" ]
local actual=$(helm template \
-x templates/server-service.yaml \
--set 'server.standalone.enabled=true' \
--set 'server.service.nodePort=30010' \
. | tee /dev/stderr |
yq -r '.spec.ports[0].nodePort' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

View file

@ -139,6 +139,14 @@ server:
# load balancer.
# clusterIP: None
# Configures the service type for the main Vault service. Can be ClusterIP
# or NodePort.
#type: ClusterIP
# If type is set to "NodePort", a specific nodePort value can be configured,
# will be random if left blank.
#nodePort: 30000
# Port on which Vault server is listening
port: 8200
# Target port to which the service should be mapped to