Skip to content

Commit

Permalink
Allow to apply additional labels to the connect inject pods (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilpianista authored Nov 11, 2022
1 parent da1e0c8 commit d7cbe44
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions charts/consul/templates/connect-inject-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: connect-injector
{{- if .Values.connectInject.extraLabels }}
{{- toYaml .Values.connectInject.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
{{- if .Values.connectInject.annotations }}
Expand Down
25 changes: 25 additions & 0 deletions charts/consul/test/unit/connect-inject-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,31 @@ load _helpers
[ "${actual}" = "name" ]
}

#--------------------------------------------------------------------
# extraLabels

@test "connectInject/Deployment: no extra labels defined by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.labels | del(."app") | del(."chart") | del(."release") | del(."component")' | tee /dev/stderr)
[ "${actual}" = "{}" ]
}

@test "connectInject/Deployment: can set extra labels" {
cd `chart_dir`
local actual=$(helm template \
-s templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
--set 'connectInject.extraLabels.foo=bar' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.labels.foo' | tee /dev/stderr)

[ "${actual}" = "bar" ]
}

#--------------------------------------------------------------------
# annotations

Expand Down
13 changes: 13 additions & 0 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,19 @@ connectInject:
# Optional priorityClassName.
priorityClassName: ""

# Extra labels to attach to the connect inject pods. This should be a YAML map.
#
# Example:
#
# ```yaml
# extraLabels:
# labelKey: label-value
# anotherLabelKey: another-label-value
# ```
#
# @type: map
extraLabels: null

# This value defines additional annotations for
# connect inject pods. This should be formatted as a multi-line string.
#
Expand Down

0 comments on commit d7cbe44

Please sign in to comment.