Dimuthu
Dimuthu

Reputation: 8576

Kubernetes adding the name of the pod as a label

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?

Upvotes: 0

Views: 1319

Answers (2)

briangrant
briangrant

Reputation: 845

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

Upvotes: 1

Tim Hockin
Tim Hockin

Reputation: 3662

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

Upvotes: 1

Related Questions