Get started in 5 minutes

Okteto gives you instant cloud environments to code and collaborate in your Kubernetes cluster. 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 a Python app directly in the cloud 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 an account in Okteto, download your Kubernetes credentials, activate your namespaces and manage your Okteto Environments.

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/cli/okteto-Windows-x86_64 -OutFile c:\windows\system32\okteto.exe

Using an existing Kubernetes cluster?
It is possible to use Okteto with an existing cluster. If you’re interested in that scenario, jump to step 4 of the guide.

Step 2: Login from the Okteto CLI

Run okteto login command to create and initialize your Okteto account.

1
$ okteto login

When you create an account in Okteto, a service account, namespace, and credentials will be automatically created for you in Okteto’s multi-tenant kubernetes cluster. These resources are configured automatically to include network policies, quotas, pod security policies, admission webhooks, roles, role bindings and limit ranges to give you the best possible development experience.

Once the login process is completed, open your browser and go to https://cloud.okteto.com. you should now see your empty personal namespace, ready to create new resources.

Step 3: Switch Kubernetes namespaces and context

Run the following command to activate your new personal namespace:

1
$ okteto namespace

The okteto namespace command lets you easily change your Kubernetes context. If no namespace is provided, the command will switch to your Okteto personal namespace.

Step 4: Deploy the Sample App

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/samples
$ cd samples/python

You now have a functioning git repository that contains a simple python application and a requirements.txt, which is used by Python’s dependency manager, pip.

In the manifest/ directory you also have raw Kubernetes manifests that we will use in this guide to deploy the application in the cluster. Okteto works however independently of your common deployment practices or tools.

If you don’t have kubectl installed, follow this guide.

Run the Voting app by executing:

1
$ kubectl apply -f manifests
1
2
deployment.apps/vote created
service/vote created

Step 5: Create your Okteto Environment

Start your Okteto Environment by running the following command in your local terminal:

1
$ okteto up
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Deployment 'vote' doesn't exist. Do you want to create a new one? [y/n]: y
✓ Okteto Environment activated
✓ Files synchronized
✓ Your Okteto Environment is ready
Name: vote

* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 245-101-759

The okteto up command will automatically start an Okteto Environment. It will also start a file synchronization service to keep your changes up to date between your local filesystem and your Okteto Environment.

Your application is now ready. Open your browser and go the URL of the application. You can get the URL by logging into Okteto and clicking in the application’s endpoint.

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

Step 6: Develop directly in the cloud

Now things get more exciting. Open app.py in your favorite local 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 the terminal and notice that flask already detected the code changes and reloaded your application.

1
2
3
4
5
...
* Detected change in '/src/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, build or push required 😎!

Step 7: Cleanup

Cancel the okteto up command by pressing Ctrl + C and run the following commands to remove the resources created by this guide:

1
2
3
kubectl delete -f manifests
deployment.apps "vote" deleted
service "vote" deleted

Next steps

You now know how easy you can do efficient development in the cloud.

Notice the okteto.yml file in the sample folder. Okteto uses that manifest to determine the name of your Okteto Environment, the docker image to use and where to upload your code. Check the Okteto manifest docs to customize your Okteto Environments with your own dev tools, images and dependencies.

Improve your team’s Kubernetes and Docker development workflows with Okteto Enterprise. Schedule your demo today!