---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: osd-delete-ownerrefs-bz1906584
  namespace: openshift-logging
spec:
  failedJobsHistoryLimit: 3
  successfulJobsHistoryLimit: 3
  concurrencyPolicy: Replace
  schedule: "7,37 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          affinity:
            nodeAffinity:
              preferredDuringSchedulingIgnoredDuringExecution:
              - preference:
                  matchExpressions:
                  - key: node-role.kubernetes.io/infra
                    operator: Exists
                weight: 1
          tolerations:
            - effect: NoSchedule
              key: node-role.kubernetes.io/infra
              operator: Exists
          serviceAccountName: osd-delete-ownerrefs-bz1906584
          restartPolicy: Never
          containers:
          - name: osd-delete-ownerrefs-bz1906584
            image: image-registry.openshift-image-registry.svc:5000/openshift/cli:latest
            imagePullPolicy: Always
            args:
            - /bin/bash
            - -c
            - |
              for object in clusterrole/elasticsearch-metrics clusterrole/elasticsearch-proxy clusterrolebinding/elasticsearch-metrics clusterrolebinding/elasticsearch-proxy; do
                if [[ $(oc get $object --ignore-not-found -o jsonpath='{.metadata.ownerReferences[0].name}') == "elasticsearch" ]]; then
                  oc patch $object --type=json -p '[{"op":"remove","path":"/metadata/ownerReferences"}]'
                fi
              done
