Tools · Containers and Kubernetes security · 26 / 27
A pod UID is not the pod name
The name is what people type. The UID is the object id. A new UID means a different object.
The name is the typed label
metadata.name is the name in the namespace. People type it in commands. After a pod is deleted, a later pod can reuse the name. The name alone does not prove it is the same object as yesterday.
Two namespaces can each have a pod named lab-web. The name without the namespace is not even one slot.
The UID is the object id
metadata.uid is the id the API assigned to that object. A different UID is a different object, even when the name matches. Quote the UID when the note has to mean this pod and not a later one with the same name.
If the paste has the name and no UID, write “UID not in this output.” Do not invent a UID from the name.
Cite the object you mean
File namespace, name, and UID together when you claim a specific object. A note that only has the name is a note about the name. It is not a note about one UID.
Lab: the same name, a new UID
Monday the pod named lab-web in team-a has UID aaaa-1111. Wednesday a get of the same name shows UID bbbb-2222. A draft says it is the same pod because the name did not change.
The note lists both UIDs under the shared name and namespace. They are two objects. Notes about Monday stay on aaaa-1111. Wednesday is bbbb-2222. The name is not the id.
namespace: team-a name: lab-web monday uid: aaaa-1111 wednesday uid: bbbb-2222 write: two objects not: the same pod because the name matches
Diagram
A name can outlive an object
The UID is what makes the note point at one pod.
- Name
The typed name in that namespace. It can be reused.
- UID
The object id. A new value is a new object.
- Namespace
Part of the name slot. Say it with the name.
- Name only
Not an object id. Write that the UID was not in the output.
Check yourself
1. Two gets of lab-web in team-a show different UIDs. What do you have?
2. Which field is the object id?
3. The paste has the name and no UID. What do you write?