{{- if .Values.tiller.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: tiller-{{ .Values.tiller.role.name }}
  {{- if hasKey .Values "namespace" }}
  namespace: {{ .Values.namespace }}
  {{- end }}
  labels:
    app: helm
    name: tiller
    chart: {{ template "magic-namespace.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: {{ .Values.tiller.role.type }}
  name: {{ .Values.tiller.role.name }}
subjects:
- kind: ServiceAccount
  name: tiller
  {{- if hasKey .Values "namespace" }}
  namespace: {{ .Values.namespace }}
  {{- else }}
  namespace: {{ .Release.Namespace }}
  {{- end }}

{{- end }}
