The aim behind this question is to know how having a file inside a Pod, if we use ConfigMap, I don't want to apply changes if the configMap will change
Thanks
I am not really understanding, why don't you want to use a volume?
A proper way, to mount a confgimap to a pod looks like this:
Configmap- specify name of the file in a data
section:
apiVersion: v1
kind: ConfigMap
metadata:
creationTimestamp: 2016-02-18T18:52:05Z
name: txt-file-configmap
namespace: default
resourceVersion: "516"
selfLink: /api/v1/namespaces/default/configmaps/game-config
uid: b4952dc3-d670-11e5-8cd0-68f728db1985
data:
file.txt: |
here
are
filecontents
And in a pod, specify a volume with a configmap name and volumeMount, pointing a path, where to mount the volume:
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "/bin/sh", "-c", "cat /etc/txtfiles/file.txt" ]
volumeMounts:
- name: txt-file
mountPath: /etc/txtfiles
volumes:
- name: txt-file
configMap:
name: txt-file-configmap
The example pod which I provided you, will have the configmap mounted as a file and will print it's contents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With