ability to specify prefix for catalog sync

This commit is contained in:
Mitchell Hashimoto 2018-09-25 09:10:05 -05:00
parent 0931239bee
commit 560c461c9b
No known key found for this signature in database
GPG key ID: 744E147AA52F5B0A
3 changed files with 32 additions and 0 deletions

View file

@ -50,5 +50,8 @@ spec:
-to-k8s=false \ -to-k8s=false \
{{- end }} {{- end }}
-consul-domain={{ .Values.global.domain }} \ -consul-domain={{ .Values.global.domain }} \
{{- if .Values.syncCatalog.k8sPrefix }}
-k8s-service-prefix="{{ .Values.syncCatalog.k8sPrefix}}" \
{{- end }}
-k8s-write-namespace=${NAMESPACE} -k8s-write-namespace=${NAMESPACE}
{{- end }} {{- end }}

View file

@ -99,3 +99,27 @@ load _helpers
yq '.spec.template.spec.containers[0].command | any(contains("-to-consul"))' | tee /dev/stderr) yq '.spec.template.spec.containers[0].command | any(contains("-to-consul"))' | tee /dev/stderr)
[ "${actual}" = "false" ] [ "${actual}" = "false" ]
} }
#--------------------------------------------------------------------
# k8sPrefix
@test "syncCatalog/Deployment: no k8sPrefix by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/sync-catalog-deployment.yaml \
--set 'syncCatalog.enabled=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-k8s-service-prefix"))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "syncCatalog/Deployment: can specify k8sPrefix" {
cd `chart_dir`
local actual=$(helm template \
-x templates/sync-catalog-deployment.yaml \
--set 'syncCatalog.enabled=true' \
--set 'syncCatalog.k8sPrefix=foo-' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-k8s-service-prefix=\"foo-\""))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

View file

@ -143,6 +143,11 @@ syncCatalog:
toConsul: true toConsul: true
toK8S: true toK8S: true
# k8sPrefix is the service prefix to prepend to services before registering
# with Kubernetes. For example "consul-" will register all services
# prepended with "consul-".
k8sPrefix: null
# ConnectInject will enable the automatic Connect sidecar injector. # ConnectInject will enable the automatic Connect sidecar injector.
connectInject: connectInject:
enabled: false # "-" disable this by default for now until the image is public enabled: false # "-" disable this by default for now until the image is public