{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: katib-ui
  labels:
    {{- include "katib.ui.clusterRoleLabels" . | nindent 4 }}
rules:
- apiGroups:
  - ""
  resources:
  - configmaps
  - namespaces
  verbs:
  - "*"
- apiGroups:
  - kubeflow.org
  resources:
  - experiments
  - trials
  - suggestions
  verbs:
  - "*"
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - list
- apiGroups:
  - ""
  resources:
  - pods/log
  verbs:
  - get
{{- if and .Values.rbac (.Values.rbac.kubeflow) (.Values.rbac.kubeflow.enabled) }}
- apiGroups:
  - authorization.k8s.io
  resources:
  - subjectaccessreviews
  verbs:
  - create
{{- end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: katib-ui
  labels:
    {{- include "katib.ui.clusterRoleLabels" . | nindent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: katib-ui
subjects:
- kind: ServiceAccount
  name: {{ include "katib.ui.serviceAccountName" . }}
  namespace: {{ include "katib.namespace" . }}
{{- end }}