tczekajlo / kube-consul-register

a tool to register Kubernetes PODs as Consul Services
Apache License 2.0
105 stars 50 forks source link

Add Pod name without "pod:" prefix as tag #41

Closed arunvelsriram closed 5 years ago

arunvelsriram commented 5 years ago

kube-consul-register by default adds some useful tags like pod name, node name, container name etc. It also adds the type as prefix. For example, pod:<pod-name>, node:<node-name>.

I wanted to route traffic to specific pods (managed by Statefulset) via Consul DNS. Currently, this can be achieved by querying pod:<pod-name>.<consul-service-name>.service.consul. The problem am facing is that the above domain name is invalid for certain resolvers like redis-cli.

In this PR I have made kube-consul-register to add the pod name without "pod:" prefix as one of the tags to Consul service. So we use <pod-name>.<consul-service-name>.service.consul to route traffic to a specific pod.

Routing to specific pods is much required in a cluster setup (like redis cluster) where we have multiple master / slave instances and the client requires the name of all those instances to interact with the cluster.