Skip to main content
AllDevToolsHub
Back to all patterns

Kubernetes Resource Name (DNS subdomain)

Web & Network

Validates a Kubernetes resource name following the RFC 1123 DNS subdomain rules.

/^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/

How it works

K8s names must be lowercase alphanumeric or hyphens, 253 chars max, dot-separated labels each up to 63 chars. Used for most resources (pods, services, configmaps, etc.) other than label values.

Test Cases

Should Match

  • my-app
  • redis-primary
  • my-app.staging

Should NOT Match

  • MyApp
  • -bad-start
  • bad-end-
  • double..dot

Quick Summary

Matches K8s resource names (RFC 1123 DNS subdomain, lowercase, 253 char max, alphanumeric/hyphens, dot-separated labels).