apiVersion: v1
kind: ServiceAccount
metadata:
  name: metrics-collector
  namespace: kubeflow
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: metrics-collector
rules:
- apiGroups:
  - ""
  resources:
  - pods
  - pods/log
  - pods/status
  verbs:
  - '*'
- apiGroups:
  - batch
  resources:
  - jobs
  verbs:
  - '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: metrics-collector
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: metrics-collector
subjects:
- kind: ServiceAccount
  name: metrics-collector
  namespace: kubeflow
---
apiVersion: v1
data:
  defaultMetricsCollectorTemplate.yaml: |-
    apiVersion: batch/v1beta1
    kind: CronJob
    metadata:
      name: {{`{{.Trial}}`}}
      namespace: {{`{{.NameSpace}}`}}
    spec:
      schedule: "*/1 * * * *"
      successfulJobsHistoryLimit: 0
      failedJobsHistoryLimit: 1
      jobTemplate:
        spec:
          backoffLimit: 0
          template:
            spec:
              serviceAccountName: metrics-collector
              containers:
              - name: {{`{{.Trial}}`}}
                image: gcr.io/kubeflow-images-public/katib/v1alpha2/metrics-collector:v0.1.2-alpha-289-g14dad8b
                imagePullPolicy: IfNotPresent
                command: ["./metricscollector"]
                args:
                - "-e"
                - "{{`{{.Experiment}}`}}"
                - "-t"
                - "{{`{{.Trial}}`}}"
                - "-k"
                - "{{`{{.JobKind}}`}}"
                - "-n"
                - "{{`{{.NameSpace}}`}}"
                - "-m"
                - "{{`{{.ManagerService}}`}}"
                - "-mn"
                - "{{`{{.MetricNames}}`}}"
              restartPolicy: Never
kind: ConfigMap
metadata:
  name: metrics-collector-template
  namespace: kubeflow
