cdk8s-core icon indicating copy to clipboard operation
cdk8s-core copied to clipboard

Enclose label values that are numeric in quotes

Open akefirad opened this issue 1 year ago • 0 comments

Description of the bug:

I'm not sure if this is a feature or bug, or even what tool needs to take care of it. But it seems the root cause of the issue is deep in Go libraries used in K8S ecosystem. Anyhow, the issue is that even though 123456789 is a perfectly valid value for a label, you cannot deploy the following manifest:

# manifest.yaml file
apiVersion: v1
kind: ServiceAccount
metadata:
  name: foo-account
  labels:
    foo: 123456789

Reproduction Steps:

Try to deploy the above manifest.

Error Log:

The attempt fails with different error messages, depending on the tool used to deploy the resource. For example, using kubectl apply fails with:

error: unable to decode "manifest.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string

ArgoCD fails with:

"" is invalid: patch: Invalid value "<manifest>" : cannot convert int64 to string

Environment:

  • Framework Version: #N/A
  • OS: #N/A

Other:

A quick solution would be to enclose the value in quotes to force it to be string. But would be nice if CDK8S does it automatically.


This is :bug: Bug Report

akefirad avatar May 27 '23 12:05 akefirad