Kubernetes utilizes DNS for service discovery. It is quite easy. One can use host name
service_name.namespace (in my previous sample,
code-sharing-api.default) to access the service (with load-balancing).
I was preparing a sample front-end webapp, and then figured out that it actually required an API gateway (Ingress, in kubernetes), instead of service discovery mechanism. Else I would face the CORS problem (front-end and back-end being on different host or port), unnecessarily.