Okteto Manifest Reference
okteto.yaml
is a manifest format for describing development environments.
The Okteto Manifest has four main sections: build
, deploy
, test
and dev
, to define how to build, deploy, test, and develop your development environment.
Example
build:
api:
context: api
frontend:
context: frontend
deploy:
- helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
dev:
api:
command: ["bash"]
forward:
- 8080:8080
- 9229:9229
sync:
- api:/usr/src/app
frontend:
command: yarn start
sync:
- frontend:/usr/src/app
test:
unit:
image: okteto/golang:1
commands:
- "go test ."
Schema reference
build (object, optional)
A list of images to build as part of your development environment.
build:
base:
context: .
api:
context: api
frontend:
context: frontend
dockerfile: Dockerfile
target: dev
depends_on: base
args:
SOURCE_IMAGE: ${OKTETO_BUILD_BASE_IMAGE}
secrets:
npmrc: .npmrc
Each image supports the following fields:
image
: the name of the image to build and push. In clusters that have Okteto installed, this is optional (if not specified, the Okteto Registry is used).context
: the build context. Relative paths are relative to the location of the Okteto Manifest (default:.
)dockerfile
: the path to the Dockerfile. It's a relative path to the build context (default:Dockerfile
)target
: build the specified stage as defined inside the Dockerfile. See the multi-stage official docs for details.args
: add build arguments, which are environment variables accessible only during the build process. Build arguments with a value containing a$
sign are resolved to the environment variable value on the machine okteto is running on.secrets
: list of secrets exposed to the build. The value of each secret refers to a file. Okteto will resolve references containing a$
sign in this file to environment variables on the machine okteto is running on.export_cache
: image tag for exported cache when build.cache_from
: list of images to import cache from.depends_on
: list of images that need to be built first.
You can build all these images by running okteto build
, or okteto build xxx
to build a single one.
Follow this document for a list of environment variables available in your deploy commands to refer to the images built in the build
section of your Okteto Manifest.
Okteto will automatically add all the build environment variables from all previous images in the dependency chain as build arguments. To refer to them, remember to add the
ARG
instruction on your Dockerfile.
context (string, optional)
The okteto context when the development environment is deployed. By default, it uses the current okteto context.
For example, to force that your development environment is always created on your minikube context, you can define:
context: minikube
You can use an environment variable to replace the context field, or any part of it:
context: $DEV_CONTEXT
dependencies ([string], optional)
A list of repositories you want to deploy as part of your development environment.
dependencies
is only supported in clusters that have Okteto installed.
dependencies:
- https://github.com/okteto/movies-frontend
Follow this document for a list of environment variables available in your deploy commands to refer to variables
of your dependencies
.
Use okteto deploy --dependencies
to force the redeployment of your dependencies.
There is also an extended notation to configure how to deploy your dependency:
dependencies:
frontend:
repository: https://github.com/okteto/movies-frontend
manifest: okteto.yaml
branch: main
variables:
ENVIRONMENT: development
DEBUG: true
wait: true
timeout: 15m
Or:
dependencies:
frontend:
repository: https://github.com/okteto/movies-frontend
manifest: okteto.yaml
branch: main
variables:
- ENVIRONMENT: development
- DEBUG: true
wait: true
timeout: 15m
When specifying the manifest path, the dependency deployment will use this path where the manifest is defined as the context.
deploy ([string], optional)
A list of commands to deploy your development environment.
It's usually a combination of helm
, kubectl
, and okteto
commands.
Deploy with Commands
For example, deploy a Helm chart using a custom command invoking the helm
CLI:
deploy:
- helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
You can name your commands with the following syntax:
deploy:
- name: Deploy Movies App with Helm
command: helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
You can share environment variables between steps by adding them to $OKTETO_ENV
:
deploy:
- name: Set env value
command: echo "OKTETO_FOLDER=/app" >> $OKTETO_ENV
- name: Get env value
command: echo "$OKTETO_FOLDER" # Prints /app
Follow this document for a list of environment variables available in your deploy commands.
Deploy remotely (recommended)
If you define an image in your deploy
section, okteto deploy
will run in remote mode:
deploy:
image: okteto/pipeline-runner:1.0.0
commands:
- helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
If you don't define an image, you can run in remote mode adding the remote
field to your manifest:
deploy:
remote: true
commands:
- helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
Follow our docs to know more about remote execution and how it works.
Deploy with Compose
Deploy a Docker Compose file using the following notation:
deploy:
compose: docker-compose.yml
Images specified in the build
section of the Okteto Manifest overrides the image associated with services sharing the same name in your Docker Compose files.
There is an extended notation to deploy several Docker Compose files and endpoints:
deploy:
compose:
- file: docker-compose.yml
services:
- frontend
- file: docker-compose.dev.yml
services:
- api
endpoints:
- path: /
service: frontend
port: 80
- path: /api
service: api
port: 8080
The services
field allows us to deploy only a subset of the services in the Docker compose file (default to all services).
Only the volumes
and endpoints
of the services specified in the services
field are deployed.
You can combine deploy commands with Docker Compose files:
deploy:
commands:
- helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
compose: docker-compose.yml
Your deploy commands will be executed before deploying your Docker Compose files.
Divert
Divert is useful when you have many services and you only want to deploy a subset of them in your development environment, while connecting these services with a shared environment that runs all your microservices.
When divert is enabled, Okteto adds the header baggage.okteto-divert
to every request coming from the developer namespace.
If the request reaches the shared namespace and matches a diverted virtual service, Okteto redirects the request back to the developer namespace.
To divert a virtual service as part of your development environment, use the following notation:
deploy:
commands:
- helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
divert:
driver: istio
virtualServices:
- name: vs1
namespace: staging
routes:
- route1
- route2
hosts:
- virtualService: frontend
namespace: staging
driver
: the backend for divert. Currently, the only supported driver isistio
.virtualServices
: a list of virtual services to divert. Each virtual service is defined with it's name, namespace, and an optional list of routes to be diverted. By default, all routes are diverted.hosts
: the list of hosts you want to divert in the developer namespace. Requests to these virtual services will have the headerbaggage.okteto-divert
injected.
destroy ([string], optional)
A list of commands to destroy external resources created by your development environment.
okteto destroy
automatically takes care of destroying all the Kubernetes resources created by okteto deploy
.
Use the destroy
section if you create resources out of the scope of Kubernetes, like s3 buckets or RDS databases.
destroy:
- helm uninstall movies
Follow this document for a list of variables available in your destroy commands.