Okteto CLI
The Okteto Command Line Interface (CLI) is a unified tool to manage your applications in Okteto directly from your terminal. Follow this guide to download and install the CLI if you don't already have it. The CLI is an open-source tool that can be used independently or integrated with the Okteto Platform.
- Commands labeled
Platform
are available exclusively on the Okteto platform and require the Okteto Helm Chart to be installed in your Kubernetes cluster - Commands labeled
Open-Source
are available to users of the Okteto open-source CLI
For a complete comparison of features, refer to the open-source README
Synopsis
$ okteto [options] <command> <subcommand> [parameters]
Use okteto command --help
for information on a specific command. The synopsis for each command shows its parameters and their usage. Optional parameters are shown in square brackets.
Global Flags
Options | Type | Description | Default |
---|---|---|---|
--help | bool | Show help info | |
-l, --log-level | debug, info, warn, error | Amount of information output | warm |
--log-output | tty, plain, json | Output format for logs | tty |
Available commands
analyticsPlatformOpen-Source
Enable / Disable analytics collection. Analytics are enabled by default.
If telemetry is disabled, analytics are disabled for all developers.
$ okteto analytics [parameters]
Options | Description |
---|---|
-d, --disable | Disable analytic collection |
Okteto only collects information to help us understand how our users interact with the product. We don't collect any personally identifiable information.
When you use the okteto CLI, the following information is collected:
- The name of the action
- A timestamp of when it was run
- Your version of the CLI
- Your OS
- An anonymous machine ID (we use https://github.com/denisbrodbeck/machineid for this)
- A user ID if you are currently logged in to Okteto
- An action ID (to correlate multiple actions performed during a command's execution)
Please reach out to us if you have any questions or concerns about the information collected.
buildPlatform
Build and push the images defined in the build
section using the Okteto Build Service.
$ okteto build [image...]
The following command flags are available:
Options | Type | Description | Default |
---|---|---|---|
-f, --file | string | The path to the Okteto Manifest | okteto.yml |
-n, --namespace | string | Overwrite the current Okteto Namespace | |
--no-cache | bool | Do not use cache when building the image | false |
--progress | string | Show plain/tty build output | tty |
You can also use the -f
to point to a Dockerfile instead of an Okteto Manifest.
In this mode, okteto build
will build an image using the Dockerfile.
This is useful to build images that are not defined on your Okteto manifest.
In "Dockerfile" mode, the following additional flags can be used (very similar to docker build
):
Options | Type | Description | Default |
---|---|---|---|
--build-arg | list | Set build-time variables (optional) | |
--cache-from | list | List of cache source images (optional) | |
--export-cache | string | Image tag for exported cache when build (optional) | |
--platform | string | Specify which platform to build the container image for (optional) | |
--secret | list | Secret files exposed to the build. Format: id=mysecret,src=/local/secret | |
-t, --tag | string | Tag name to be pushed (optional) | |
--target | string | Target build stage to build (optional) |
contextPlatformOpen-Source
Set the default Okteto Context.
An Okteto Context is a group of cluster access parameters. Each context contains a Kubernetes cluster, a user, and a namespace. The current Okteto Context is the default cluster/namespace for any Okteto CLI command.
$ okteto context
okteto ctx
is an alias of okteto context
.
This will prompt you to select one of your existing Okteto Contexts or to create a new one:
A context defines the default cluster/namespace for any Okteto CLI command.
Select the context you want to use:
Use the arrow keys to navigate: ↓ ↑ → ←
▸ https://okteto.example.com *
minikube
Create new context
Options | Type | Description | Default |
---|---|---|---|
--insecure-skip-tls-verify | bool | Skip validation of server's certificates | false |
-n, --namespace | string | Overwrite the current Okteto Namespace | |
--token | string | API token for authentication. Use this when scripting or if you don't want to use browser-based authentication. |
When you run okteto context
, the Okteto CLI will exchange an authorization token with the Okteto Platform and save your API token and Okteto certificates information under $HOME/.okteto/
.
In your CI/CD you should use environment variables to specify your Okteto Context, Namespace and token. Check out Environment Variables to know more.
Available subcommands:
delete
Delete one or more Okteto Contexts.
For example, to delete the Okteto Context "https://okteto.example.com", run:
$ okteto context delete https://okteto.example.com
list
List available Okteto Contexts.
$ okteto context list
Name Namespace Builder Registry
https://okteto.example.com * cindy tcp://buildkit.okteto.example.com:1234 registry.okteto.example.com
minikube default docker -
Options | Type | Description | Default |
---|---|---|---|
-o, --output | string | Output format. One of: json , yaml | json |
show
Print the current Okteto Context.
$ okteto context show
Options | Type | Description | Default |
---|---|---|---|
--include-token | bool | Include the token in the output | false |
-o, --output | string | Output format. One of: json , yaml | json |
{
"name": "https://okteto.example.com",
"token": "REDACTED", # only printed using flag: --include-token
"namespace": "cindy",
"builder": "tcp://buildkit.okteto.example.com:1234",
"registry": "registry.okteto.example.com",
"isOkteto": true
}
use
Set the default Okteto Context. okteto context use
is an alias of okteto context
.
deployPlatform
Deploy your Development Environment by running the commands specified in the deploy
section of your Okteto Manifest.
$ okteto deploy
If there are pending changes in the images defined in your Okteto Manifest, okteto deploy
automatically builds and pushes all them.
This way, okteto deploy
enforce all your local changes are pushed to your Development Environment.
If the repositories in the dependencies
section haven't been deployed yet, okteto deploy
deploys these dependencies automatically.
The command is executed relative to the path where the Okteto Manifest is located. This means, that if the Okteto Manifest is at any subfolder, the command will use the context of the subfolder where the Okteto Manifest is defined.
Options
Options | Type | Description | Default |
---|---|---|---|
--dependencies | bool | Force deployment of repositories in the dependencies section | false |
-f, --file | string | The path to the Okteto Manifest | okteto.yml |
--name | string | The name of the Development Environment | The repo/folder name |
-n, --namespace | string | Overwrite the current Okteto Namespace | |
--no-bash | bool | Execute the command using the container's default shell instead of bash | false |
--no-build | bool | Skips the re-build of images in the build section | false |
--remote | bool | Run the deploy commands using Remote Execution | false |
-t, --timeout | duration | The duration to wait until all pods are healthy. Requires --wait . Any value should contain a corresponding time unit e.g. 1s, 2m, 3h | 5m0s |
-v, --var | list | Set a variable for the deploy commands (can be set more than once) | |
-w, --wait | bool | Wait until the deployment finishes and pods are healthy | false |
destroyPlatform
Destroy your Development Environment. It automatically destroys all the Kubernetes resources created by okteto deploy. If you need to destroy external resources (like s3 buckets or other Cloud resources), use the destroy section of the Okteto Manifest.
$ okteto destroy
The okteto destroy
command will only destroy resources matching the specified Development Environment name. By default, this is the name of the folder, but you can specify the name in the Okteto Manifest, or with the --name
flag.
In a monorepo scenario, where you might have several Okteto Manifests, you need to specify the correct Okteto Manifest to destroy the specific Development Environment.
This ensures that the appropriate destroy commands, as defined in your Okteto Manifest, are executed within a particular scope.
This way, executing the okteto destroy
command on one Development Environment will not delete the other.
For example, if you have two Development Environments, dev1
and dev2
, and you run okteto destroy
for dev1
, it will only destroy the resources for dev1
and leave dev2
intact.
You can use okteto destroy --all
to delete all Development Environments in an Okteto Namespace.
Options
Options | Type | Description | Default |
---|---|---|---|
--all | bool | Destroy all Development Environments, excluding resources annotated with dev.okteto.com/policy: keep | false |
-d, --dependencies | bool | Force destroy repositories in the dependencies section | false |
-f, --file | string | The path to the Okteto Manifest | okteto.yml |
--force-destroy | bool | Forces the Development Environment to be destroyed even if there is an error executing the custom destroy commands defined in the Okteto Manifest | false |
--name | string | The name of the Development Environment | The repo/folder name |
-n, --namespace | string | Overwrite the current Okteto Namespace | |
--no-bash | bool | Execute the command using the container's default shell instead of bash | false |
--remote | bool | Run the destroy commands using Remote Execution | false |
-v, --volumes | bool | Destroy the persistent volumes created by the Development Environment | false |
Resources annotated with
dev.okteto.com/policy: keep
will not be affected by the destroy action.
doctorPlatformOpen-Source
Generate a doctor file with all the information relevant for troubleshooting an issue. Use it when filing an issue or asking the Okteto community for help.
$ okteto doctor [devContainer]
The doctor
command should be run from the folder where you ran okteto up
.
The doctor file contains:
- The
okteto.log
- The syncthing logs of your Development Container
- A summary of your Development Container manifest
- A metadata file with information about your host machine's OS and architecture
The following command flags are available:
Options | Type | Description | Default |
---|---|---|---|
-f, --file | string | The path to the Okteto Manifest | okteto.yml |
-n, --namespace | string | Overwrite the current Okteto Namespace |
downPlatformOpen-Source
Deactivate your Development Container, stops the file synchronization service, and restores your previous deployment configuration.
$ okteto down [devContainer]
The down
command should be run from the same location as okteto up
.
Options | Type | Description | Default |
---|---|---|---|
-A, --all | bool | Deactivate all running Development Containers | false |
-f, --file | string | The path to the Okteto Manifest | okteto.yml |
-n, --namespace | string | Overwrite the current Okteto Namespace | |
-v, --volumes | bool | Remove persistent volumes where your local folder is synced on remote | false |
endpointsPlatform
List the public endpoints of your Development Environment.
$ okteto endpoints
Options | Type | Description |
---|---|---|
-f, --file | string | The path to the Okteto Manifest |
--name | string | The name of the Development Environment |
-n, --namespace | string | Overwrite the current Okteto Namespace |
-o, --output | string | Output format. One of: ['json', 'md'] |
execPlatformOpen-Source
The exec
command allows you to execute a COMMAND
inside your Development Container, created by an okteto up
session which is already running. It is important to note that okteto exec
can only be used with a container that is in development mode. If there is no active Development Container corresponding to the current folder, the command will fail.
If only one Development Container is running, okteto exec
will automatically connect to it. If multiple Development Containers are activated, you'll be presented with a selector to choose which one you want to connect to.
$ okteto exec [devContainer] -- COMMAND
Make sure to run the exec
command from the same directory where you ran okteto up
.
Options | Type | Description | Default |
---|---|---|---|
-f, --file | string | The path to the Okteto Manifest | okteto.yml |
-n, --namespace | string | Overwrite the current Okteto Namespace |
helpPlatformOpen-Source
Displays the full help.
$ okteto help
kubeconfigPlatformOpen-Source
Download credentials for the Kubernetes cluster selected via okteto context
.
$ okteto kubeconfig
i Updated kubernetes context 'okteto_example_com/cindy' in '/Users/cindy/.kube/config'
logsPlatform
Fetch the logs of your Development Environment.
$ okteto logs [serviceName]
The first argument is optional and it's a regex matching the name of the containers you want to fetch the logs from.
For example, okteto logs api
fetches the logs of any container starting with api
.
Options | Type | Description | Default |
---|---|---|---|
-a, --all | bool | Fetch logs from the whole namespace | false |
-e, --exclude | string | Exclude by container name (regular expression) | |
-f, --file | string | The path to the Okteto Manifest | okteto.yml |
--name | string | The name of the Development Environment | The repo/folder name |
-n, --namespace | string | Overwrite the current Okteto Namespace | |
-s, --since | duration | Return logs newer than a relative duration like 5s, 2m, or 3h | 48h0m0s |
--tail | int | The number of lines from the end of the logs to show | 100 |
-t, --timestamps | bool | Print timestamps | false |
namespacePlatform
Configure the default namespace of the Okteto Context.
$ okteto namespace
okteto ns
is an alias of okteto namespace
.
This will prompt you to select one of your existing namespaces:
Select the namespace you want to use:
Use the arrow keys to navigate: ↓ ↑ → ←
▸ cindy
Create new namespace
✓ Using context cindy @ okteto.example.com
Options | Type | Description | Default |
---|---|---|---|
--personal | bool | Load personal namespace | false |