apiVersion: batch/v1
kind: Job
metadata:
  annotations:
   "helm.sh/hook": post-install
  name: healthcheck-elasticsearch-operator
spec:
  selector: {}
  template:
    metadata:
      name: healthcheck-elasticsearch-operator
    spec:
     restartPolicy: Never
     serviceAccountName: elasticsearch-healthcheck
     containers:
      - name: 'healthcheck'
        image: 'quay.io/openshift/origin-cli:latest'
        command: ["sh"]
        args:
        - '-c'
        - 'while [[ (`oc get csv --all-namespaces | grep elasticsearch-operator | grep Succeeded` = "") ]]; do echo "Elasticsearch operator still pending, sleeping for 5 sec"; sleep 5; done && oc get csv --all-namespaces | grep elasticsearch-operator'
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: elasticsearch-healthcheck
subjects:
- kind: ServiceAccount
  name: elasticsearch-healthcheck
  namespace: openshift-operators-redhat
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: elasticsearch-healthcheck