Kubernetes adding the name of the pod as a label

2/10/2016

I need to add the name of a kubernetes pod as a label to that pod when I create a pod using a replication controller. Is there a way to do that or should I do a patch once the pod is created?

-- Dimuthu
kubernetes

2 Answers

2/13/2016

There is no way to auto-promote the pod name into a label. You'll have to do that manually. Sorry.

-- Tim Hockin
Source: StackOverflow

2/14/2016

Depending on what you're trying to do, a headless service may work for you: http://kubernetes.io/v1.1/docs/user-guide/services.html#headless-services

Specify spec.clusterIP=None

DNS is ten configured to return multiple A records (addresses) for the Service name, which point directly to the Pods backing the Service.

Otherwise, you may want to follow progress on the PetSet proposal: https://github.com/kubernetes/kubernetes/pull/18016

-- briangrant
Source: StackOverflow