From 71b899159c4a7ff73789e34475455f9c8b80ef42 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 25 Sep 2018 09:19:19 -0500 Subject: [PATCH] add global.imageK8S for consul-k8s --- templates/sync-catalog-deployment.yaml | 2 +- test/unit/sync-catalog-deployment.bats | 26 ++++++++++++++++++++++++++ values.yaml | 5 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/templates/sync-catalog-deployment.yaml b/templates/sync-catalog-deployment.yaml index 0eb863b..937891d 100644 --- a/templates/sync-catalog-deployment.yaml +++ b/templates/sync-catalog-deployment.yaml @@ -27,7 +27,7 @@ spec: spec: containers: - name: consul-sync-catalog - image: "{{ .Values.syncCatalog.image }}" + image: "{{ default .Values.global.imageK8S .Values.syncCatalog.image }}" env: - name: HOST_IP valueFrom: diff --git a/test/unit/sync-catalog-deployment.bats b/test/unit/sync-catalog-deployment.bats index b623543..c9f0f30 100755 --- a/test/unit/sync-catalog-deployment.bats +++ b/test/unit/sync-catalog-deployment.bats @@ -42,6 +42,32 @@ load _helpers [ "${actual}" = "false" ] } +#-------------------------------------------------------------------- +# image + +@test "syncCatalog/Deployment: image defaults to global.imageK8S" { + cd `chart_dir` + local actual=$(helm template \ + -x templates/sync-catalog-deployment.yaml \ + --set 'global.imageK8S=bar' \ + --set 'syncCatalog.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.containers[0].image' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} + +@test "syncCatalog/Deployment: image can be overridden with server.image" { + cd `chart_dir` + local actual=$(helm template \ + -x templates/sync-catalog-deployment.yaml \ + --set 'global.imageK8S=foo' \ + --set 'syncCatalog.enabled=true' \ + --set 'syncCatalog.image=bar' \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.containers[0].image' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} + #-------------------------------------------------------------------- # toConsul and toK8S diff --git a/values.yaml b/values.yaml index f88d989..83182d3 100644 --- a/values.yaml +++ b/values.yaml @@ -18,6 +18,11 @@ global: # servers below. This can be overridden per component. image: "consul:1.2.3" + # imageK8S is the name (and tag) of the consul-k8s Docker image that + # is used for functionality such as the catalog sync. This can be overridden + # per component below. + imageK8S: "hashicorp/consul-k8s:0.1.0" + # Datacenter is the name of the datacenter that the agents should register # as. This shouldn't be changed once the Consul cluster is up and running # since Consul doesn't support an automatic way to change this value