Kubernetes Object Naming Model
Kubernetes Object Naming Model defines how resources are uniquely identified and structured within a cluster's namespace.
Kubernetes Object Naming Model is the set of rules governing how an object's metadata.name (and, for namespaced resources, its combination with metadata.namespace) must be formed, how uniqueness is enforced, and how names interact with DNS and other systems that consume Kubernetes-managed identifiers downstream. Because names are used directly as path segments in the API, as DNS labels for Service discovery, and as labels within generated child object names, the naming model imposes stricter constraints than an arbitrary free-text identifier would need, in order to remain valid across every context a name might be used in.
Name Uniqueness Scope
Uniqueness Within a Namespace
For namespaced resources, a name must be unique only within its namespace and its resource type; two Pods can share the exact name worker as long as they live in different namespaces, or as long as one is a Pod and the other is, say, a ConfigMap in the same namespace, since uniqueness is scoped to the specific combination of namespace, resource type, and name.
Uniqueness for Cluster-Scoped Resources
Cluster-scoped resources such as Nodes, PersistentVolumes, and ClusterRoles have no namespace to scope uniqueness within, so their names must be unique across the entire cluster for that resource type, reflecting that these resources represent cluster-wide entities rather than anything belonging to a particular team or application boundary.
DNS-Compatible Naming Constraints
RFC 1123 Subdomain Names
Most object names must conform to the RFC 1123 DNS subdomain format: lowercase alphanumeric characters, -, and ., no more than 253 characters, and must start and end with an alphanumeric character; this constraint exists because many names, particularly Service names, are used directly as DNS labels for cluster-internal service discovery, and an invalid DNS label would break that resolution.
RFC 1035 Label Names
Some resource types impose the stricter RFC 1035 label format, which additionally disallows the . character and caps length at 63 characters, matching the constraint on a single DNS label segment rather than a full subdomain, which applies specifically where the name must function as one DNS label rather than a dotted hierarchy.
Why the Stricter Rules Exist Even for Non-DNS Resources
Even for resource types with no direct DNS role, Kubernetes generally applies the same conservative naming rules across the board, since doing so keeps names portable and interoperable with any downstream tool that might assume DNS-compatible identifiers, and avoids a proliferation of resource-type-specific naming edge cases.
Generated Names
generateName as a Naming Convenience
Rather than specifying metadata.name directly, a client can supply metadata.generateName with a prefix, and the API server appends a random suffix to produce a unique name at creation time, which is the mechanism controllers use to name Pods created from a ReplicaSet template, since many identical Pods need distinct names despite sharing the same template.
Collision Handling
If the API server's randomly generated suffix happens to collide with an existing name (an extremely rare but structurally possible event), object creation fails with an already-exists error, and well-behaved clients using generateName are expected to retry the creation request, which will produce a new random suffix on the next attempt.
Names Versus UIDs as Identity
Names Are Reusable, UIDs Are Not
A name can be reused after its original object is deleted — creating a new Pod named worker after a prior Pod of that name was removed is entirely valid — but the new object receives a fresh metadata.uid, meaning any reference that needs to survive across a delete-and-recreate cycle unambiguously, such as an owner reference, must key on UID rather than name.
Implications for Automation
Automation and controllers that need to detect whether they are looking at the "same" object across two points in time, rather than merely an object with the same name, must compare UIDs rather than relying on name equality alone, since the naming model deliberately does not guarantee that a name persistently identifies one specific object over the object's full history within the cluster.