A summarization of the goals and recommendations for identifiers in Kubernetes. Described in GitHub issue #199.
UID : A non-empty, opaque, system-generated value guaranteed to be unique in time and space; intended to distinguish between historical occurrences of similar entities.
Name : A non-empty string guaranteed to be unique within a given scope at a particular time; used in resource URLs; provided by clients at creation time and encouraged to be human friendly; intended to facilitate creation idempotence and space-uniqueness of singleton objects, distinguish distinct entities, and reference particular entities across operations.
rfc1035/rfc1123 label (DNS_LABEL) : An alphanumeric (a-z, and 0-9) string, with a maximum length of 63 characters, with the '-' character allowed anywhere except the first or last character, suitable for use as a hostname or segment in a domain name
rfc1035/rfc1123 subdomain (DNS_SUBDOMAIN) : One or more lowercase rfc1035/rfc1123 labels separated by '.' with a maximum length of 253 characters
rfc4122 universally unique identifier (UUID) : A 128 bit generated value that is extremely unlikely to collide across time and space and requires no central coordination
rfc6335 port name (IANA_SVC_NAME) : An alphanumeric (a-z, and 0-9) string, with a maximum length of 15 characters, with the '-' character allowed anywhere except the first or the last character or adjacent to another '-' character, it must contain at least a (a-z) character
Uniquely identify (via a UID) an object across space and time
Uniquely name (via a name) an object across space
Provide human-friendly names in API operations and/or configuration files
Allow idempotent creation of API resources (#148) and enforcement of space-uniqueness of singleton objects
Allow DNS names to be automatically generated for some objects
When an object is created via an API, a Name string (a DNS_SUBDOMAIN) must be specified. Name must be non-empty and unique within the apiserver. This enables idempotent and space-unique creation operations. Parts of the system (e.g. replication controller) may join strings (e.g. a base name and a random suffix) to create a unique Name. For situations where generating a name is impractical, some or all objects may support a param to auto-generate a name. Generating random names will defeat idempotency.
When an object is created via an API, a Namespace string (a DNS_SUBDOMAIN? format TBD via #1114) may be specified. Depending on the API receiver, namespaces might be validated (e.g. apiserver might ensure that the namespace actually exists). If a namespace is not specified, one will be assigned by the API receiver. This assignment policy might vary across API receivers (e.g. apiserver might have a default, kubelet might generate something semi-random).
Upon acceptance of an object via an API, the object is assigned a UID (a UUID). UID must be non-empty and unique across space and time.
Pods can be placed onto a particular node in a number of ways. This case study demonstrates how the above design can be applied to satisfy the objectives.
A user submits a pod with Namespace="" and Name="guestbook" to the apiserver.
The apiserver validates the input.
The pod is accepted.
The pod is bound to a node.
Kubelet validates the input.
Kubelet runs the pod.
A config file is stored on the node, containing a pod with UID="", Namespace="", and Name="cadvisor".
Kubelet validates the input.
Kubelet runs the pod.