<p>I am new to Kubernetes, but I have been using Docker and Docker Compose for a long time.  I am trying to find more information about how Kubernetes handles shared/read only config files compared to Docker Compose.</p>
<p>In my <code>docker-compose.yaml</code> file I am sharing specific config files to my containers using bind mounts, similar to this:</p>
<pre><code>  ...
  elasticsearch:
    image: elasticsearch:7.3.2
    environment:
      - discovery.type=single-node
    networks: 
      mycoolapp:
        aliases: 
          - elasticsearch
    ports:
      - &quot;9200:9200&quot;
      - &quot;9300:9300&quot;
    volumes:
      - elasticdata:/usr/share/elasticsearch/data
      - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
   ...
</code></pre>
<p>I have been reading up on Persistent Volumes and I believe this is what I need, however, my understanding still isn't 100% clear on a few issues.</p>
<ol>
<li>I'm using <code>azureFile</code> for my volume type, and I have copied my configs into the file share.  How do I mount a sub folder of the file share into my container?  <code>mountPath</code> only appears in <code>volumeMounts</code>, and I can't find where the corresponding location within the volume are.</li>
<li>How do I share just a single file?</li>
<li>How do I make the single file that I shared above read only?</li>
</ol>

joe_coolish
<p>Kubernetes ConfigMap object will come handy here.</p>
<blockquote>
<p>A ConfigMap is an API object used to store non-confidential data in key-value pairs.</p>
</blockquote>
<p>Example:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: elastic-demo
data:
  # property-like keys; each key maps to a simple value; available as env var
  properties_file_name: &quot;database.properties&quot;

  # file-like keys
  database.properties: |
    data1=value1
    data2=value2      
</code></pre>
<p>You can mount the above ConfigMap in volume in read only mode.</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: mypod
    image: elasticsearch
    volumeMounts:
    - name: elastic-volume
      mountPath: &quot;/etc/foo&quot;
      readOnly: true
  volumes:
  - name: elastic-volume
    configMap:
      name: elastic-demo
</code></pre>
