Back to all patterns
Kubernetes Label Value
Web & Network
Validates a Kubernetes label value, up to 63 chars, alphanumeric/dot/underscore/hyphen.
/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9_.-]{0,61}[a-zA-Z0-9])?)?$/How it works
Label values may be empty, otherwise 1–63 characters, starting and ending with alphanumeric. Different from resource names: allows uppercase, underscore, and dot anywhere in the middle.
Test Cases
Should Match
- v1
- Production
- v1.2.3-beta
Should NOT Match
- -bad
- bad-
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Quick Summary
Validates a K8s label value (≤63 chars, alphanumeric anchors, _.- inside).