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.
The open-source version of Okteto supports features within the dev
section of the Okteto Manifest. For a complete comparison of features, refer to the open-source README.
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 ."
Validating and Autocompleting the Okteto Manifest in your IDE
Okteto provides a JSON Schema for the Okteto Manifest to enhance your development experience by enabling autocompletion, real-time validation, and improved error detection within your IDE.
To configure this in Visual Studio Code, install the YAML extension and add the following to your workspace or user settings.json:
{
"yaml.schemas": {
"https://raw.githubusercontent.com/okteto/okteto/master/schema.json": [
"okteto.yml",
"okteto.yaml",
]
}
}
For JetBrains IDEs, you can use the built-in JSON Schema feature specifying the following params:
- Schema URL as
https://raw.githubusercontent.com/okteto/okteto/master/schema.json
- Schema version as
2020.12
- Files:
okteto.yml
andokteto.yaml
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:
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.context
: the build context. Relative paths are relative to the location of the Okteto Manifest (default:.
)depends_on
: list of images that need to be built first.dockerfile
: the path to the Dockerfile. It's a relative path to the build context (default:Dockerfile
)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).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.target
: build the specified stage as defined inside the Dockerfile. See the multi-stage official docs for details.
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.
dependencies ([string], optional)
A list of repositories you want to deploy as part of your development environment.
dependencies:
- https://github.com/okteto/movies-frontend
Use okteto deploy --dependencies
to force the redeployment of your dependencies.
There is also an extended notation to configure how to deploy your dependencies:
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 as the location of the Okteto Manifest in the Git repository.
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 command to invoke 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
context: .
commands:
- helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
The context
field specifies the working directory for running the deploy commands. If left empty, it defaults to the directory containing the Okteto Manifest.
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.
If you want to deploy only a subset of the services in the Docker compose file, you can use the services
field. By default, all services are deployed.
deploy:
compose:
file: docker-compose.yml
services:
- frontend
There is an extended notation to deploy several Docker Compose files and endpoints. Only the volumes
and endpoints
of the services specified in the services
field are deployed:
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
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 allows you to create lightweight development environments that include only the services you are actively working on while leveraging an existing shared environment for all other microservices. This approach significantly reduces infrastructure costs and complexity, especially in large microservices environments.
Okteto supports two different drivers: nginx
(default) and istio
.
- Nginx
- Istio
Use the nginx
driver if your applications rely on Okteto-generated endpoints for service-to-service communication.
To deploy a diverted
development environment, add the divert.namespace
key under the deploy
section of your Okteto Manifest.
This configuration tells Okteto where to redirect requests for services not deployed in your current development environment.
deploy:
commands:
- helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
divert:
driver: nginx
namespace: staging
driver
: Specifies the backend to divert requests. Usenginx
(or leave this field unspecified) to use the default Nginx driver.namespace
: The namespace that holds the full shareable environment. When a request is directed to a service that wasn't created by thedeploy
command, Okteto will automatically direct it to the environment running on this namespace.
Use the istio
driver if your development environments use Istio for managing service-to-service communication.
When divert is enabled, Okteto injects the header baggage.okteto-divert
to every request coming from the developer Namespace.
If a request reaches the shared Namespace and matches a diverted virtual service, Okteto automatically 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
: Specifies the backend to divert requests. Useistio
to use the Istio driver.virtualServices
: A list of virtual services to divert. Each virtual service is defined by 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
in your namespace.
Use the destroy
section if you create resources outside of your namespace, like clusterroles, or 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.
Destroy remotely (recommended)
If you define an image in your destroy
section, okteto destroy
will run in remote mode:
destroy:
image: okteto/tfenv-ci:1.4
context: .
commands:
- terraform destroy --auto-approve
The context
field specifies the working directory for running the destroy commands. If left empty, it defaults to the directory containing the Okteto Manifest.
If you don't define an image, you can run in remote mode adding the remote
field to your manifest:
destroy:
remote: true
commands:
- helm uninstall movies
Follow our docs to know more about remote execution and how it works.
dev (object, optional)
A list of development containers to define the behavior of okteto up and synchronize your code in your development environment.
dev:
api:
command: ["bash"]
forward:
- 8080:8080
- 9229:9229
sync:
- api:/usr/src/app
frontend:
command: yarn start
sync:
- frontend:/usr/src/app
The name
of each development container must match the name of the Kubernetes Deployment or Statefulset that you want to put on development mode.
If the name of your Deployment or Statefulset is dynamically generated, use the selector field to match the Deployment or Statefulset by labels.
Each development container supports the following fields:
affinity (Affinity, optional)
Affinity allows you to constrain which nodes your development container is eligible to be scheduled on, based on labels on the node. More information about Kubernetes affinities is available here.
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: role
operator: In
values:
- web-server
topologyKey: kubernetes.io/hostname
autocreate (bool, optional)
If set to true, okteto up
creates a deployment if name
doesn't match any existing deployment in the current namespace (default: false
).
command (string, optional)
Sets the command of your development container. If empty, it defaults to sh
:
command: bundle exec thin -p 3000
The command can also be a list:
command: ["bundle", "exec", "thin", "-p", "3000"]
container (string, optional)
The name of the container in your deployment you want to put on development mode. By default, it takes the first one.
environment ([string], optional)
Add environment variables to your development container. If a variable already exists on your deployment, it will be overridden with the value specified on the manifest.
Environment variables with only a key, or with a value with a $
sign resolve to their values on the machine Okteto is running on, which can be helpful for secret or machine-specific values.
environment:
environment: development
name: user-${USER:peter} ## will be replaced by the value of $USER or by "peter" if the variable USER does not exist
DBPASSWORD: ## will be given the value of $DBPASSWORD if it exists
They can also be defined as a list, for example:
environment:
- environment=development
- name=user-${USER:peter} ## will be replaced by the value of $USER or by "peter" if the variable USER does not exist
- DBPASSWORD
envFiles
Add environment variables to your development container from a file.
envFiles:
- .env1
- .env2
Environment variables declared in the environment section override these values.
externalVolumes ([string], optional)
A list of persistent volume claims (not managed by Okteto) that you want to mount in your development container. This is useful to share cache information between different development containers. For example, to share the go cache between different development containers, you could define:
externalVolumes:
- go-cache:/root/.cache/go-build/
on different Okteto Manifests. You can also mount a relative subpath of a given persistent volume claim:
externalVolumes:
- pvc-name:subpath:/var/lib/mysql
forward ([string], optional)
A list of ports to forward from your development container.
The list should follow the localPort:remotePort
notation and each element should be unique.
You can also access other services running in your namespace by using the notation localPort:remoteService:remotePort
.
forward:
- 8080:80
- 5432:postgres:5432
You can also use the extended notation below to configure the service to be exposed using a label selector or its name.
forward:
- localPort: 8080
remotePort: 80
name: app
- localPort: 5432
remotePort: 5432
labels:
app: db
Once your development container is up and running, you will be able to access the port directly by using localhost:localPort
.
Common uses of port forwarding are:
- Access a service via
localhost
instead of via an ingress- Remote debugging
- Connect to a hot reloader via a websocket
If Okteto can't forward a port (typically because they are already taken), the okteto up
command will fail with an error.
initContainer (object, optional)
Allows you to override the okteto init container configuration of your development container.
initContainer:
image: okteto/bin:1.2.22
resources:
requests:
cpu: 30m
memory: 30Mi
limits:
cpu: 30m
memory: 30Mi
interface (string, optional)
Port forwards and reverse tunnels will be bound to this address. Defaults to localhost
.
interface: 0.0.0.0
image (string, optional)
Sets the docker image of your development container. Defaults to the image specified in your deployment.
More information on development images here
You can use an environment variable to replace the image, or any part of it:
image: okteto/dev:$USER
More information on how to use private images for your development container is available here.
imagePullPolicy (string, optional)
The image pull policy of your development environment (default: Always
)
lifecycle (boolean, optional)
Configures lifecycle hooks for your development container. Lifecycle hooks allow you to execute commands when your container starts or stops, enabling you to automate setup or cleanup tasks.
If set to true, both postStart and preStop lifecycle events are enabled when running okteto up
inheriting the lifecycle from the original container (default: false).
For more information about Kubernetes lifecycle hooks, see the official Kubernetes documentation.
lifecycle: true
This enables both postStart and preStop events to use the default commands defined in your Kubernetes deployment.
For more granular control, you can enable or disable specific lifecycle events and define custom commands to run during those events.
lifecycle:
postStart:
enabled: true
command: "echo 'Container has started'"
preStop:
enabled: true
command: "echo 'Container is stopping'"
- postStart:
- enabled (boolean): Set to true to enable the postStart event (default: false).
- command (string): The command to execute when the container starts.
- preStop:
- enabled (boolean): Set to true to enable the preStop event (default: false).
- command (string): The command to execute just before the container stops.
metadata (object, optional)
The metadata field allows to inject labels and annotations into your development container.
metadata:
annotations:
fluxcd.io/ignore: "true"
labels:
custom.label/dev: "true"
mode (string, optional)
The development mode used for a development environment. There are two options available for this field:
sync
: the standard and default mode. This mode will synchronize your code with the remote development containerhybrid
: use this mode if you want to run your service locally but run the rest of your application components in the cluster
More information about development modes is available here.
nodeSelector (map[string]string, optional)
List of labels that the node must have to include the development container on it. More information about Kubernetes node selectors is available here.
nodeSelector:
disktype: ssd
persistentVolume (object, optional)
Allows you to configure the okteto persistent volume:
enabled
: enable/disable the use of persistent volumes (default:true
)accessMode
: the Okteto persistent volume access mode (default:ReadWriteOnce
)annotations
: add annotations to the Okteto persistent volumelabels
: add labels to the Okteto persistent volumesize
: the size of the Okteto persistent volume (default:5Gi
)storageClass
: the storage class of the Okteto persistent volume (default: thedefault
storage class in your cluster)volumeMode
: the Okteto persistent volume mode (default:Filesystem
)
persistentVolume:
enabled: true
storageClass: standard
size: 30Gi
Note the following limitations:
persistentVolume.enabled
must betrue
if you use services.persistentVolume.enabled
must betrue
if you use volumes.persistentVolume.enabled
must betrue
if you want to share command history across development containers between differentokteto up
sessions.
priorityClassName (string, optional)
This field allows you to optionally override the priorityClassName of your development container. By default, this is not set, but you can specify a custom value as shown below:
priorityClassName: okteto
This value will also apply to the priorityClassName
of the pods defined in your services.
probes (boolean, optional)
If set to true, liveness, readiness, and start probes are enabled when running okteto up
(default: false
).
More information about Kubernetes probes is available here.
Use the extended notation below to have more control over which probes to enable/disable:
probes:
liveness: true
readiness: true
startup: true
liveness
: specifies if liveness probes are enabled when runningokteto up
(default:false
).readiness
: specifies if readiness probes are enabled when runningokteto up
(default:false
).startup
: specifies if startup probes are enabled when runningokteto up
(default:false
).
resources (object, optional)
Allows you to override the resources configuration of your development container.
It follows the same syntax used in Kubernetes. By default, requests
, limits
and ephemeral-storage
are unset.
resources:
requests:
cpu: "250m"
memory: "64Mi"
ephemeral-storage: "64Mi"
limits:
cpu: "500m"
memory: "1Gi"
ephemeral-storage: "1Gi"
remote (integer, optional)
The local port to use for SSH communication with your development environment. Defaults to a random value.
remote: 2222
Setting this value in the manifest is equivalent to starting your development container with the
okteto up --remote=2222
command.
reverse ([string], optional)
A list of ports to reverse forward from your development container to your local machine.
The list should follow the remotePort:localPort
notation and each element should be unique.
reverse:
- 9000:9001
- 8080:8080
Once your development container is up and running, any requests to 0.0.0.0:remotePort
in the development container will be directed to localhost:localPort
Common uses of reverse forwarding are:
- Remote debugging
- Send events or logs to your local machine
If Okteto can't reverse forward a port (typically because they're already taken), the okteto up
command will fail with an error.
secrets ([string], optional)
A list of secrets that will be injected into your development container.
The format of a secret is LOCAL_PATH:REMOTE_PATH:MODE
. LOCAL_PATH
must exist, REMOTE_PATH
must be an absolute path, and MODE
is the remote file permissions in Base-8 (optional: defaults to 644
).
secrets:
- $HOME/.token:/root/.token:400
securityContext (object, optional)
Allows you to override the pod security context of your development container.
Okteto supports overriding the fsGroup
, runAsUser
, runAsGroup
, runAsNonRoot
, allowPrivilegeEscalation
and capabilities
values.
They're not set by default, and they follow the same syntax used in Kubernetes.
securityContext:
runAsUser: 1000
runAsGroup: 2000
fsGroup: 3000
runAsNonRoot: false
allowPrivilegeEscalation: false
capabilities:
add:
- SYS_PTRACE
Non-root Containers:
If you're using a non-root container, and the runAsUser and runAsGroup values are not specified in your Kubernetes manifest, you need to set these values in your Okteto manifest. Remember to use the numeric ID in all cases, not the human readable name.
selector (map[string]string, optional)
The labels of the Kubernetes deployment/statefulset you want to put on development mode. They must identify a single Kubernetes deployment/statefulset.
selector:
app.kubernetes.io/name: vote
serviceAccount (string, optional)
Allows you to override the serviceAccount of your development container.
serviceAccount: default