This is a sample of how to develop a Flask App that uses CockroachDB as the DB.
-
Head to Okteto Cloud. If this is the first time you visit the page, you'll be asked to login with your Github credentials. Doing this will automatically create a free developer account for you.
-
Okteto Cloud already includes CockroachDB in its default application catalog. This version is configured to be highly available, and to only admin traffic from within your Okteto namespace. To deploy it, click on the
deploy
button, selectcockroachdb
, and click thedeploy
button. -
While your cluster finishes starting up, install the okteto CLI in your local machine if you don't have it yet. We'll be using that to start a remote development environment and synchronize your local code.
-
Run the
okteto context use https://cloud.okteto.com
in your local terminal to connect to your Okteto Cloud account.$ okteto context use https://cloud.okteto.com
-
Run the
okteto kubeconfig
command to download your credentials and activate your Okteto Cloud namespace.$ okteto kubeconfig
-
Run
okteto up
to start your development environment in Okteto Cloud. Your development environment will be pre-configured with everything you need to develop yourflask
application.$ okteto up
-
Before starting our service, we need to create the database. Your development environment is already configured with the cockroachDB client and access to the cluster, so all you have to run is:
okteto> cockroach sql -e 'CREATE DATABASE todo' --insecure
-
Start your service directly in your development environment
okteto> python app.py
-
When you started your development environment, Okteto Cloud automatically created an HTTPS endpoint to it. Go to Okteto Cloud, find the service and click on the URL to access your application. Add and remove a few items from the todo list to try it out.