Passing list object into configMap data section

8/25/2020

I want to pass a list object in the data section of configMap in application YAML file.

I have the following list in the properties file:

abc.management.provider[0].url=https://example.com
 abc.management.provider[0].username=John
 abc.management.provider[1].url=https://example2.com
 abc.management.provider[1].username=Targerian

YAML file:

data:
    abc_management:
	  provider:
		- url: "https://example.com"
		  username: "John"
		- url: "https://example2.com"
		  username: "Targerian"

I'm getting this error: ConfigMap in version "v1" cannot be handled as a ConfigMap: v1.ConfigMap: Data: ReadString: expects " or n,.

what should I do?

-- Manoj Singh
kubernetes
kubernetes-helm
yaml

2 Answers

4/14/2021

I think this question points to what the nature of a ConfigMap object is. Under the hood, it seems ConfigMaps do not explicitly handle lists, so in the end it just depends on how you read that content.

The data field is designed to contain UTF-8 byte sequences ...

Each key under the data or the binaryData field must consist of alphanumeric characters, -, _ or .. The keys stored in data must not overlap with the keys in the binaryData field.

https://kubernetes.io/docs/concepts/configuration/configmap/#configmap-object

-- Martín Coll
Source: StackOverflow

8/25/2020

what should I do?

This mostly depends on how your application reads the configuration.

If it works for you, you an create the ConfigMap directly with your properties-file:

kubectl create configmap app-config --from-file=app.properties
-- Jonas
Source: StackOverflow