By default, when a service is created, Kubernetes injects some environment variables in pods within the same namespace. These variables follow the pattern:
SERVICE-NAME_VARIABLE-NAME
If you have a service named nginx-provider, that generates the following variables (non-exhaustive) then you can simply inject these environment variables into your application: