<p>Want to understand if it's possible to create a configmap with a blank or empty key. The value isn't empty though.</p>

Vinodh Nagarajaiah
<p>No, it is not possible. While the YAML syntax allows for an empty string to be specified as the key, Kubernetes validation will not accept it:</p>

<pre><code>$ cat test-cm.yaml
apiVersion: v1
data:
  key1: value1
  key2: value2
  "": value3
kind: ConfigMap
metadata:
  name: test-cm
$ kubectl apply -f test-cm.yaml
The ConfigMap "test-cm" is invalid: data[]: Invalid value: "": a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name',  or 'KEY_NAME',  or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+')
$
</code></pre>

<p>The validation regexp printed in the error message <code>[-._a-zA-Z0-9]+</code> clearly states that the key length may not be zero.</p>

<p>Using the null key is also unacceptable to Kubernetes:</p>

<pre><code>$ cat test-cm.yaml 
apiVersion: v1
data:
  key1: value1
  key2: value2
  ?
  : value3
kind: ConfigMap
metadata:
  name: test-cm
$ kubectl apply -f test-cm.yaml 
error: error converting YAML to JSON: Unsupported map key of type: %!s(&lt;nil&gt;), key: &lt;nil&gt;, value: "value3"
$
</code></pre>
