Edith Puclla:
I am getting an error creating CM in Mockups, does anybody understand the logs here?
Error from server (BadRequest): error when creating "cm.yaml": ConfigMap in version "v1" cannot be handled as a ConfigMap: v1.ConfigMap.Data: ReadString: expects " or n, but found 3, error found in #10 byte of ...|DB_PORT":3306},"kind|..., bigger context ...|<http://322.mycompany.com|322.mycompany.com>","DB_NAME":"SQL3322","DB_PORT":3306},"kind":"ConfigMap","metadata":{"creationTimes|...
controlplane $ cat cm.yaml
apiVersion: v1
data:
DB_NAME: SQL3322
DB_HOST: <http://sql322.mycompany.com|sql322.mycompany.com>
DB_PORT: 3306
kind: ConfigMap
metadata:
creationTimestamp: null
name: cm-3392845
controlplane $
unnivkn:
what command you ran ? please paste here.
Edith Puclla:
I just did: kubectl create -f cm.yaml , to create the Config Map
Fernando Jimenez:
apiVersion: v1
data:
DB_NAME: SQL3322
DB_HOST: <http://sql322.mycompany.com|sql322.mycompany.com>
DB_PORT: "3306"
kind: ConfigMap
metadata:
creationTimestamp: null
name: cm-3392845
Quote the number 3306
Edith Puclla:
wow I did that wrong …ups
chris resnik:
try the imperative command…. probably faster and less prone to errors
Edith Puclla:
with many parameters?
Edith Puclla:
Let me check
chris resnik:
you can use --from-literal= several times
Edith Puclla:
yes, I did, but I don’t know in what I failed and I decided to go for yaml. I will practice that , thank you
chris resnik:
of course, you can also use --from-literal= just once, output as yaml file, then edit that
Edith Puclla:
like this:
kubectl create configmap cm-3392845 --from-literal=DB_NAME=SQL3322 --from-literal=DB_HOST=<http://sql322.mycompany.com|sql322.mycompany.com> --from-literal=DB_PORT=3306
chris resnik:
yes, looks correct
Fernando Jimenez:
@Edith Puclla The risk of that is that now you might need to be aware of the shell interpreter, specially if in the key=value after --from-literal you might introduce a character that the shell is going to try to treat differently. It is for that reason you might commonly see those surrounded by single or double quotes. These quotes are for protection from the interpretation of the shell.
kubectl create configmap cm-3392845 --from-literal="DB_NAME=SQL3322" --from-literal="DB_HOST=<http://sql322.mycompany.com|sql322.mycompany.com>" --from-literal="DB_PORT=3306"