4.8 KiB
Identifiers and Names in Kubernetes
A summarization of the goals and recommendations for identifiers and names in Kubernetes. Described in GitHub issue #199.
Definitions
- identifier
- An opaque machine generated value guaranteed to be unique in a certain space
- name
- A human readable string intended to help an end user distinguish between similar but distinct entities
- 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 identifiers
-
Uniquely identify an instance of a pod on the apiserver and on the kubelet
-
Uniquely identify an instance of a container within a pod on the apiserver and on the kubelet
-
Uniquely identify a single execution of a container in time for logging or reporting
-
The structure of a pod specification should stay largely the same throughout the entire system
-
Provide human-friendly, memorable, semantically meaningful, short-ish references in container and pod operations
-
Provide predictable container and pod references in operations and/or configuration files
-
Allow idempotent creation of API resources (#148)
-
Allow DNS names to be automatically generated for individual containers or pods (#146)
Design
-
Each apiserver has a Namespace string (a DNS_SUBDOMAIN) that is unique across all apiservers that share its configured minions. Example: "k8s.example.com"
-
Each pod instance on an apiserver has a PodName string (a DNS_SUBDOMAIN) which is and unique within the Namespace.
- If not specified by the client, the apiserver will assign this identifier Example: "guestbook.user"
-
Each pod instance on an apiserver has a PodFullName (a DNS_SUBDOMAIN) string which is derived from a combination of the Namespace and Name strings.
- If the joined Namespace and PodName is too long for a DNS_SUBDOMAIN, the apiserver must transform it to fit, while still being unique Example: "guestbook.user.k8s.example.com"
-
Each pod instance on an apiserver has a PodID (a UUID) that is unique across space and time
- If not specified by the client, the apiserver will assign this identifier
- This identifier will persist for the lifetime of the pod, even if the pod is stopped and started or moved across hosts Example: "01234567-89ab-cdef-0123-456789abcdef"
-
Each container within a pod has a ContainerName string (a DNS_LABEL) that is unique within that pod
- This name must be specified by the client or the apiserver will reject the pod Example: "frontend"
-
Each pod instance on a kubelet has a PodNamespace string (a DNS_SUBDOMAIN)
- This corresponds to the apiserver's Namespace string
- If not specified, the kubelet will assign this name to a deterministic value which is likely to be unique across all sources on the host Example: "k8s.example.com" Example: "file-f4231812554558a718a01ca942782d81"
-
Each pod instance on a kubelet has a PodName string (a DNS_SUBDOMAIN) which is unique within the source Namespace
- This corresponds to the apiserver's PodName string
- If not specified, the kubelet will assign this name to a deterministic value Example: "frontend"
-
When starting an instance of a pod on a kubelet, a PodInstanceID (a UUID) will be assigned to that pod instance
- If not specified, the kubelet will assign this identifier
- If the pod is restarted, it must retain the PodInstanceID it previously had
- If the pod is stopped and a new instance with the same PodNamespace and PodName is started, it must be assigned a new PodInstanceID
- If the pod is moved across hosts, it must be assigned a new PodInstanceID Example: "01234567-89ab-cdef-0123-456789abcdef"
-
The kubelet may use the PodNamespace, PodName, PodID, and PodInstanceID to produce a docker container name (--name) Example: "01234567-89ab-cdef-0123-456789abcdef_frontend_k8s.example.com"
-
Each run of a container within a pod will be assigned a ContainerAttemptID (string) that is unique across time.
-
This corresponds to Docker container IDs Example: "77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182"