Identifiers

Kubernetes Label (key=value)

Validate Kubernetes label `key=value` pairs per the K8s naming spec.

Try it in RegexPro →

Available in

Pattern

regexengine-agnostic
^([a-zA-Z0-9](?:[\w.\-]{0,61}[a-zA-Z0-9])?)=([a-zA-Z0-9](?:[\w.\-]{0,61}[a-zA-Z0-9])?)?$

Raw source: ^([a-zA-Z0-9](?:[\w.\-]{0,61}[a-zA-Z0-9])?)=([a-zA-Z0-9](?:[\w.\-]{0,61}[a-zA-Z0-9])?)?$

How it works

Both key and value follow the same rule: 1–63 chars, must start AND end with alphanumeric, can contain underscores/dots/hyphens in the middle. The value group is optional (empty values are allowed). Anchored with ^ and $ for strict full-string matching.

Examples

Input

app=myapp

Matches

  • app=myapp

Input

version=v1.2.3

Matches

  • version=v1.2.3

Input

-bad=value

No match

Common use cases

  • kubectl label / annotation linting
  • Helm chart values validation
  • GitOps tooling (ArgoCD, Flux) policy checks
  • Cluster admission webhook input validation