mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
Expose pod name as a label on containers.
Full pod name is exposed under key 'kubernetes.io/pod'. It helps in introspection by looking at all containers in a pod through docker ps -a -f label=kubernetes.io/pod=podXXX We also plan to visualize this in cAdvisor.
This commit is contained in:
parent
86751e8c90
commit
1511dbf0b5
@ -504,6 +504,10 @@ func (dm *DockerManager) runContainer(pod *api.Pod, container *api.Container, op
|
||||
if len(containerHostname) > hostnameMaxLen {
|
||||
containerHostname = containerHostname[:hostnameMaxLen]
|
||||
}
|
||||
namespacedName := types.NamespacedName{pod.Namespace, pod.Name}
|
||||
labels := map[string]string{
|
||||
"io.kubernetes.pod.name": namespacedName.String(),
|
||||
}
|
||||
dockerOpts := docker.CreateContainerOptions{
|
||||
Name: BuildDockerName(dockerName, container),
|
||||
Config: &docker.Config{
|
||||
@ -514,6 +518,7 @@ func (dm *DockerManager) runContainer(pod *api.Pod, container *api.Container, op
|
||||
Memory: container.Resources.Limits.Memory().Value(),
|
||||
CPUShares: milliCPUToShares(container.Resources.Limits.Cpu().MilliValue()),
|
||||
WorkingDir: container.WorkingDir,
|
||||
Labels: labels,
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user