apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: experiments.kubeflow.org
spec:
  additionalPrinterColumns:
  - JSONPath: .status.conditions[-1:].type
    name: Status
    type: string
  - JSONPath: .metadata.creationTimestamp
    name: Age
    type: date
  group: kubeflow.org
  names:
    categories:
    - all
    - kubeflow
    - katib
    kind: Experiment
    plural: experiments
    singular: experiment
  scope: Namespaced
  subresources:
    status: {}
  version: v1alpha2
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: trials.kubeflow.org
spec:
  additionalPrinterColumns:
  - JSONPath: .status.conditions[-1:].type
    name: Status
    type: string
  - JSONPath: .metadata.creationTimestamp
    name: Age
    type: date
  group: kubeflow.org
  names:
    categories:
    - all
    - kubeflow
    - katib
    kind: Trial
    plural: trials
    singular: trial
  scope: Namespaced
  subresources:
    status: {}
  version: v1alpha2
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: katib-controller
  namespace: kubeflow
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: katib-controller
rules:
- apiGroups:
  - ""
  resources:
  - configmaps
  - serviceaccounts
  - services
  - secrets
  verbs:
  - '*'
- apiGroups:
  - ""
  resources:
  - pods
  - pods/log
  - pods/status
  verbs:
  - '*'
- apiGroups:
  - batch
  resources:
  - jobs
  - cronjobs
  verbs:
  - '*'
- apiGroups:
  - apiextensions.k8s.io
  resources:
  - customresourcedefinitions
  verbs:
  - create
  - get
- apiGroups:
  - admissionregistration.k8s.io
  resources:
  - validatingwebhookconfigurations
  - mutatingwebhookconfigurations
  verbs:
  - '*'
- apiGroups:
  - kubeflow.org
  resources:
  - experiments
  - experiments/status
  - trials
  - trials/status
  verbs:
  - '*'
- apiGroups:
  - kubeflow.org
  resources:
  - tfjobs
  - pytorchjobs
  verbs:
  - '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: katib-controller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: katib-controller
subjects:
- kind: ServiceAccount
  name: katib-controller
  namespace: kubeflow
---
apiVersion: v1
data:
  defaultTrialTemplate.yaml: |-
    apiVersion: batch/v1
    kind: Job
    metadata:
      name: {{`{{.Trial}}`}}
      namespace: {{`{{.NameSpace}}`}}
    spec:
      template:
        spec:
          containers:
          - name: {{`{{.Trial}}`}}
            image: alpine
          restartPolicy: Never
kind: ConfigMap
metadata:
  name: trial-template
  namespace: kubeflow
---
apiVersion: v1
kind: Secret
metadata:
  name: katib-controller
  namespace: kubeflow
---
apiVersion: v1
kind: Service
metadata:
  name: katib-controller
  namespace: kubeflow
spec:
  ports:
  - port: 443
    protocol: TCP
    targetPort: 443
  selector:
    app: katib-controller
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: katib-controller
  name: katib-controller
  namespace: kubeflow
spec:
  replicas: 1
  selector:
    matchLabels:
      app: katib-controller
  template:
    metadata:
      labels:
        app: katib-controller
    spec:
      containers:
      - command:
        - ./katib-controller
        env:
        - name: KATIB_CORE_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        image: gcr.io/kubeflow-images-public/katib/v1alpha2/katib-controller:v0.6.0-rc.0
        imagePullPolicy: IfNotPresent
        name: katib-controller
        ports:
        - containerPort: 443
          name: webhook
          protocol: TCP
        volumeMounts:
        - mountPath: /tmp/cert
          name: cert
          readOnly: true
      serviceAccountName: katib-controller
      volumes:
      - name: cert
        secret:
          defaultMode: 420
          secretName: katib-controller
