Kubernetes ConfigMap 创建失败 cannot unmarshal number into Go struct field ConfigMap.data of type string

Kubernetes YAML About 368 words

错误信息

ConfigMap in version "v1" cannot be handled as a ConfigMap: json: cannot unmarshal number into Go struct field ConfigMap.data of type string

ConfigMap yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: myconfigmap
data:
  username: zhangsan
  password: 123

原因

上述案例中的password填写的是123Go语言在转换时认为了是一个number类型的变量,所以转换失败。

解决方法

对于纯数字类型的变量,可以添加双引号,即password: "123"

Views: 5,090 · Posted: 2022-11-09

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh