How to find out redis server hostname?

11/3/2016

I was thinking of using kubernetes to setup a Redis service to a pod of containers for Redis masters. I have Node.js connecting to the Redis service but I would like to know which pod it connected to and that in turn figure out which node it connected to. Is there a way to do that? I was looking through redis-cli and there doesn't seem to be anything that will return the hostname.

-- PLui
kubernetes

1 Answer

11/4/2016

Each pod managed by Kubernetes is created with a set of environment variables.

If you ssh into your pod and run env | grep HOSTNAME in your shell you will get the name of the pod. Or just run env and explore what is in there.

I'm afraid you cannot get that kind of information within redis. What you can do is store the information into redis when starting your redis pod.

Hope it helps.

-- Michel Tresseras
Source: StackOverflow