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 in Kubernetes by Karan
• 3,630 points
249 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 by Sirajul
• 30,540 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 in Kubernetes by ajs3033
• 7,280 points
2,287 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
• 41,620 points
256 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
59 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 in Others by anonymous
2,584 views
+3 votes
1 answer
0 votes
1 answer

Can pods mount NFS volume?

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

answered Jul 15 in Kubernetes by Sirajul
• 30,540 points
152 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 in Kubernetes by Sirajul
• 30,540 points
95 views