apiVersion: v1
kind: ServiceAccount
metadata:
  name: katib-ui
  namespace: kubeflow
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: katib-ui
rules:
- apiGroups:
  - ""
  resources:
  - configmaps
  verbs:
  - '*'
- apiGroups:
  - kubeflow.org
  resources:
  - experiments
  - trials
  verbs:
  - '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: katib-ui
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: katib-ui
subjects:
- kind: ServiceAccount
  name: katib-ui
  namespace: kubeflow
---
apiVersion: v1
data:
  clusterDomain: {{ .Values.clusterDomain | quote }}
kind: ConfigMap
metadata:
  name: katib-parameters
  namespace: kubeflow
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: katib
    component: ui
  name: katib-ui
  namespace: kubeflow
spec:
  ports:
  - name: ui
    port: 80
    protocol: TCP
  selector:
    app: katib
    component: ui
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: katib
    component: ui
  name: katib-ui
  namespace: kubeflow
spec:
  replicas: 1
  selector:
    matchLabels:
      app: katib
      component: ui
  template:
    metadata:
      labels:
        app: katib
        component: ui
      name: katib-ui
    spec:
      containers:
      - command:
        - ./katib-ui
        image: gcr.io/kubeflow-images-public/katib/v1alpha2/katib-ui:v0.6.0-rc.0
        imagePullPolicy: IfNotPresent
        name: katib-ui
        ports:
        - containerPort: 80
          name: ui
      serviceAccountName: katib-ui
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: katib-ui
  namespace: kubeflow
spec:
  gateways:
  - kubeflow-gateway
  hosts:
  - '*'
  http:
  - match:
    - uri:
        prefix: /katib/
    rewrite:
      uri: /katib/
    route:
    - destination:
        host: katib-ui.kubeflow.svc.{{ .Values.clusterDomain }}
        port:
          number: 80
