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
• 9,500 points
2,491 views

1 answer to this question.

0 votes

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
• 50,440 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,280 points
5,482 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
• 51,830 points
444 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,250 points
133 views
0 votes
1 answer
0 votes
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
5,603 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 11, 2019 in Kubernetes by Kalgi
• 51,830 points

reshown Apr 12, 2019 by Kalgi 1,527 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
• 50,440 points
901 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
• 50,440 points
419 views