{{- if and .Values.openshift (semverCompare ">=1.9-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRoleBinding
metadata:
  name: neuvector-binding-app
  labels:
    chart: {{ template "neuvector.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
roleRef:
{{- if not .Values.openshift }}
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
{{- end }}
  name: neuvector-binding-app
subjects:
- kind: ServiceAccount
  name: default
  namespace: {{ .Release.Namespace }}
{{- if .Values.openshift }}
userNames:
- system:serviceaccount:{{ .Release.Namespace }}:default
{{- end }}

---

{{- if and .Values.openshift (semverCompare ">=1.9-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRoleBinding
metadata:
  name: neuvector-binding-rbac
  labels:
    chart: {{ template "neuvector.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
roleRef:
{{- if not .Values.openshift }}
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
{{- end }}
  name: neuvector-binding-rbac
subjects:
- kind: ServiceAccount
  name: default
  namespace: {{ .Release.Namespace }}
{{- if .Values.openshift }}
userNames:
- system:serviceaccount:{{ .Release.Namespace }}:default
{{- end }}

---

{{- if and .Values.openshift (semverCompare ">=1.9-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRoleBinding
metadata:
  name: neuvector-binding-admission
  labels:
    chart: {{ template "neuvector.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
roleRef:
{{- if not .Values.openshift }}
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
{{- end }}
  name: neuvector-binding-admission
subjects:
- kind: ServiceAccount
  name: default
  namespace: {{ .Release.Namespace }}
{{- if .Values.openshift }}
userNames:
- system:serviceaccount:{{ .Release.Namespace }}:default
{{- end }}
