Skip to content

Commit

Permalink
Expose pod name as a label on containers.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rjnagal committed May 4, 2015
1 parent 86751e8 commit c6911c3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/kubelet/dockertools/manager.go
Expand Up @@ -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{
"kubernetes.io/pod": namespacedName.String(),
}
dockerOpts := docker.CreateContainerOptions{
Name: BuildDockerName(dockerName, container),
Config: &docker.Config{
Expand All @@ -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,
},
}

Expand Down

0 comments on commit c6911c3

Please sign in to comment.