apiVersion: batch/v1
kind: Job
metadata:
  annotations:
    helm.sh/hook: post-install
  labels:
    app: {{ template "name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "fullname" . }}-get-crd
spec:
  template:
    metadata:
      labels:
        app: {{ template "name" . }}
        release: {{ .Release.Name }}
      name: {{ template "fullname" . }}-get-crd
    spec:
      containers:
        - name: hyperkube
          image: "{{ .Values.global.hyperkube.repository }}:{{ .Values.global.hyperkube.tag }}"
          imagePullPolicy: "{{ .Values.global.hyperkube.pullPolicy }}"
          command:
            - ./kubectl
            - get
            - customresourcedefinitions
            - alertmanagers.monitoring.coreos.com
            - prometheuses.monitoring.coreos.com
            - servicemonitors.monitoring.coreos.com
      restartPolicy: OnFailure
    {{- if .Values.rbacEnable }}
      serviceAccountName: {{ template "fullname" . }}
    {{- end }}
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}

apiVersion: batch/v1
kind: Job
metadata:
  annotations:
    helm.sh/hook: post-install
    "helm.sh/hook-delete-policy": hook-succeeded
  labels:
    app: {{ template "name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "fullname" . }}-get-crd
spec:
  template:
    metadata:
      labels:
        app: {{ template "name" . }}
        release: {{ .Release.Name }}
      name: {{ template "fullname" . }}-get-crd
    spec:
      containers:
        - name: hyperkube
          image: "{{ .Values.global.hyperkube.repository }}:{{ .Values.global.hyperkube.tag }}"
          imagePullPolicy: "{{ .Values.global.hyperkube.pullPolicy }}"
          command:
            - ./kubectl
            - get
            - customresourcedefinitions
            - alertmanagers.monitoring.coreos.com
            - prometheuses.monitoring.coreos.com
            - servicemonitors.monitoring.coreos.com
      restartPolicy: OnFailure
    {{- if .Values.rbacEnable }}
      serviceAccountName: {{ template "fullname" . }}
    {{- end }}
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}

Make Helm to delete TPR job on success
Make Helm to delete TPR job on success
