Getting Started With Okteto

okteto manages two different concepts: projects and services.

Projects represent a group of strongly related services. All services in the same project will share the same infrastructure, network domain, secrets, logging and other configurations.

Services represent your applications. Services in the same project are meant to be related, and can access each other via private traffic.

The idea is to configure your infrastructure once at the project level, which might be more time-consuming, and all the services will inherit the same configuration. This way developers can easily deploy their applications in a given project.

This guide will show you how to configure a demo project in your okteto account.

Create Your First Project

  1. Log in to your okteto account by browsing here.

  2. On the top side of the screen, click on the icon * Projects.

  3. Click on the ‘+’ icon on the top left and pick a name for your project.

  4. Click on the Create button to create your new project.

By default, your project is configured to use okteto’s infrastructure. Our free tier is just meant for demo purposes and it allows the creation of a maximum of 5 services which get auto destroyed after 1 hour.
To configure a project using your own infrastructure, go to the Project Reference.

Deploy Your First Application

Now it’s time to launch your first application.
We’ll be using the sample application available here.

The sample application is a python web application that counts the number of visits and stores it in a redis database.

You can run this application locally by executing:

1
2
3
$ git clone https://github.com/okteto/sample-app.git
$ cd sample-app
$ docker-compose up -d

Browse to http://localhost:5000/ to use it.

In order to deploy this application to your okteto project, we need to create two service manifest files, one for the python application and one for the redis service. Let’s create them in okteto.

Redis Service

  1. Log in to your okteto account by browsing here.

  2. Click on the ‘+ Add Service’ icon on the top left to create a new service.

  3. On the Manifest section, paste the definition of the redis service:

    1
    2
    3
    4
    5
    6
    7
    8
    name: redis
    replicas: 1
    stateful: true
    containers:
    redis:
    image: redis:alpine
    ports:
    - tcp:6379:tcp:6379
  4. Click on the deploy button on the top right corner.

After a few minutes, the redis service will be deployed (green) and a new section Endpoints section will appear with the URL you can use to access your service. Because the service is not marked as public, this endpoint won’t be publicly accessible.

As the service is deployed, its logs will appear in the History section below the service manifest. Every action you perform via okteto will be displayed as part of the service’s history.


Redis service

Python Web Service

  1. Click on the ‘+ Add Service’ icon on the top left to create a new service.

  2. On the Manifest section, paste the definition of the web service:

    1
    2
    3
    4
    5
    6
    7
    8
    name: web
    replicas: 2
    public: true
    containers:
    web:
    image: okteto/sample-app
    ports:
    - http:80:http:80
  3. Click on the deploy button on the top right corner.

After a few minutes, your service will be deployed (green) and a new section Endpoints section will appear to access your service.
This time the service has been declared as public, and the endpoint is accessible from external traffic. Browse to the endpoint to verify that the app is running.

If you want your app to run using certificates, update the ports in your web service manifest to expose https:

1
2
ports:
- https:443:http:80

and click the deploy button on the top right corner again.

That’s all, you have successfully deployed your first application in okteto!

More information: