Identifiers

Kubernetes Pod Name (RFC 1123)

Validate Kubernetes pod names per the RFC 1123 DNS label rules — lowercase, ≤63 chars, no leading/trailing hyphen.

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("^[a-z0-9](?:[a-z0-9\\-]{0,61}[a-z0-9])?$", "");
const input = "nginx-deployment-66b6c48dd5-abcd1";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
^[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?$

Raw source: ^[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?$

How it works

Stricter than the general hostname pattern: pod names must be LOWERCASE only (per K8s spec). [a-z0-9] for first char. (?:[a-z0-9\-]{0,61}[a-z0-9])? optionally allows up to 61 more chars ending in a non-hyphen. Total length ≤63 chars per RFC 1123 label limits.

Examples

Input

nginx-deployment-66b6c48dd5-abcd1

Matches

  • nginx-deployment-66b6c48dd5-abcd1

Input

my-app

Matches

  • my-app

Input

MyApp

No match

Common use cases

  • Helm chart values validation
  • Custom controller / operator input checks
  • GitOps tooling sanity rules
  • Cluster admission webhook policy

Related patterns