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
Conversation
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: |
38081e4
to
7cc2364
Compare
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 |
LGTM, thanks @rjnagal! Will merge on green. |
What : rather than / ? It would be nice if the format we dump to logs for
|
'/' works fine too. Switched. |
I think that is what NameapacedName does.
|
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(), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@bgrant0607 updated the label key :) |
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.