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?
Pods can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume. A ConfigMap allows you to decouple environment-specific configuration from your container images, so that your applications are easily portable. Caution: ConfigMap does not provide secrecy or encryption.
Functions can access Kubernetes Secrets and ConfigMaps. Use secrets for things like API keys, authentication tokens, and so on. Use config maps for any other configuration that doesn't need to be a secret.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With