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:
Rohit Jnagal 2015-05-04 16:54:42 +00:00
parent 86751e8c90
commit 1511dbf0b5

View File

@ -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,
},
}