Add configurable nodeport (#152)
This commit is contained in:
parent
36d6c283e4
commit
268c2418d3
3 changed files with 68 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -302,4 +302,60 @@ load _helpers
|
|||
. | tee /dev/stderr |
|
||||
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" ]
|
||||
}
|
||||
|
|
|
@ -138,6 +138,14 @@ server:
|
|||
# used to communicate with pods directly through DNS instead of a round robin
|
||||
# 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
|
||||
|
|
Loading…
Reference in a new issue