kind: ServiceAccount
apiVersion: v1
metadata:
  name: prow-controller-manager-kicker
  namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: prow-controller-manager-kicker
  namespace: default
rules:
  - apiGroups: ["apps", "extensions"]
    resources: ["deployments"]
    resourceNames: ["prow-controller-manager"]
    verbs: ["get", "patch", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: prow-controller-manager-kicker
  namespace: default
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: prow-controller-manager-kicker
subjects:
  - kind: ServiceAccount
    name: prow-controller-manager-kicker
---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: prow-controller-manager-kicker
  namespace: default
spec:
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 2
  concurrencyPolicy: Forbid
  schedule: "0 7 * * *" # Run at 07:00(UTC) every day.
  jobTemplate:
    spec:
      backoffLimit: 1
      activeDeadlineSeconds: 300
      template:
        spec:
          serviceAccountName: prow-controller-manager-kicker
          restartPolicy: Never
          containers:
            - name: kubectl
              image: gcr.io/k8s-staging-test-infra/gcloud-in-go:v20230111-cd1b3caf9c
              command:
                - "kubectl"
                - "-n"
                - "default"
                - "rollout"
                - "restart"
                - "deployment/prow-controller-manager"
