<p>I have a <strong>ConfigMap</strong> holding a <em>shell script</em> for me:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Chart.Name }}-script
  labels:
    app: {{ .Chart.Name }}
data:
  backup.sh: |
    #!/bin/bash

    rolling_backup() {
      echo &quot;Found at least 3 backups. Starting rolling backup.&quot;
    ...
      rolling_backup
    fi
</code></pre>
<p>Then i'm trying to mount it to a <strong>CronJob</strong> that executes this script:</p>
<pre><code>      ...
      containers:
      - name: {{ .Chart.Name }}-cronjob
        image: busybox
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        command: ['sh', '-c', 'ls -la /etc/scripts/ &amp;&amp; /etc/scripts/backup.sh inp-mongo-main-volume']
        volumeMounts:
        - name: {{ .Chart.Name }}-script
          mountPath: &quot;/etc/scripts/&quot;
      volumes:
      - name: {{ .Chart.Name }}-script
        configMap:
          name: {{ .Chart.Name }}-script
          defaultMode: 0777
      ...
</code></pre>
<p>Whenever I try to run this job all I get is <strong>'not found'</strong>, when <em>ls</em> command before script execution shows something completely different that the script is actually there.</p>
<pre><code>user@computer scripts % kubectl logs -n &lt;namespace&gt; mongo-cron-46svm 
total 12
drwxr-xr-x    2 root     root          4096 Aug  5 10:31 .
drwxr-xr-x    1 root     root          4096 Aug  5 10:31 ..
-rwxrwxrwx    1 root     root          1377 Aug  5 10:31 backup.sh
/bin/sh: /etc/scripts/backup.sh: not found
</code></pre>
<p>What could be the issue here?</p>

Przemek Wit
<p>The Docker Hub <code>busybox</code> image is an extremely minimal image containing only <a href="https://busybox.net" rel="nofollow noreferrer">BusyBox</a>, a single-static-binary application that contains a minimum set of standard Unix tools.  It contains an implementation of the Bourne shell <code>/bin/sh</code> that conforms to <a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18" rel="nofollow noreferrer">the POSIX specification</a>, but it does not contain GNU bash.</p>
<p>In practice, you should be able to rewrite most shell scripts to conform to POSIX syntax.  (Use <code>.</code> instead of <code>source</code>; don't begin shell function declarations with <code>function</code>; you may need to use external tools instead of complex pattern expansions.)  The shell fragment you show should probably be okay.  You just need to change the first line to</p>
<pre class="lang-sh prettyprint-override"><code>#!/bin/sh
</code></pre>
<p>(Since this is <em>code</em> and not configuration, also consider putting it into a custom Docker image; your CI system would need to publish it to some image registry to be able to run it, but then it would follow the same lifecycle as all other custom code that runs in your cluster.)</p>
