Error config Map volume mount read-only file system error

0 votes

I have a configmap for 3 files that are going to be mounted in  "fluentd/etc/" and the respective files are fluent.conf, Kubernetes.conf, systemd.conf, configmap in deployment.yaml is like this:

volumeMounts:
name: fluentd
mountPath: /fluentd/etc/
name: varlog
mountPath: /var/log
name: container1
mountPath: /var/lib/docker/containers
readOnly: true
securityContext:
privileged: true
terminationGracePeriodSeconds: 30
volumes:
name: varlog
hostPath:
path: /var/log
name: container1
hostPath:
path: /var/lib/docker/containers
name: fluentd
configMap:
name: fluentd-config

During deployment I am getting an error of mount as read-only, which is effecting fluent to read some of the mentioned sources in the configmap. How can I avoid this read-only error?

Jul 18, 2019 in Kubernetes by Karan
• 19,610 points
20,730 views

1 answer to this question.

+1 vote

ConfigMaps are always mounted read-only.

If you need to modify a configmap in a pod, you should copy it from the configmap mount to a regular file in the pod and then modify it. 

To solve this issue :

  • you should use an init container to mount the configmap

  • copy the configmap into an `emptyDir` volume and

  • share the volume with the main container.

  • configmaps are mounted read-only so that you can't touch the files. 

  • when the master configmap changes the mounted file also changes. so if you were to modify the local mounted file, it would be overwritten anyways.

answered Jul 18, 2019 by Sirajul
• 59,230 points

Related Questions In Kubernetes

0 votes
1 answer

Set volume mount user group and file permissions in kubernetes

There's a setting in Pod Security Context ...READ MORE

answered Jan 16, 2019 in Kubernetes by ajs3033
• 7,300 points
27,832 views
0 votes
1 answer

config-map kubernetes multiple environments

Deploy your application as helm chart.  After having ...READ MORE

answered Aug 31, 2018 in Kubernetes by Kalgi
• 52,360 points
2,004 views
0 votes
1 answer

ConfigMaps volume not creating file in container

Did a little research and found the ...READ MORE

answered Sep 6, 2018 in Kubernetes by Atul
• 10,240 points
1,114 views
0 votes
1 answer
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,301 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 6,926 views
+1 vote
1 answer

Can pods mount NFS volume?

Yes, there's an example here of both ...READ MORE

answered Jul 15, 2019 in Kubernetes by Sirajul
• 59,230 points
3,349 views
0 votes
1 answer

What is the difference between config map and secret in kubernetes?

Config maps ideally stores application configuration in ...READ MORE

answered Jul 17, 2019 in Kubernetes by Sirajul
• 59,230 points
3,672 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP