Get started in 5 minutes

Okteto gives you instant cloud environments to code and collaborate. Write code using your favorite IDE, and see the results directly in the cloud. No commit or push required.

This tutorial will have you developing and deploying a Python app in less than 5 minutes. Hang on for a bit longer to learn more about the power of Okteto.

While you’re going through this tutorial, why don’t you join Okteto’s slack community and say hi 🤙?

Step 1: Install the Okteto CLI

You’ll use the CLI to create your Okteto Environments, provision databases and run your application.

Install the Okteto CLI by running the following command in your local terminal:

MacOS/Linux

1
curl https://get.okteto.com -sSfL | sh

Windows

1
wget https://downloads.okteto.com/cloud/cli/okteto-Windows-x86_64 -OutFile c:\windows\system32\okteto.exe

Step 2: Login from the Okteto CLI

1
$ okteto login

The login command will automatically create an account for you in Okteto. It will also automatically create your personal Okteto Space. Okteto Environments and Databases launched in your space can only be accessed by you. They also share the same network, so they can talk to each other directly.

Step 3: Create your Okteto Environment

Okteto runs your application in an Environment. An Okteto Environment is a container that includes all the runtime components and developer tools you need to build and run your application. We offer pre-built development environments for the most popular software stacks, but you can also create and share your own.

Get a local version of the sample application by executing the following commands in your local terminal:

1
2
$ git clone https://github.com/okteto/cloud-samples
$ cd cloud-samples/vote

You now have a functioning git repository that contains a simple python 3 application and a requirements.txt, which is used by Python’s dependency manager, pip. The application we’re using in this tutorial consists of a flask app that allows you to vote for your favorite animals and stores the results in a Redis database.

First we need to provision the Redis database. Okteto provides three database services: Okteto Postgres, Okteto Redis and Okteto MongoDB. Run okteto database redis in your local terminal to provision an instance of Okteto Redis into your Okteto Space. The command will print out the name and connection string of your database instance.

1
2
3
4
$ okteto database redis
✓ Your redis instance is ready
Name: redis
Endpoint: redis://redis:6379

Now start your Okteto Environment by running okteto up in your local terminal:

1
2
3
4
5
6
7
8
9
$ okteto up
✓ Okteto Environment activated
✓ Files synchronized
✓ Your Okteto Environment is ready
Name: damp-darkness
Endpoint: https://damp-darkness-rberrelleza.cloud.okteto.net

Welcome to your development environment. Happy coding!
okteto>

The okteto up command will create an Okteto Environment with a random name and configured for your application (you can customize this later by updating okteto.yml). Your Okteto Environment will be active until you manually deleted it.

Every Okteto Environment has a unique public address. It will be accessible while your application is running and listening on port 8080.

Once the Okteto Environment is ready, start your application by executing the following commands in your Okteto Terminal:

1
2
okteto> pip install -r requirements.txt
okteto> python app.py

Your application is now ready. Open your browser and go the URL of the application. You can get it from the okteto up command, or by logging into Okteto and clicking in the application’s endpoint.

Place a few votes on your favorite animal to see try out the application. Congratulations, you just deployed your first Okteto Application 🚀!

Step 4: Develop directly in the cloud

Now things get more exciting. When your Okteto Environment starts, a file synchronization service is created to automatically keep your changes up to date between your local filesystem and your Okteto Environment. With Okteto, you can still use your local IDE, even when developing directly in the cloud.

Open vote/app.py in your favorite IDE and modify the getOptions function with the following code, and save your file:

1
2
3
4
def getOptions():
optionA = 'Otters'
optionB = 'Dogs'
return optionA, optionB

Go back to your Okteto Terminal and notice that flask already detected the code changes and reloaded your application.

1
2
3
4
5
...
* Detected change in '/usr/src/app/app.py', reloading
* Restarting with stat
* Debugger is active!
* Debugger PIN: 778-756-428

Go back to the browser, and reload the page. Notice how your changes are instantly applied. No commit or push required 😎!

Step 5: Deploy your application

Now that you are happy with your changes, it’s time to run your updated application with the okteto run command. Instead of launching an Okteto Environment and synchronizing your files, the okteto run command automatically deploys a container into your Okteto Space.

Let’s build a Docker image with your latest changes. Press ctrl + c and ctrl + d in your Okteto Terminal to go back to your local terminal, and execute the following command to build your docker image and push it to Docker Hub:

1
2
$ docker build -t <hub-user>\vote
$ docker push <hub-user>\vote

If you don’t have access to Docker Hub, you can use okteto/vote:0.1.0 instead of your own docker image to complete this step.

Once your image is ready, run the following command to deploy your container:

1
$ okteto run <hub-user>\vote

After a couple of seconds, your application will be ready. Go back to the browser and reload the page to see your new docker container up and running.

okteto run only supports images from public docker repositories.Contact us if you’re interested in support for private images

Next steps

You now know how to create an Okteto Environment, deploy your application on it, develop it directly in the cloud and deploy the final container.

Notice that an okteto.yml has been generated in your folder. Okteto uses that manifest to determine the name of your Okteto Environment, the docker image to use and where to upload your code. You can edit it to customize your Okteto Environment. This will let you spin an Okteto Environment already configured with your own dev tools and dependencies.

Visit our samples repository to learn more about how to use Okteto to speed up your development.