config kubectl_Kubectl更新configMap

bd96500e110b49cbb3cd949968f18be7.png

I am using the following command to create a configMap.

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

Now, I have modified a value for a key from mongo.properties which i need to update in kubernetes.

Option1 :-

kubectl edit test

Here, it opens the entire file. But, I want to just update mongo.properties and hence want to see only the mongo.properties. Is there any other way?

Note :- I dont want to have mongo.properties in a separate configMap.

Thanks

解决方案

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值