title: Helm Override common template values
body: <p>First day helm user here. Trying to understand how to build common templates for k8s resources.
  Let's say I have 10 cron jobs within single chart, all of them different by args and names only. Today 10 full job manifests exists and 95% of manifest content is equal. I want to move common part in template and create 10 manifests where I will provide specific values for args and names.</p>
  
  <p>So I defined template _cron-job.yaml</p>
  
  <pre><code>    {{- define "common.cron-job"}}
  apiVersion: batch/v1beta1
  kind: CronJob
  metadata:
    name: {{ include "costing-report.name" . }}-bom-{{ .Values.env }}
    labels:
  {{ include "costing-report.labels" . | indent 4 }}
  spec:
    schedule: "{{ .Values.cronjob.scheduleBom }}"
    suspend: {{ .Values.cronjob.suspendBom }}
    {{- with .Values.cronjob.concurrencyPolicy }}
    concurrencyPolicy: {{ . }}
    {{- end }}
    {{- with .Values.cronjob.failedJobsHistoryLimit }}
    failedJobsHistoryLimit: {{ . }}
    {{- end }}
    {{- with .Values.cronjob.successfulJobsHistoryLimit }}
    successfulJobsHistoryLimit: {{ . }}
    {{- end }}
    jobTemplate:
      metadata:
        labels:
          app.kubernetes.io/name: {{ include "costing-report.name" . }}
          app.kubernetes.io/instance: {{ .Release.Name }}
      spec:
        template:
          spec:
            containers:
              - name: {{ .Chart.Name }}
                image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
                imagePullPolicy: {{ .Values.image.pullPolicy }}
                args: ["--report=Bom","--email={{ .Values.configmap.service.email_bom }}"]
                env:
                  - name: spring_profiles_active
                    value: "{{ .Values.env }}"
                envFrom:
                  - configMapRef:
                      name: {{ include "costing-report.fullname" . }}
                  - secretRef:
                      name: {{ .Values.secrets.properties }}
            restartPolicy: Never
            {{- with .Values.imagePullSecrets }}
            imagePullSecrets:
              {{- toYaml . | nindent 8 }}
            {{- end }}    
  {{- end -}}
  </code></pre>
  
  <p>and now I need to create job manifest that override name and args job1.yaml</p>
  
  <pre><code>{{- template "common.cron-job" . -}}
  ??? override ???
  name: {{ include "cost-report.name" . }}-job1-{{ .Values.env }}
  jobTemplate:
  spec:
    template:
      spec:
        containers:
          args: ["--report=Bom","--email={{ .Values.configmap.service.email_bom }}"]
  </code></pre>
  
  <p>Is there any way to do this? I didn't find this in helm docs. I did find this <a href="https://github.com/helm/charts/tree/master/incubator/common" rel="nofollow noreferrer">https://github.com/helm/charts/tree/master/incubator/common</a> but It didn't work as well and gave me error.</p>
  
  <p>Thanks.</p>