How to consume external MongoDB service in Kubernetes
There are many ways to consume an external service, such as:
- Hardcoding the IP:Port of the service in your app.
- Using environment variables in your app and injecting them through configmaps.
- Creating a service/endpoint, ExternalName service, or a service with External IPs. This allows your applications to useKubernetes' Service Discovery mechanisms.
In your case you can just use:const MONGO_URI = 'mongodb://mongo/${config.collection}?authSource=admin';
as the name mongo
will be mapped to 159.89.x.x:xxx