From 7a56bb809e4e64b3d8dae89efad0406e78822519 Mon Sep 17 00:00:00 2001 From: John Murret Date: Sun, 13 Mar 2022 21:34:30 -0600 Subject: [PATCH] Adding -use-https flag to client-daemonset.yaml when externalServers are enabled --- charts/consul/templates/client-daemonset.yaml | 13 +++++++++++-- charts/consul/test/unit/client-daemonset.bats | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/charts/consul/templates/client-daemonset.yaml b/charts/consul/templates/client-daemonset.yaml index 176f876652..e500b06192 100644 --- a/charts/consul/templates/client-daemonset.yaml +++ b/charts/consul/templates/client-daemonset.yaml @@ -478,10 +478,16 @@ spec: value: "/consul/tls/ca/tls.crt" {{- end }} {{- end }} + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace command: - "/bin/sh" - "-ec" - | + CONSUL_FULLNAME="{{template "consul.fullname" . }}" + consul-k8s-control-plane acl-init \ -component-name=client \ -acl-auth-method="{{ template "consul.fullname" . }}-k8s-component-auth-method" \ @@ -490,20 +496,23 @@ spec: {{- end }} -log-level={{ default .Values.global.logLevel .Values.client.logLevel }} \ -log-json={{ .Values.global.logJSON }} \ - -init-type="client" \ {{- if .Values.externalServers.enabled }} + {{- if .Values.global.tls.enabled }} + -use-https \ + {{- end }} {{- range .Values.externalServers.hosts }} -server-address={{ quote . }} \ {{- end }} -server-port={{ .Values.externalServers.httpsPort }} \ {{- if .Values.externalServers.tlsServerName }} - -tls-server-name={{ .Values.externalServers.tlsServerName }} \ + -tls-server-name={{ .Values.externalServers.tlsServerName }} \ {{- end }} {{- else }} {{- range $index := until (.Values.server.replicas | int) }} -server-address="${CONSUL_FULLNAME}-server-{{ $index }}.${CONSUL_FULLNAME}-server.${NAMESPACE}.svc" \ {{- end }} {{- end }} + -init-type="client" volumeMounts: - name: aclconfig mountPath: /consul/aclconfig diff --git a/charts/consul/test/unit/client-daemonset.bats b/charts/consul/test/unit/client-daemonset.bats index 831d4df25e..0119041726 100755 --- a/charts/consul/test/unit/client-daemonset.bats +++ b/charts/consul/test/unit/client-daemonset.bats @@ -1355,6 +1355,7 @@ local actual=$(echo $object | local command=$(helm template \ -s templates/client-daemonset.yaml \ --set 'global.acls.manageSystemACLs=true' \ + --set 'global.tls.enabled=true' \ --set 'externalServers.enabled=true' \ --set 'server.enabled=false' \ --set 'externalServers.hosts[0]=computer' \