k8s configMap

  • Changing the main process of a container
  • Passing command-line options to the app
  • Setting environment variables exposed to the app
  • Configuring apps through ConfigMaps
  • Passing sensitive information through Secrets

部署一个app,配置可以通过command-line,当配置选项多了后,可以通过config file(保密性不强且每次更改都要重新创建image),或者是环境变量(在container中最常用)

一些配置参数放configureFile里嵌入image中的话每一个可以进入image的人都可以看到一些私密的参数信息如数据库密码等,而且每次改动参数都要rebuild image,所以用到了configMap。

configMap可以在命令行中用$(ENV_VAR)的方式来使用。

使用configmap的valueFrom intead of value field可以reuse the same pod definition in multiple environments,从而达到配置和pod descriptor解耦的目的。

 

configmap是KV形式的,也可以是一个文件夹。一般是将disk里的一个文件夹create为一个configMap,然后就可以通过valueFrom将这些KV作为环境变量传进container。

A configMap volume will expose each entry of the ConfigMap as a file. The process running in the container can obtain the entry’s value by reading the contents of the file.

可以通过设置configMapKeyRef。optional:true来选择一个configmap是否可以为空,这样就可以做成通用的一个configmap。

 

当你更新了configmap后,process会监测到并reload,但这会花费大约一分钟的时间。

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值