Skip to main content
Version: 1.24

Add a database as a dependency

The Movies app requires an instance of MongoDB to be running in your Development Environment.

You could deploy MongoDB as part of your deploy section in the okteto.yaml file, but in this case, you are going to use the repo https://github.com/okteto/mongodb as a dependency. This repo is already pre-configured with a Docker Compose file to deploy MongoDB in Okteto.

To instruct Okteto to deploy this repository in your Development Environment, add the following section to your okteto.yaml file:

okteto.yaml
dependencies:
mongodb:
repository: https://github.com/okteto/mongodb
wait: true
variables:
MONGODB_PASSWORD: password

The wait flag instructs Okteto to wait until MongoDB is ready before running the deploy commands.

The variables field can be used to customize the deployment of the dependency, in this case to set the MongoDB password.

note

Learn more about the diffent ways to define Okteto Variables here 😎

Deploy the Movies app to apply the changes:

okteto deploy
 i  Using cindy @ okteto.example.com as context
i Deploying dependency 'mongodb'
...
✓ Repository 'mongodb' successfully deployed
i Running 'Helm Install'
Release "movies" does not exist. Installing it now.
NAME: movies
LAST DEPLOYED: Fri Jan 19 23:54:00 2024
NAMESPACE: cindy
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
Success! Your application will be available shortly.
i Endpoints available:
- https://movies-cindy.okteto.example.com
- https://movies-cindy.okteto.example.com/api
✓ Development environment 'movies' successfully deployed

You can see that MongoDB is now running from the Okteto UI:

Movies Onboard MongoDB

And the seed job has now successfully initialized the MongoDB data.

note

Running seed data scripts can be slow with real world databases. For those scenarios, you can use our Volume Snapshots feature to clone this data from an existing database in seconds 🚀

Next Steps​

But the Okteto CLI is informing us that There are no available endpoints for 'movies'...

Let's create endpoints for your app in the next step of this guide 😎