extraConfig support for consul clients
This commit is contained in:
parent
7baa854376
commit
71e2fefc62
4 changed files with 80 additions and 0 deletions
16
templates/client-config-configmap.yaml
Normal file
16
templates/client-config-configmap.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
# ConfigMap with extra configuration specified directly to the chart
|
||||
# for client agents only.
|
||||
{{- if (or (and (ne (.Values.client.enabled | toString) "-") .Values.client.enabled) (and (eq (.Values.client.enabled | toString) "-") .Values.global.enabled)) }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ template "consul.fullname" . }}-client-config
|
||||
labels:
|
||||
app: {{ template "consul.name" . }}
|
||||
chart: {{ template "consul.chart" . }}
|
||||
heritage: {{ .Release.Service }}
|
||||
release: {{ .Release.Name }}
|
||||
data:
|
||||
extra-from-values.json: |-
|
||||
{{ tpl .Values.client.extraConfig . | indent 4 }}
|
||||
{{- end }}
|
|
@ -34,6 +34,9 @@ spec:
|
|||
volumes:
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
- name: config
|
||||
configMap:
|
||||
name: {{ template "consul.fullname" . }}-client-config
|
||||
|
||||
containers:
|
||||
- name: consul
|
||||
|
@ -57,6 +60,7 @@ spec:
|
|||
-advertise="${POD_IP}" \
|
||||
-bind=0.0.0.0 \
|
||||
-client=0.0.0.0 \
|
||||
-config-dir=/consul/config \
|
||||
-datacenter={{ .Values.server.datacenter }} \
|
||||
-data-dir=/consul/data \
|
||||
{{- if (.Values.client.join) and (gt (len .Values.client.join) 0) }}
|
||||
|
@ -74,6 +78,8 @@ spec:
|
|||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /consul/data
|
||||
- name: config
|
||||
mountPath: /consul/config
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
|
|
53
test/unit/client-configmap.bats
Executable file
53
test/unit/client-configmap.bats
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load _helpers
|
||||
|
||||
@test "client/ConfigMap: enabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-config-configmap.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "client/ConfigMap: enable with global.enabled false" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-config-configmap.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'client.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "client/ConfigMap: disable with client.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-config-configmap.yaml \
|
||||
--set 'client.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "client/ConfigMap: disable with global.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-config-configmap.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "client/ConfigMap: extraConfig is set" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-config-configmap.yaml \
|
||||
--set 'client.extraConfig="{\"hello\": \"world\"}"' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.data["extra-from-values.json"] | match("world") | length' | tee /dev/stderr)
|
||||
[ ! -z "${actual}" ]
|
||||
}
|
|
@ -68,6 +68,11 @@ client:
|
|||
image: null
|
||||
join: null
|
||||
|
||||
# extraConfig is a raw string of extra configuration to set with the
|
||||
# server. This should be JSON or HCL.
|
||||
extraConfig: |
|
||||
{}
|
||||
|
||||
# ConnectInject will enable the automatic Connect sidecar injector.
|
||||
connectInject:
|
||||
enabled: false # "-" disable this by default for now until the image is public
|
||||
|
|
Loading…
Reference in a new issue