{{- if .Values.updater.enabled -}}
{{- $updater := mustMergeOverwrite (mustDeepCopy .Values) .Values.updater -}}
{{- if $updater.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: {{ .Release.Name }}-updater
  namespace: {{ .Release.Namespace }}
{{- if $updater.extraLabels.roleBinding }}
  labels:
  {{- toYaml $updater.extraLabels.roleBinding | nindent 4 }}
{{- end }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: {{ .Release.Name }}-updater
subjects:
- kind: ServiceAccount
  name: {{ template "teleport-kube-agent-updater.serviceAccountName" . }}
  namespace: {{ .Release.Namespace }}
{{- end -}}
{{- end -}}
