Kubectl update configMap

前端 未结 3 482
说谎
说谎 2021-02-12 10:07

I am using the following command to create a configMap.

kubectl create configmap test --from-file=./application.properties --from-file=./mongo.properties --from-         


        
相关标签:
3条回答
  • 2021-02-12 10:53

    Another option is actually you can use this command:

    kubectl create configmap some-config --from-file=some-key=some-config.yaml -n some-namespace -o yaml --dry-run | kubectl apply -f - 
    

    Refer to Github issue: Support updating config map and secret with --from-file

    0 讨论(0)
  • 2021-02-12 11:03

    Now you can. Just throw: kubectl edit configmap <name of the configmap> on your command line. Then you can edit your configuration.

    0 讨论(0)
  • 2021-02-12 11:06

    No, you can't.

    Replace in kubernetes will simply replace everything in that configmap. You can't just update one file or one single property in it.

    However, if you check with the client Api, you will find if you create a configmap with lots of files. Then, those files will be stored as a HashMap, where key is file name by default, value is the file content encoded as a string. So you can write your own function based on existing key-value pair in HashMap.

    This is what I found so far, if you find there is already existing method to deal with this issue, please let me know :)

    FYI, if you want to update just one or few properties, it is possible if you use patch. However, it is a little bit hard to implement.

    this and this may help

    0 讨论(0)
提交回复
热议问题