apiVersion: v1
kind: Pod
metadata:
  name: posthook
  namespace: elastic
  annotations:
    "helm.sh/hook": "post-install"
    "helm.sh/hook-weight": "-5"
#    "helm.sh/hook-delete-policy": hook-succeeded
spec:
  serviceAccountName: elastic
  containers:
  - name: hooktainer
    image: bitnami/kubectl
    imagePullPolicy: IfNotPresent
    command: ['sh', '-c', '--']
    args:
    - |
        wait 10;
        cat <<EOF | kubectl apply -f -
        apiVersion: elasticsearch.k8s.elastic.co/v1
        kind: Elasticsearch
        metadata:
          name: elasticsearch
        spec:
          version: 7.5.2
          nodeSets:
            - name: default
              count: 2
              config:
                node.master: true
                node.data: true
                node.ingest: true
                node.store.allow_mmap: false
              volumeClaimTemplates:
              - metadata:
                  name: elasticsearch-data
                spec:
                  accessModes:
                  - ReadWriteOnce
                  resources:
                    requests:
                      storage: 100Gi
        EOF
  restartPolicy: Never
  terminationGracePeriodSeconds: 0
