<p>I'm trying to deploy in Kubernetes several pods using a mongo image with a initialization script in them. I'm using helm for the deployment. Since I'm beginning with the official Mongo docker image, I'm trying to add a script at /docker-entrypoint-initdb.d so it will be executed right at the beginning to initialize some parameters of my Mongo.</p>

<p>What I don't know is how can I insert my script, that is, let's say, in my local machine, in /docker-entrypoint-initdb.d using helm.</p>

<p>I'm trying to do something like docker run -v hostfile:mongofile but I need the equivalent in helm, so this will be done in all the pods of the deployment</p>

Carabes
<p>You can use configmap. Lets put nginx configuration file to container via configmap. We have directory name called nginx with same level values.yml. Inside there we have actual configuration file. </p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config-file
  labels:
    app: ...    
data:
  nginx.conf: |-
{{ .Files.Get "nginx/nginx.conf" | indent 4 }}

---

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: SomeDeployment
  ...  
spec:
  replicas: 
  selector:
    matchLabels:
      app: ...
      release: ...
  template:
    metadata:
      labels:
        app: ...
        release: ...
    spec:
      volumes:
        - name: nginx-conf
          configMap:
            name: nginx-config-file
            items:
            - key: nginx.conf
              path: nginx.conf
      containers:        
        - name: ...
          image: ...          
          volumeMounts:
            - name: nginx-conf
              mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf
</code></pre>

<p>You can also check initContainers concept from this link :
<a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/init-containers/</a></p>
