You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ConfigMap与Secret优先级疑问:同Key时哪个生效?

ConfigMap 与 Secret 的优先级规则

当通过 envFrom 同时引用 ConfigMap 和 Secret,且二者存在相同的 Key 时,定义顺序靠后的配置会覆盖靠前的。

以你提供的配置为例:

spec:
  containers:
  - envFrom:
    - configMapRef:
        name: my-configmap
    - secretRef:
        name: my-secret

这里 my-secret 中与 my-configmap 重复的 Key,会覆盖 ConfigMap 里对应 Key 的值。如果调整顺序,把 Secret 放在前面、ConfigMap 放在后面,那么 ConfigMap 的同 Key 值会覆盖 Secret 的。

内容的提问来源于stack exchange,提问作者mnj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 04:57:24