Skip to main content
Version: 1.8

Okteto CLI

Dev Environments allow you to develop your deployed application locally. You continue coding in your favorite IDE and see the changes live on the deployed version of your application as soon as you hit save. Okteto CLI is an open source client-side only tool that allows you to launch Dev Environments in any Kubernetes cluster: your own, Okteto Cloud, or Okteto Self-Hosted.

Learn more about the Okteto CLI

Deployment Manifests

You need one of the following deployment manifests for your application so that Okteto CLI knows how to launch a Dev Environment for it. Okteto CLI will analyze your existing manifests (Helm, Kubernetes, etc.) and help you write an Okteto Manifest for your application. It will then use this Okteto Manifest instead of your existing deployment manifests to spin up Dev Environments.

If you're using a Docker Compose file, then Okteto CLI can directly launch a Dev Environment for your application without generating an Okteto Manifest. However, you can still choose to create the Okteto Manifest if you want more configuration over your environment.

Okteto CLI will look for deployment manifests for your application in the following order:

  1. Okteto Manifest file: if there is an okteto.yaml or .okteto/okteto.yaml file in your folder, Okteto will use this file to deploy your development environment.
  2. Docker Compose file: if there is an okteto-compose.yaml or docker-compose.yaml file, Okteto will use this file to deploy your development environment.
  3. Helm Chart: if there is a chart, charts, helm/chart, or helm/charts directory with a Chart.yaml file in it, Okteto will detect the chart and run helm upgrade --install on it to deploy your development environment.
  4. Kubernetes manifests folder: if there is a manifests, kubernetes, or k8s folder, Okteto will detect it and run kubectl apply to deploy your development environment.
  5. Kubernetes manifests file: if there is a manifests.yaml, kubernetes.yaml, or k8s.yaml file, Okteto will detect it and run kubectl apply to deploy your development environment

You can also explicitly define the location of the Okteto Manifest using the -f flag on any Okteto CLI command.

Okteto manifest

The Okteto manifest allows you to provide configuration for building, deploying, and developing your application in a Development Environment. This file is optional if you already have a Docker Compose file for your application. Learn more about the Okteto manifest here.

Sample Okteto Manifest

context: .
- helm upgrade --install app chart --set image=${OKTETO_BUILD_API_IMAGE}
command: ["bash"]
- 8080:8080
- 9229:9229
- .:/usr/src/app

This example shows how to build the container image of the api microservice, how to deploy the application using its helm chart, and how to develop on the api microservice by synchronizing the local filesystem on the container path /usr/src/app. If you want to learn more about what all you can configure in this manifest, head over to the Okteto Manifest Reference.

Built-in Environment Variables

The installation job also populates the following environment variables. You can refer to this in your deploy commands if needed:

  • OKTETO_NAMESPACE: the namespace where your application is going to be installed.
  • OKTETO_GIT_BRANCH: the name of the Git branch currently being deployed.
  • OKTETO_GIT_COMMIT: the SHA1 hash of the last commit of the branch.
  • OKTETO_REGISTRY_URL: the url of the Okteto Registry.
  • BUILDKIT_HOST: the address of the Okteto Cloud buildkit instance. You can use it to build your images with any CLI tool that supports Buildkit builds.

In order to refer to images in the build section of the Okteto Manifest, you can use the following environment variables:

  • ${OKTETO_BUILD_<service>_IMAGE}: the full image reference
  • ${OKTETO_BUILD_<service>_REGISTRY}: the registry URL where the image was pushed
  • ${OKTETO_BUILD_<service>_REPOSITORY}: the name of the image that was pushed
  • ${OKTETO_BUILD_<service>_SHA}: The latest tag and the SHA of the image

For example, for the image, you would have the following values:

  • OKTETO_BUILD_HELLO_WORLD_SHA: okteto@sha256:xxx

Built-in Tools When Deploying To Okteto Cloud

When launching a development environment from a Git Repository, Okteto will run an installation job that clones the Git repository, checks out the selected branch, builds the images defined in the build section of your Okteto Manifest, and executes the sequence of deploy commands. The job will fail if any of the commands in the deploy list fails. The installation job will run in a Debian Linux container with the following tools preinstalled:

  • bash
  • bazel
  • cue
  • curl
  • envsubst
  • git
  • helm
  • kubectl
  • kustomize
  • make
  • okteto
  • openssh
  • wait-for-it

The installation job is automatically configured with your Okteto and Kubernetes credentials.

Are we missing any binaries you use? Join our community and let us know!.