<p>In a kubernetes (minikube) / helm env I have an ldif file I want to share on a volume between an Init container and a normal one. I don't want to share the entire folder in which this file is stored.</p>

<p>Unfortunately from my understanding this is not possible unless the file is a properties one (syntax "key=value").</p>

<p>I tested using configMap/subPath and it seems like that if key/value syntax is not respected the Init container is not even starting, otherwise everything works and the file appears on the main container as well.</p>

<p>So I wonder if it is even possibile to accomplish this kind of sharing.</p>

<p>BR</p>

<p>edit: main container startup command is a single service start, it cannot execute copies or move the file shared by init container, unless it is the only way.</p>

user83647511
<p>Yes, it is possible, and you are on the right track. </p>

<p>Here's an example of how to do this.</p>

<pre><code>---
kind: ConfigMap 
apiVersion: v1 
metadata:
  name: example-configmap 
data:
  my-file.ldif: |
     dn: cn=The Postmaster,dc=example,dc=com
     objectClass: organizationalRole
     cn: The Postmastermongodb
---
kind: Pod
apiVersion: v1
metadata:
  name: example-pod
spec:
  volumes: 
  - name: config-volume
    configMap:
      name: example-configmap
  initContainers:
  - name: init
    image: busybox
    volumeMounts:
    - name: config-volume
      mountPath: /path/in/the/init-container/my-file.ldif
      subPath: my-file.ldif
  containers:
  - name: main
    image: busybox
    volumeMounts:
    - name: config-volume
      mountPath: /path/in/the/container/my-file.ldif
      subPath: my-file.ldif
</code></pre>

<p>It would help if you posted your configmap. You might be getting tripped up because for this to work you need the whole contents of your file as the value of one key in your configmap. </p>
