In this tutorial we are going to deploy
MongoDB
and Mongo Express
applications using the following Kubernetes
components:
Service
typeclusterIp
- an internal service for ourMongoDB
app (no external requests!).Secret
that contains our DB credentials.configMap
that stores our DB url.Deployment
- two Deployments one for theMongoDB
app and one for theMongo Express
app. in the Deployment files we are gonna reference both secret and configMap files usingEnvironment variables
in order to access our DB in a secure way.Service
typeLoadBalancer
- 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 service
of theMongo Express
which will than forward it to theMongo Express
pod
. Pod
will then connect to theinternal service
ofMongoDB
(thats basically the DB url from ourconfigMap
).- The service will forward the request to the
MongoDB
pod where it will authenticate using the credentials (from thesecret
).