Skip to content

Add formats that are supported by CEL to CRDs #130639

@jpbetz

Description

@jpbetz

Currently, Kubernetes CRD formats lack consistent mapping to corresponding CEL types for commonly used data types like CIDR, Quantity, and Semver, despite CEL having native support for them.

This is inconsistent with types like "date" and "duration" that have a format that is mapped to a CEL type.

For unmapped types, CRD authors must perform manual validation and casting within CEL expressions.

For mapped types, the fields are automatically validated against the format, and are typed according to the format in CEL expressions (without the need for a cast).

One way to think about this: Missing formats for CRD forces in "imperative" validation of fields, using CEL. Adding formats makes "declarative validation" of field possible.

Proposal

  • Add new CRD formats: "cidr" "quantity" and "semver"
  • Map these new formats to their corresponding CEL types.
  • Somehow deal with cases where a format and CEL type both exist but are not mapped ("ipv4," "ipv6," and "uri.")
    • Consider introducing new, distinct formats (e.g. "ip4", "ip6", "url") to represent the desired CEL IP and URL types without breaking existing CRDs.

Metadata

Metadata

Labels

sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions