{{- if .Values.rbac.create -}}
kind: ClusterRoleBinding
{{- if .Values.agent.supportOpenshift }}
apiVersion: v1
{{- else }}
apiVersion: rbac.authorization.k8s.io/v1
{{- end }}
metadata:
  name: {{ template "instana-agent.fullname" . }}
  labels:
    {{- include "instana-agent.commonLabels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
  name: {{ template "instana-agent.serviceAccountName" . }}
  namespace: {{ .Release.Namespace }}
roleRef:
  kind: ClusterRole
  name: {{ template "instana-agent.fullname" . }}
  {{- if not .Values.agent.supportOpenshift }}
  apiGroup: rbac.authorization.k8s.io
  {{- end -}}
{{- end -}}
