_job.tpl 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. {{/* Job Class */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.class.job" (dict "rootCtx" $ "objectData" $objectData) }}
  4. rootCtx: The root context of the chart.
  5. objectData: The object data to be used to render the Job.
  6. */}}
  7. {{- define "ix.v1.common.class.job" -}}
  8. {{- $rootCtx := .rootCtx -}}
  9. {{- $objectData := .objectData -}}
  10. {{- include "ix.v1.common.lib.workload.jobValidation" (dict "objectData" $objectData) }}
  11. ---
  12. apiVersion: batch/v1
  13. kind: Job
  14. metadata:
  15. name: {{ $objectData.name }}
  16. {{- $labels := (mustMerge ($objectData.labels | default dict) (include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
  17. {{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
  18. labels:
  19. {{- . | nindent 4 }}
  20. {{- end -}}
  21. {{- $annotations := (mustMerge ($objectData.annotations | default dict) (include "ix.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -}}
  22. {{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
  23. annotations:
  24. {{- . | nindent 4 }}
  25. {{- end }}
  26. spec:
  27. {{- include "ix.v1.common.lib.workload.jobSpec" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 2 }}
  28. template:
  29. metadata:
  30. {{- $labels := (mustMerge ($objectData.podSpec.labels | default dict)
  31. (include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)
  32. (include "ix.v1.common.lib.metadata.podLabels" $rootCtx | fromYaml)
  33. (include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}}
  34. {{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
  35. labels:
  36. {{- . | nindent 8 }}
  37. {{- end -}}
  38. {{- $annotations := (mustMerge ($objectData.podSpec.annotations | default dict)
  39. (include "ix.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)
  40. (include "ix.v1.common.lib.metadata.externalInterfacePodAnnotations" (dict "rootCtx" $rootCtx "objectData" $objectData) | fromYaml)
  41. (include "ix.v1.common.lib.metadata.podAnnotations" $rootCtx | fromYaml)) -}}
  42. {{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "annotations" $annotations) | trim) }}
  43. annotations:
  44. {{- . | nindent 8 }}
  45. {{- end }}
  46. spec:
  47. {{- include "ix.v1.common.lib.workload.pod" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 6 }}
  48. {{- end -}}