Kubernetes:如何在configMap中设置布尔类型变量 [英] Kubernetes: How to set boolean type variable in configMap
问题描述
我想在configMap(或秘密)中设置一个布尔变量:
I want to set a boolean variable in configMap (or secret):
apiVersion: v1
kind: ConfigMap
metadata:
name: env-config
namespace: mlo-stage
data:
webpack_dev_server: false
但是当我应用它时,出现以下错误:
But when I apply it, I get the following error:
The request is invalid: patch: Invalid value: "map[data:map[webpack_dev_server:false] metadata:map[annotations:map[kubectl.kubernetes.io/last-applied-configuration:{ blah blah blah}]]]": unrecognized type: string
我试图将值更改为Off/No/False,所有问题都相同.
I have tried to change the value to Off/No/False, all having the same problem.
似乎数据映射中的键的值只能是字符串,我试图将其值更改为"false",yaml文件是可以的,但随后该变量变为字符串,但不能为布尔值.
It seems that the value of the keys in the data map can only be string, I have tried to change the value to "false", the yaml file is OK, but then the variable becomes a string but not boolean.
如果我想将布尔值作为值传递,该怎么办?
what should I do if I want to pass a boolean as value?
推荐答案
ConfigMap中的值必须是键值字符串值或文件.
Values in a ConfigMap must be key-value string values or files.
更改:
data:
webpack_dev_server: false
收件人:
data:
webpack_dev_server: "false"
对您的问题:
如果我想将布尔值作为值传递,该怎么办?
what should I do if I want to pass a boolean as value?
您可以在应用程序中处理此问题,将其从string
转换为bool
.
You may handle this in the application, transform from string
to bool
.
这篇关于Kubernetes:如何在configMap中设置布尔类型变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!