Skip to main content
Version: 1.50

Application Environments

An application environment is a running copy of your application. It runs in an Okteto Namespace on Kubernetes, and Okteto creates it from the definition in your Okteto Manifest. Developers, pull requests, and AI coding agents all create their environments from that same definition, so a change that works in one environment works in the others.

Application environment workflow​

The Okteto CLI builds, deploys, and tests your application with Remote Execution: every operation runs in a container inside the cluster. Nothing depends on how the machine running the CLI is set up, whether that's a developer's laptop, a CI job, or a coding agent's sandbox:

The Okteto CLI runs in the sandbox of a coding agent, on a laptop, or in a CI job. It deploys and tests the application in an application environment, an Okteto Namespace that runs the frontend, the API, the worker, the database, and the queue of the application, and gets back the results and the logs

Working with an application environment takes three steps:

  1. okteto namespace create creates the Okteto Namespace for the environment.
  2. Repeat this loop until your change works:
    • okteto deploy builds the images for your services and deploys the application.
    • Optionally, okteto up speeds up the inner feedback loop with hot reloading and debuggers.
    • okteto test runs your tests against the application.
  3. okteto namespace delete deletes the Okteto Namespace and the application in it.

To see this workflow in practice, follow Deploy your app, which takes a sample application through each step.

Okteto Manifest​

The Okteto Manifest (okteto.yaml) is a file in your repository that defines how to build, deploy, test, and develop your application. The Okteto Manifest reference covers every option. This minimal Okteto Manifest builds two images, deploys them with Helm, and runs the end-to-end tests:

okteto.yaml
build:
api:
context: api
frontend:
context: frontend

deploy:
image: alpine/helm:4.3.2
commands:
- name: Helm Install
command: |
helm upgrade --install movies chart \
--set api.image=${OKTETO_BUILD_API_IMAGE} \
--set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}

test:
e2e:
image: mcr.microsoft.com/playwright:v1.65.1-noble
context: e2e
commands:
- bash run_tests.sh

Okteto serves the application's endpoints over HTTPS. The deploy commands can also create cloud resources, such as a database or a queue, using the Cloud Credentials your Admin configures. The commands in the destroy section delete them.

Build​

The build section defines the images for your services. The Okteto Build Service builds them inside the cluster:

build:
api:
context: api
frontend:
context: frontend

Okteto builds one image from the api folder and another from the frontend folder. Your deploy commands reference them through the OKTETO_BUILD_API_IMAGE and OKTETO_BUILD_FRONTEND_IMAGE variables. See the build reference for every option.

Dependencies​

The dependencies section lists other Git repositories that Okteto deploys along with your application:

dependencies:
mongodb:
repository: https://github.com/okteto/mongodb
wait: true

Okteto deploys the okteto/mongodb repository using that repository's own Okteto Manifest, and waits for it to be ready before deploying your application. See the dependencies reference for every option.

Deploy​

The deploy section lists the commands that deploy your application, typically helm or kubectl commands:

deploy:
image: alpine/helm:4.3.2
commands:
- name: Deploy PostgreSQL
command: helm upgrade --install postgresql postgresql/chart
- name: Deploy the Movies app
command: |
helm upgrade --install movies chart \
--set api.image=${OKTETO_BUILD_API_IMAGE} \
--set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}

Okteto runs the commands in order, inside the cluster, in a container started from the image you set. Every resource they create shows up in the Okteto UI as part of the application environment. See the deploy reference for every option.

Destroy​

The destroy section lists the commands that delete the resources your application uses outside the cluster:

destroy:
image: hashicorp/terraform:1.17.2
commands:
- name: Delete the cloud resources
command: terraform destroy --auto-approve

okteto destroy deletes the environment's Kubernetes resources, then runs these commands inside the cluster, in a container started from the image you set. Here, they delete the cloud resources that the deploy commands created with Terraform. See the destroy reference for every option.

Dev​

The dev section defines the Development Containers for your application:

dev:
api:
command: bash
sync:
- api:/usr/src/app

okteto up api replaces the api service with a Development Container, syncs your local api folder to /usr/src/app, and opens a shell in it. Your changes run in the application environment as you save them. See the dev reference for every option.

External​

The external section lists the resources that are part of your application but run outside the cluster, such as cloud services or dashboards:

external:
lambda:
icon: aws
notes: docs/lambda.md
endpoints:
- name: function

The Okteto UI shows the lambda function alongside the rest of the environment, with its notes and its endpoint. This section only describes the resources. The commands in the deploy and destroy sections create and delete them. See the external reference for every option.

Test​

The test section defines the tests that Okteto Test runs against your application:

test:
unit:
image: golang:1.26
commands:
- go test ./...

okteto test runs each test inside the cluster, in a container started from its image, against the application environment. See the test reference for every option.