添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Extract/Patch a File inside a ConfigMap

Extract/Patch a File inside a ConfigMap

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