How to patch configmap in json file with kustomize?

11/12/2019

How to patch "db.password" in the following cm with kustomize?

comfigmap:

apiVersion: v1
data:
  dbp.conf: |-
    {
      "db_properties": {
        "db.driver": "com.mysql.jdbc.Driver",
        "db.password": "123456",
        "db.user": "root"
      }
    }

kind: ConfigMap
metadata:
  labels: {}
  name: dbcm
-- Lior
configmap
kubernetes
kustomize

1 Answer

11/12/2019

you can create new file with updated values and use command replace along wih create

kubectl create configmap NAME --from-file file.name -o yaml --dry-run | kubectl replace -f -
-- Harsh Manvar
Source: StackOverflow