Reputation: 4672
Friends
Im writing a configMap containing an array of postgres db names. Approach 1 throws an error like scalar value is expected at postgres.db.name
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: "postgreshost"
postgres.db.name: {"postgredb1","postgredb1", "postgredb3"}
Here is Approach 2 ie postgres.db.name having db names separated by comma
----
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: postgreshost
postgres.db.name: postgredb1,postgredb1,postgredb3
Which is the correct way to achieve db names as an array ?
Upvotes: 1
Views: 6857
Reputation: 519
Edit: As @ShawnFumo and @HuBeZa pointed out, my old answer was incorrect. Configmap data key/value pairs expect the value to be in string format, therefore it isn't possible to provide a dict/list as value.
note: you have 4 "-" at the start of your second example, which would make the YAML document invalid. new YAML docs start with 3 "-". :)
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-init
data:
postgres.host: postgreshost
# Note the "|" after the key - this indicates a multiline string in YAML,
# hence we provide the values as strings.
postgres.db.name: |
- postgredb1
- postgredb2
- postgredb3
Upvotes: 6