问题
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
I have tried to change the value to Off/No/False, all having the same problem.
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?
回答1:
Values in a ConfigMap must be key-value string values or files.
Change:
data:
webpack_dev_server: false
To:
data:
webpack_dev_server: "false"
To your question:
what should I do if I want to pass a boolean as value?
You may handle this in the application, transform from string
to bool
.
来源:https://stackoverflow.com/questions/63905890/kubernetes-how-to-set-boolean-type-variable-in-configmap