Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
Moving from Docker Compose to Kubernetes, storing configuration on persistent volumes

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.

In my docker-compose.yaml file I am sharing specific config files to my containers using bind mounts, similar to this:

  ...
  elasticsearch:
    image: elasticsearch:7.3.2
    environment:
      - discovery.type=single-node
    networks: 
      mycoolapp:
        aliases: 
          - elasticsearch
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      - elasticdata:/usr/share/elasticsearch/data
      - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
   ...

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.

  1. I'm using azureFile 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? mountPath only appears in volumeMounts, and I can't find where the corresponding location within the volume are.
  2. How do I share just a single file?
  3. How do I make the single file that I shared above read only?
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Kubernetes ConfigMap object will come handy here.

A ConfigMap is an API object used to store non-confidential data in key-value pairs.

Example:

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: "database.properties"

  # file-like keys
  database.properties: |
    data1=value1
    data2=value2      

You can mount the above ConfigMap in volume in read only mode.

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: mypod
    image: elasticsearch
    volumeMounts:
    - name: elastic-volume
      mountPath: "/etc/foo"
      readOnly: true
  volumes:
  - name: elastic-volume
    configMap:
      name: elastic-demo
over 4 years ago · Santiago Trujillo Report

0

As @Pulak said it correctly you can use configmap. I saw you want to import a folder containing 100s of files into a configmap. What I think is, you can do this in another way. That is using zip/jar file as ConfigMap support binary file, so after mounting it can be unzipped into your desired path inside the container.

For example you have below structure in the folder:

.
├── test1.html
├── test2.css
├── test3.xml
└── testN.html

Now you can make them jar/zip and can create a configmap by kubectl create configmap example --from-file=./

Another thing is configmap size (in terms of MiB) should not be large. So, if you really have lot of things than can use kubernetes typical volumes.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!