apiVersion: batch/v1
kind: Job
metadata:
  name: tigera-operator-uninstall
  namespace: {{.Release.Namespace}}
  labels:
    k8s-app: tigera-operator-uninstall
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  annotations:
    # Mark this Job as a pre-deletion hook. This will only be executed as part
    # of helm uninstall, in order to ensure the Installation is cleaned up prior to
    # tearing down the operator.
    helm.sh/hook: pre-delete
    helm.sh/hook-weight: "-5"
    helm.sh/hook-delete-policy: hook-succeeded
spec:
  template:
    metadata:
      name: "{{ .Release.Name }}"
      labels:
        helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    spec:
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      restartPolicy: Never
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      serviceAccountName: tigera-operator
      containers:
      - name: cleanup-job
        image: {{ template "tigera-operator.image" .Values.tigeraOperator}}
        args: ["-pre-delete"]
