<p>I'm using a Helm chart to deploy an app in the Kubernetes. After deployment, I want to copy a file from the chart repository to the container. </p>

<p>Currently I am doing this manually:</p>

<pre><code>kubectl cp custom-samples.json che-8467596d54-7c2hg:/data/templates
</code></pre>

<p>But I want to make this step a part of the deployment that will be performed automatically. Note that I took a look at <code>post-install</code> hooks but I'm not sure it's a good solution.</p>

<p>[UPD] I created this init container:</p>

<pre><code> - name: add-custom-samples
        image: alpine:3.5
        command: ["sh", "-c", "cd /data/templates; touch custom.json;"]
        volumeMounts: [{
              "mountPath": "/data",
              "name": "che-data-volume"
        }]
</code></pre>

<p>But the file <code>custom.json</code> is missing in the mounted volume.</p>

<p><code>kubectl cp</code> (in the form you're using it) takes a file from the host on which it runs. If you are always initiating deployment from that same host, you could (in theory) arrange for the file to be copied - either by having <code>kubectl cp ...</code> in a script that you use to control the deployment or by setting up a watch and performing the copy every time a new container appears in the deployment that needs it.</p>

<p>However, it is probably better to have the pods <strong>get</strong> that file by themselves (e.g., over http or from github) as part of their startup. If you have control of the container's startup (e.g., you own its code or you can specify the command that it runs), you can do that easily. You could also define an init container that runs before the container that does the real work and have it pull the file into a volume that's shared with the main container.</p>
