<p>I have a <code>data-config.json</code> that is used by my ASP.NET Core application.</p>
<p>The app was built to a image and the goal is to create a Kubernetes environment (using Minikube and a myapp.yaml to create and deploy the Minikube and the pods) and copy the <code>data-config.json</code> from a specific place in my local machine to a directory in the Node (the place I want to be <code>~/app/publish/data-config.json</code>, in other words, in the root directory of the node).</p>
<p>I read a lot the documentation and I think ConfigMap can be useful in this case. I already implemented a Volume too. But I don't think write the json content inside the ConfigMap configuration is the best way to do that, I want to depend only of the <code>data-config.json</code> file and the YAML.</p>
<p>In the <code>docker-compose.yml</code> file, to test in Docker Desktop, it works and the code is showed above:</p>
<pre><code>    dataService:
        image: webapp
        build:
          context: ../..
          dockerfile: webapp
        container_name: webapp-container
        ports:
            - &quot;9000:8080&quot;
        volumes:
            - &quot;../data-service/data-config.json:/app/publish/data-config.json&quot;
</code></pre>
<p>And it worked. Now I need to translate or find a way to copy this file and save it in the <code>/app/publish/</code> directory of my node.</p>

Hugo Mata
<p>I solved this question by creating a ConfigMap that maps the <code>data-config.json</code> from my local machine directory to the container pod. The example shows the implementation of the YAML file used by Minikube to create and start the cluster:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: data-deployment
  labels:
    app: data-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: data-app
  template:
    metadata:
      labels:
        app: data-app
    spec:
      imagePullSecrets:
      - name: regcred
      containers:
      - name: data-app
        image: validation-image:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
        env:
        - name: DataSettings_ConfigPath
          value: /app/publish/data-config.json
        volumeMounts:
        - name: data-config-dir
          mountPath: /app/publish/data-config.json
          subPath: data-config.json
      restartPolicy: Always
      hostname: data-service
      volumes: 
      - name: data-config-dir
        configMap:
           name: data-configmap
           items:
             - key: data-config.json
               path: data-config.json
</code></pre>
<p>PS: you must run the command below in terminal to create the ConfigMap for data-config.json file:</p>
<pre class="lang-sh prettyprint-override"><code>$ kubectl create configmap data-configmap --from-file ../data-service/data-config.json
</code></pre>
