Skip to content

Commit

Permalink
Add global.extraLabels values.yaml setting (#1771) (#1778)
Browse files Browse the repository at this point in the history
* Add global.extraLabels values.yaml setting
This setting lets you apply a set of labels to all pods created by the
consul-k8s helm chart.
* Also apply global extra labels to deployments/daemonsets/statefulsets/jobs
* Add global extraLabels to sync catalog deployment

Co-authored-by: Chris Bruce <christopher.bruce@blackrock.com>
  • Loading branch information
Ashwin Venkatesh and brucec5 authored Dec 7, 2022
1 parent ab920e1 commit 6bdb8e6
Show file tree
Hide file tree
Showing 37 changed files with 918 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: api-gateway-controller
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.apiGateway.controller.replicas }}
selector:
Expand Down Expand Up @@ -44,6 +47,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: api-gateway-controller
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "consul.fullname" . }}-api-gateway-controller
containers:
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/client-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: client
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
{{- if .Values.client.updateStrategy }}
updateStrategy:
Expand All @@ -45,6 +48,9 @@ spec:
{{- if .Values.client.extraLabels }}
{{- toYaml .Values.client.extraLabels | nindent 8 }}
{{- end }}
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.global.secretsBackend.vault.enabled }}
"vault.hashicorp.com/agent-inject": "true"
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/cni-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: cni
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
{{- if .Values.connectInject.cni.updateStrategy }}
updateStrategy:
Expand All @@ -29,6 +32,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: cni
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
consul.hashicorp.com/connect-inject: "false"
spec:
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/connect-inject-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: connect-injector
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.connectInject.replicas }}
selector:
Expand All @@ -41,6 +44,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: connect-injector
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
{{- if .Values.connectInject.annotations }}
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/create-federation-secret-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: create-federation-secret
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
annotations:
"helm.sh/hook": post-install,post-upgrade
{{- /* Hook weight needs to be 1 so that the service account is provisioned first */}}
Expand All @@ -27,6 +30,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: create-federation-secret
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
spec:
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/enterprise-license-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: license
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-weight": "100"
Expand All @@ -31,6 +34,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: license
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: gossip-encryption-autogenerate
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "1"
Expand All @@ -27,6 +30,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: gossip-encryption-autogenerate
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
spec:
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/ingress-gateways-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ metadata:
release: {{ $root.Release.Name }}
component: ingress-gateway
ingress-gateway-name: {{ template "consul.fullname" $root }}-{{ .name }}
{{- if $root.Values.global.extraLabels }}
{{- toYaml $root.Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
replicas: {{ default $defaults.replicas .replicas }}
selector:
Expand All @@ -65,6 +68,9 @@ spec:
release: {{ $root.Release.Name }}
component: ingress-gateway
ingress-gateway-name: {{ template "consul.fullname" $root }}-{{ .name }}
{{- if $root.Values.global.extraLabels }}
{{- toYaml $root.Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
{{- if (and $root.Values.global.secretsBackend.vault.enabled $root.Values.global.tls.enabled) }}
"vault.hashicorp.com/agent-init-first": "true"
Expand Down
8 changes: 7 additions & 1 deletion charts/consul/templates/mesh-gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: mesh-gateway
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.meshGateway.replicas }}
selector:
Expand All @@ -34,6 +37,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: mesh-gateway
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
{{- if (and .Values.global.secretsBackend.vault.enabled .Values.global.tls.enabled) }}
Expand Down Expand Up @@ -352,7 +358,7 @@ spec:
lifecycle:
preStop:
exec:
command:
command:
- "/bin/sh"
- "-ec"
- "/consul-bin/consul services deregister -id=\"{{ .Values.meshGateway.consulServiceName }}\""
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/partition-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: partition-init
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "2"
Expand All @@ -27,6 +30,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: partition-init
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
{{- if (and .Values.global.secretsBackend.vault.enabled (or .Values.global.tls.enabled .Values.global.acls.manageSystemACLs)) }}
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/server-acl-init-cleanup-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: server-acl-init-cleanup
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-weight": "0"
Expand All @@ -39,6 +42,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: server-acl-init-cleanup
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
spec:
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: server-acl-init
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
template:
metadata:
Expand All @@ -36,6 +39,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: server-acl-init
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
{{- if .Values.global.secretsBackend.vault.enabled }}
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: server
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
serviceName: {{ template "consul.fullname" . }}-server
podManagementPolicy: Parallel
Expand Down Expand Up @@ -56,6 +59,9 @@ spec:
{{- if .Values.server.extraLabels }}
{{- toYaml .Values.server.extraLabels | nindent 8 }}
{{- end }}
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
{{- if .Values.global.secretsBackend.vault.enabled }}
"vault.hashicorp.com/agent-inject": "true"
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/sync-catalog-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: sync-catalog
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
replicas: 1
selector:
Expand All @@ -31,6 +34,9 @@ spec:
{{- if .Values.syncCatalog.extraLabels }}
{{- toYaml .Values.syncCatalog.extraLabels | nindent 8 }}
{{- end }}
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
{{- if .Values.syncCatalog.annotations }}
Expand Down
8 changes: 7 additions & 1 deletion charts/consul/templates/terminating-gateways-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ metadata:
release: {{ $root.Release.Name }}
component: terminating-gateway
terminating-gateway-name: {{ template "consul.fullname" $root }}-{{ .name }}
{{- if $root.Values.global.extraLabels }}
{{- toYaml $root.Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
replicas: {{ default $defaults.replicas .replicas }}
selector:
Expand All @@ -68,6 +71,9 @@ spec:
release: {{ $root.Release.Name }}
component: terminating-gateway
terminating-gateway-name: {{ template "consul.fullname" $root }}-{{ .name }}
{{- if $root.Values.global.extraLabels }}
{{- toYaml $root.Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
{{- if (and $root.Values.global.secretsBackend.vault.enabled $root.Values.global.tls.enabled) }}
"vault.hashicorp.com/agent-init-first": "true"
Expand Down Expand Up @@ -199,7 +205,7 @@ spec:
- name: CONSUL_HTTP_ADDR
value: http://$(HOST_IP):8500
{{- end }}
command:
command:
- "/bin/sh"
- "-ec"
- |
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/tls-init-cleanup-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: tls-init-cleanup
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded
Expand All @@ -27,6 +30,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: tls-init-cleanup
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
spec:
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/tls-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: tls-init
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-weight": "1"
Expand All @@ -27,6 +30,9 @@ spec:
chart: {{ template "consul.chart" . }}
release: {{ .Release.Name }}
component: tls-init
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
spec:
Expand Down
6 changes: 6 additions & 0 deletions charts/consul/templates/webhook-cert-manager-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: webhook-cert-manager
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 4 }}
{{- end }}
spec:
replicas: 1
selector:
Expand All @@ -28,6 +31,9 @@ spec:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: webhook-cert-manager
{{- if .Values.global.extraLabels }}
{{- toYaml .Values.global.extraLabels | nindent 8 }}
{{- end }}
annotations:
"consul.hashicorp.com/connect-inject": "false"
"consul.hashicorp.com/config-checksum": {{ include (print $.Template.BasePath "/webhook-cert-manager-configmap.yaml") . | sha256sum }}
Expand Down
Loading

0 comments on commit 6bdb8e6

Please sign in to comment.