In this tutorial we are going to deploy MongoDB and Mongo Express applications using the following Kubernetes components:
ServicetypeclusterIp- an internal service for ourMongoDBapp (no external requests!).Secretthat contains our DB credentials.configMapthat stores our DB url.Deployment- two Deployments one for theMongoDBapp and one for theMongo Expressapp. in the Deployment files we are gonna reference both secret and configMap files usingEnvironment variablesin order to access our DB in a secure way.ServicetypeLoadBalancer- External service that will allow external requests to our Mongo Express pod.
So with this setup the request flow will look like this:
- The request comes from the browser.
- Request goes to the
External serviceof theMongo Expresswhich will than forward it to theMongo Expresspod. Podwill then connect to theinternal serviceofMongoDB(thats basically the DB url from ourconfigMap).- The service will forward the request to the
MongoDBpod where it will authenticate using the credentials (from thesecret).
