Skip to content
Snippets Groups Projects
job-setup-apps.yaml 1.51 KiB
Newer Older
apiVersion: batch/v1
kind: Job
metadata:
  name: "{{ .Release.Name }}-setup-apps"
  labels:
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  annotations:
    "helm.sh/hook": post-install,post-upgrade
    "helm.sh/hook-weight": "0"
spec:
  template:
    metadata:
      labels:
        app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
        app.kubernetes.io/instance: {{.Release.Name | quote }}
        helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    spec:
      restartPolicy: Never
      serviceAccountName: {{ .Release.Name }}-setup-apps-job
      containers:
      - name: setup-apps-job
        image: docker.io/bitnami/kubectl:1.28
        command:
        - /bin/bash
        - -c
        - >
          pod=$(kubectl get pod -n {{ .Release.Namespace }} -l app.kubernetes.io/name=nextcloud --no-headers -o custom-columns=":metadata.name" | head -n 1)
          && cp -L /scripts/setup-apps.sh /tmp/setup-apps.sh
          && kubectl cp
          -n {{ .Release.Namespace }}
          /tmp/setup-apps.sh
          $pod:/tmp/setup-apps.sh
          && kubectl exec
          -n {{ .Release.Namespace }}
          deploy/{{ .Release.Name }}-nextcloud
          -- /bin/bash /tmp/setup-apps.sh
        volumeMounts:
        - mountPath: /scripts
          name: setup-apps
      volumes:
      - name: setup-apps
        configMap:
          name: "{{ .Release.Name }}-setup-apps"