Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose pod name as a label on containers. #7712

Merged
merged 1 commit into from May 4, 2015

Conversation

rjnagal
Copy link
Contributor

@rjnagal rjnagal commented May 4, 2015

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.

@rjnagal
Copy link
Contributor Author

rjnagal commented May 4, 2015

@vmarmol

@vmarmol vmarmol self-assigned this May 4, 2015
@vmarmol
Copy link
Contributor

vmarmol commented May 4, 2015

Spoke offline about doing a concrete format for namespace, name instead of relying in the internal one Kubelet uses. Looks like we're gonna go with: <namespace>:<name>

@rjnagal rjnagal force-pushed the kubelet branch 2 times, most recently from 38081e4 to 7cc2364 Compare May 4, 2015 17:49
@rjnagal
Copy link
Contributor Author

rjnagal commented May 4, 2015

Switched to 'namespace:name' format.

sample grouping in docker:

docker ps -a -f label=kubernetes.io/pod=default:nginx-75f97

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

7940e2d11efc nginx:latest "nginx -g 'daemon of About a minute ago Up About a minute k8s_nginx.3c6ae5e1_nginx-75f97_default_3dc3233c-f284-11e4-8fb1-42010af0b7a3_809435e0

665f8c79438c gcr.io/google_containers/pause:0.8.0 "/pause" About a minute ago Up About a minute k8s_POD.1a1fe303_nginx-75f97_default_3dc3233c-f284-11e4-8fb1-42010af0b7a3_5b4f0d1f

@vmarmol
Copy link
Contributor

vmarmol commented May 4, 2015

LGTM, thanks @rjnagal! Will merge on green.

@thockin
Copy link
Member

thockin commented May 4, 2015

What : rather than / ? It would be nice if the format we dump to logs for
namespaced names was the same as this syntax.
On May 4, 2015 10:52 AM, "Victor Marmol" notifications@github.com wrote:

LGTM, thanks @rjnagal https://github.com/rjnagal! Will merge on green.


Reply to this email directly or view it on GitHub
#7712 (comment)
.

@rjnagal
Copy link
Contributor Author

rjnagal commented May 4, 2015

'/' works fine too. Switched.

@ghost
Copy link

ghost commented May 4, 2015

I think that is what NameapacedName does.
On May 4, 2015 11:16 AM, "Rohit Jnagal" notifications@github.com wrote:

'/' works fine too. Switched.


Reply to this email directly or view it on GitHub
#7712 (comment)
.

@rjnagal
Copy link
Contributor Author

rjnagal commented May 4, 2015

Updated to use NamespacedName.

@@ -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(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docker's proposed namespace convention is reverse DNS IIRC: io.kubernetes.pod.name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@rjnagal
Copy link
Contributor Author

rjnagal commented May 4, 2015

@bgrant0607 updated the label key :)

vmarmol added a commit that referenced this pull request May 4, 2015
Expose pod name as a label on containers.
@vmarmol vmarmol merged commit b012908 into kubernetes:master May 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants