I spent today some hours trying to overwrite an existing configuration file in a pod/container by a config-files which I defined in a configmap, but I didn't get it... :-(
I already found out there is a bug with the description that the filesystem is mounted read-only which fit to the error I get and I also found a workaround to mount the map on a different location and copy the file to the right place.
My Question is now is there a way to overwrite existing files in the container by a configmap or is the copy-solution the only solution which really works?
best regards
Dan
PS
We are using kubernetes in Version 1.10.4
apiVersion: v1
kind: Pod
spec:
containers:
- name: sq-container
image: docker.io/sonarqube:6.7.1
command: [
"sh",
"-ce",
"cp /mnt/conf/sonar.properties /opt/sonarqube/conf/sonar.properties &&
chown sonarqube:sonarqube /opt/sonarqube/conf/sonar.properties &&
/opt/sonarqube/bin/run.sh"]
volumeMounts:
- name: sq-conf
mountPath: /mnt
volumes:
- name: sq-conf
configMap:
name: sq-configmap
items:
- key: sonar.properties
path: conf/sonar.properties
and I already try this (with the same configuration - just the parts I changed)
...
volumeMounts:
- name: sq-conf
mountPath: /opt/sonarqube/conf
subPath: conf
volumes:
- name: sq-conf
configMap:
name: sq-configmap
items:
- key: sonar.properties
path: sonar.properties
I get an error, the first was
chown: changing ownership of '/opt/sonarqube/conf': Read-only file system
and there was a secound I cannot reproduce at the moment
```
kind: ConfigMap
metadata:
name: sq-configmap
data:
sonar.properties: |
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
wrapper.conf: |
wrapper.java.additional.1=-Dsonar.wrapped=true
wrapper.java.additional.2=-Djava.awt.headless=true
```
and the manifest is like this
```
containers:
- name: sq-container
image: docker.io/sonarqube:6.7.1
volumeMounts:
- name: sq-conf
mountPath: /opt/sonarqube
subPath: conf
volumes:
- name: sq-conf
configMap:
name: sq-configmap
```
but I still get a read-only-filesystem-error. I also try to set subPath to the current-file
```
- name: sq-conf
mountPath: /opt/sonarqube/conf
subPath: sonar.properties
```
but the I get the error. sonar.properties is not a directory-error
I think I am now very close to that what you're doing (suggest). My configmap looks like this at the moment:
```
kind: ConfigMap
metadata:
name: sq-configmap
data:
sonar.properties: |
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
wrapper.conf: |
wrapper.java.additional.1=-Dsonar.wrapped=true
wrapper.java.additional.2=-Djava.awt.headless=true
```
```
containers:
- name: sq-container
image: docker.io/sonarqube:6.7.1
volumeMounts:
- name: sq-conf
mountPath: /opt/sonarqube
subPath: conf
volumes:
- name: sq-conf
configMap:
name: sq-configmap
```
but I still get a read-only-filesystem-error. I also try to set subPath to the current-file
```
- name: sq-conf
mountPath: /opt/sonarqube/conf
subPath: sonar.properties
```
but the I get the error. sonar.properties is not a directory-error
Thanks a lot for your comments and the modifications the files appear in the container... it's a little bit strange but now the run.sh-Skript which starts the service in the container will not be executed, could this be a effect of the mount of the files into the filesystem? because when I mount the file to another place (e.g. /mount) copy it the it works...
--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.
Dan