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:
- Okteto Manifest file: if there is an
okteto.yml
or.okteto/okteto.yml
file in your folder, Okteto will use this file to deploy your development environment. - Docker Compose file: if there is an
okteto-compose.yaml
ordocker-compose.yaml
file, Okteto will use this file to deploy your development environment. - Helm Chart: if there is a
chart
,charts
,helm/chart
, orhelm/charts
directory with aChart.yaml
file in it, Okteto will detect the chart and runhelm upgrade --install
on it to deploy your development environment. - Kubernetes manifests folder: if there is a
manifests
,kubernetes
, ork8s
folder, Okteto will detect it and runkubectl apply
to deploy your development environment. - Kubernetes manifests file: if there is a
manifests.yaml
,kubernetes.yaml
, ork8s.yaml
file, Okteto will detect it and runkubectl 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
icon: https://apps.okteto.com/movies/icon.png
build:
api:
context: .
deploy:
- helm upgrade --install app chart --set image=${OKTETO_BUILD_API_IMAGE}
dev:
api:
command: ["bash"]
forward:
- 8080:8080
- 9229:9229
sync:
- .:/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 registry.cloud.okteto.net/cindy/hello-world:okteto
, you would have the following values:
OKTETO_BUILD_HELLO_WORLD_IMAGE
: registry.cloud.okteto.net/cindy/hello-world@sha256:xxxOKTETO_BUILD_HELLO_WORLD_REGISTRY
: registry.cloud.okteto.netOKTETO_BUILD_HELLO_WORLD_REPOSITORY
: cindy/hello-worldOKTETO_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!.