I'm looking for a programmatic way to list up callers of one Service in kubernetes. For example, when there're 5 microservices A, B, C, D and E, and microservice A is accessed by microservice B, C, D and E, I'd like to list up microservice B, C, D, and E (at least their namespaces).
It's possible to grep environment variables of all Deployment and find services that point to Service of A like service-a.a-namespace.svc. But, I'm finding a more reliable approach that takes advantage of kubernetes features like Servive, kube-dns, iptables, kubectl, and so on. Please help me if you know anything.
Well, this is something related to distributed tracing !!
You can initiate a GUID in the headers and supply it to the subsequent microservices calls.
And if you are using some stable frameworks like Spring and spring-cloud then you can use Zipkins for this.
The caller sends a unique GUID and is intercepted by all the microservices in the hierarchy.
And when you wanna visualise the logs, then you can search using this GUID and related URI calls will appear.
The other way is to use Jaeger based tracing and it has support for kubernetes too.
You can refer this link for more.
I guess this turns a bit helpful