# helm_charts_stsdiscovery-rolebinding.yaml
{{- if and .Values.autosharding.enabled .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: stsdiscovery-{{ template "kube-state-metrics.fullname" . }}
  namespace: {{ template "kube-state-metrics.namespace" . }}
  labels:
    app.kubernetes.io/name: {{ template "kube-state-metrics.name" . }}
    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/instance: {{ .Release.Name }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: stsdiscovery-{{ template "kube-state-metrics.fullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "kube-state-metrics.fullname" . }}
    namespace: {{ template "kube-state-metrics.namespace" . }}
{{- end }}