<p>I am new to helm and I have tried to deploy a few tutorial charts. Had a couple of queries:</p>
<ol>
<li><p>I have a Kubernetes job which I need to deploy. Is it possible to deploy a job via helm?</p>
</li>
<li><p>Also, currently my kubernetes job is deployed from my custom docker image and it runs a bash script to complete the job. I wanted to pass a few parameters to this chart/job so that the bash commands takes the input parameters. That's the reason I decided to move to helm because it provided a more flexibility. Is that possible?</p>
</li>
</ol>

<p>You can use helm. Helm installs all the kubernetes resources like job,pods,configmaps,secrets inside the templates folder. You can control the order of installation by helm hooks. Helm offers hooks like pre-install, post-install, pre-delete with respect to deployment. if two or more jobs are pre-install then their weights will be compared for installing.</p>

<pre><code>|-scripts/runjob.sh
|-templates/post-install.yaml
|-Chart.yaml
|-values.yaml
</code></pre>

<p>Many times you need to change the variables in the script as per the environment. so instead of hardcoding variable in script, you can also pass parameters to script by setting them as environment variables to your custom docker image. Change the values in values.yaml instead of changing in your script.</p>

<p>values.yaml</p>

<pre><code>key1:
  someKey1: value1
key2:
  someKey2: value1
</code></pre>

<p>post-install.yaml</p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: post-install-job
  labels:
    provider: stackoverflow
    microservice: {{ template "name" . }}
    release: "{{ .Release.Name }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  annotations:
    "helm.sh/hook": pre-install,pre-upgrade,pre-rollback
    "helm.sh/hook-delete-policy": before-hook-creation
    "helm.sh/hook-weight": "3"
spec:
  template:
    metadata:
      name: "{{.Release.Name}}"
      labels:
        provider: stackoverflow
        microservice: {{ template "name" . }}
        release: "{{ .Release.Name }}"
        app: {{ template "fullname" . }}
    spec:
      restartPolicy: Never
      containers:
        - name: post-install-job
          image: "custom-docker-image:v1"
          command: ["/bin/sh", "-c", {{ .Files.Get "scripts/runjob.sh" | quote }} ]
          env:
          #setting KEY1 as environment variable in the container,value of KEY1 in container is value1(read from values.yaml)
          - name: KEY1
            value: {{ .Values.key1.someKey1 }}
          - name: KEY2
            value: {{ .Values.key2.someKey2 }}
</code></pre>

<p>runjob.sh</p>

<pre><code># you can access the variable from env variable
echo $KEY1
echo $KEY2
# some stuff
</code></pre>
