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
Platformare available exclusively on the Okteto platform and require the Okteto Helm Chart to be installed in your Kubernetes cluster - Commands labeled
Open-Sourceare 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...]
To save you time, okteto build will only build the image if your build context hasn't been built before. You can always force a build by using the --no-cache flag. Learn more about Okteto Smart Builds here.
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) |
If you use multiple Dockerfiles, you can use different ignore-files for each Dockerfile. You do so using a special naming convention for the ignore-files. Place your ignore-file in the same directory as the Dockerfile, and prefix the ignore-file with the name of the Dockerfile, as shown in the following example. e.g. dev.Dockerfile.dev and dev.Dockerfile.dockerignore
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.