ConfigMap works great when you need to mount several files inside a container virtually.
Imagine you have a ConfigMap (like the following) with multiple files inside it and you want to extract/patch a single one of them.
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
config.json: |
"server": "0.0.0.0",
"feature": true
hosts: |
127.0.0.1 localhost
10.10.0.1 example.com
app.conf: |
[main]
appName=Awesome App
To extract a single file say config.json
, run the following.
kubectl get cm app-config -o go-template='{{index .data "config.json"}}' > config.json