3.6 KiB
Identifiers and Names in Kubernetes
A summarization of the goals and recommendations for identifiers in Kubernetes. Described in GitHub issue #199.
Definitions
- uid
- An opaque system-generated value guaranteed to be unique in time and space; intended to distinguish between historical occurrences of similar entities.
- name
- A 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, 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 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
Objectives for names and uids
-
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
FIXME: Should this be more agnostic to resource type, and talk about pod as a particular case?
Design
- When an object is created on an apiserver, a Name string (a DNS_SUBDOMAIN) must be provided.
- must be non-empty and unique within the apiserver
- enables idempotent and space-unique creation
- generating random names will defeat idempotentcy
- other parts of the system (e.g. replication controller) may join strings (e.g. a base name and a random suffic) to create a unique Name Example: "guestbook.user" Example: "backend-x4eb1"
FIXME: final debate on having master default a name. Alternative: set "autosetName"=true
-
Upon acceptance at the apiserver, a pod is assigned a uid (a UUID).
- must be non-empty and unique across space and time Example: "01234567-89ab-cdef-0123-456789abcdef"
-
Each container within a pod must have a Name string (a DNS_LABEL).
- must be non-empty and unique within the pod Example: "frontend"
-
When a pod is bound to a node, the node is told the pod's uid.
- if not provided, the kubelet will generate one
- provides for pods from node-local config files
-
When a pod is bound to a node, the node is told the pod's Name.
- kubelet will namespace pods from distinct sources (e.g. files vs apiserver)
- namespaces must be deterministic
- provides a cluster-wide space-unique name Example: Namespace="k8s.example.com" Name="guestbook.user" Example: Namespace="k8s.example.com" Name="backend-x4eb1" Example: Namespace="file-f4231812554558a718a01ca942782d81" Name="cadvisor"
-
Each run of a container within a pod will be assigned an AttemptID (string) that is unique across time.
- corresponds to Docker's container ID Example: "77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182"