Kubernetes: Unable to use 'true' and 'false' as label value

Created on 20 Mar 2016  ·  3Comments  ·  Source: kubernetes/kubernetes

It seems resources can't be created with label value set to 'true' or 'false'.

With the following yaml,

  template:
    metadata:
      labels:
        environment: test
        release: false
        tier: frontend

I'm getting error:

$ kubectl create -f replicaset.yaml
unable to decode "replicaset.yaml": [pos 341]: json: expect char '"' but got char 'f'

but change to

  template:
    metadata:
      labels:
        environment: test
        release: stable
        tier: frontend

No error:

$ kubectl create -f replicaset.yaml   
replicaset "replicaset" created

Label documentation doesn't mention this case.

Valid label values must be 63 characters or less and must be empty or begin and end with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.

The use case for using 'true' as label value is to use "Exist", "NotExist" selector, where you don't have a meaningful label value.

I haven't tested yet, but if yaml parser convert it to typed boolean value before we even get the value, then it might not be easy to fix? If so and we don't want to support it, then I'd think we at least document it somehow.

siapi-machinery

Most helpful comment

Quote them.

All 3 comments

Labels are strings.

Quote them.

follow @bgrant0607
fixed.

Was this page helpful?
0 / 5 - 0 ratings