Can a configMap of type array be created in Kubernetes

8/20/2020

Does the following configuration for configMap create the test.json file of type empty array or string []

kind: ConfigMap
apiVersion: v1
metadata:
  name: myconfigmap
data:
  test.json: |-
    []

The convertor to JSON suggests string:

{
	"kind": "ConfigMap",
	"apiVersion": "v1",
	"metadata": {
		"name": "myconfigmap"
	},
	"data": {
		"test.json": "[]"
	}
}

My goal is to create configMap file with empty array.

-- maopuppets
kubernetes

1 Answer

8/20/2020

Sure, you can make it whatever string you want, it just has to be a string. The thing you can't do is test.json: [] since that's an array. The fact that your string happens to be valid JSON is not something K8s knows or cares about.

-- coderanger
Source: StackOverflow