Custom value of agent port (#489)
* configure the agent port * add unit test * remove default * remove default * Update values.yaml Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com> Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>
This commit is contained in:
parent
dc696bb1f3
commit
d8c2d2058c
5 changed files with 62 additions and 4 deletions
|
@ -53,7 +53,7 @@ spec:
|
||||||
{{- end }}
|
{{- end }}
|
||||||
env:
|
env:
|
||||||
- name: AGENT_INJECT_LISTEN
|
- name: AGENT_INJECT_LISTEN
|
||||||
value: ":8080"
|
value: {{ printf ":%v" .Values.injector.port }}
|
||||||
- name: AGENT_INJECT_LOG_LEVEL
|
- name: AGENT_INJECT_LOG_LEVEL
|
||||||
value: {{ .Values.injector.logLevel | default "info" }}
|
value: {{ .Values.injector.logLevel | default "info" }}
|
||||||
- name: AGENT_INJECT_VAULT_ADDR
|
- name: AGENT_INJECT_VAULT_ADDR
|
||||||
|
@ -104,7 +104,7 @@ spec:
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /health/ready
|
path: /health/ready
|
||||||
port: 8080
|
port: {{ .Values.injector.port }}
|
||||||
scheme: HTTPS
|
scheme: HTTPS
|
||||||
failureThreshold: 2
|
failureThreshold: 2
|
||||||
initialDelaySeconds: 5
|
initialDelaySeconds: 5
|
||||||
|
@ -114,7 +114,7 @@ spec:
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /health/ready
|
path: /health/ready
|
||||||
port: 8080
|
port: {{ .Values.injector.port }}
|
||||||
scheme: HTTPS
|
scheme: HTTPS
|
||||||
failureThreshold: 2
|
failureThreshold: 2
|
||||||
initialDelaySeconds: 5
|
initialDelaySeconds: 5
|
||||||
|
|
|
@ -12,7 +12,7 @@ metadata:
|
||||||
spec:
|
spec:
|
||||||
ports:
|
ports:
|
||||||
- port: 443
|
- port: 443
|
||||||
targetPort: 8080
|
targetPort: {{ .Values.injector.port }}
|
||||||
selector:
|
selector:
|
||||||
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector
|
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector
|
||||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
|
|
|
@ -422,6 +422,42 @@ load _helpers
|
||||||
[ "${actual}" = "bar" ]
|
[ "${actual}" = "bar" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# agent port
|
||||||
|
|
||||||
|
@test "injector/deployment: default agentPort" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local object=$(helm template \
|
||||||
|
--show-only templates/injector-deployment.yaml \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.template.spec.containers[0].env' | tee /dev/stderr)
|
||||||
|
|
||||||
|
local actual=$(echo $object |
|
||||||
|
yq -r '.[0].name' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "AGENT_INJECT_LISTEN" ]
|
||||||
|
|
||||||
|
local actual=$(echo $object |
|
||||||
|
yq -r '.[0].value' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = ":8080" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "injector/deployment: custom agentPort" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local object=$(helm template \
|
||||||
|
--show-only templates/injector-deployment.yaml \
|
||||||
|
--set 'injector.port=8443' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.template.spec.containers[0].env' | tee /dev/stderr)
|
||||||
|
|
||||||
|
local actual=$(echo $object |
|
||||||
|
yq -r '.[0].name' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "AGENT_INJECT_LISTEN" ]
|
||||||
|
|
||||||
|
local actual=$(echo $object |
|
||||||
|
yq -r '.[0].value' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = ":8443" ]
|
||||||
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# affinity
|
# affinity
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,25 @@ load _helpers
|
||||||
[ "${actual}" = "true" ]
|
[ "${actual}" = "true" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "injector/Service: service with default port" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/injector-service.yaml \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.ports[0].targetPort' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "8080" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "injector/Service: service with custom port" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/injector-service.yaml \
|
||||||
|
--set 'injector.port=8443' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.ports[0].targetPort' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "8443" ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "injector/Service: disable with global.enabled false" {
|
@test "injector/Service: disable with global.enabled false" {
|
||||||
cd `chart_dir`
|
cd `chart_dir`
|
||||||
local actual=$( (helm template \
|
local actual=$( (helm template \
|
||||||
|
|
|
@ -29,6 +29,9 @@ injector:
|
||||||
|
|
||||||
replicas: 1
|
replicas: 1
|
||||||
|
|
||||||
|
# Configures the port the injector should listen on
|
||||||
|
port: 8080
|
||||||
|
|
||||||
# If multiple replicas are specified, by default a leader-elector side-car
|
# If multiple replicas are specified, by default a leader-elector side-car
|
||||||
# will be created so that only one injector attempts to create TLS certificates.
|
# will be created so that only one injector attempts to create TLS certificates.
|
||||||
leaderElector:
|
leaderElector:
|
||||||
|
|
Loading…
Reference in a new issue