Okteto CLI
The Okteto Command Line Interface is a unified tool to manage your development environments.
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.
Options | Values |
---|---|
--loglevel | debug, info, warn, error |
The amount of information outputted (defaults to warn).
Advanced configuration
It is possible to handle timeouts from the client side when communicating with the buldkit daemon through the Okteto CLI. To do so, the following environment variables can be modified:
OKTETO_KEEPALIVE_CLIENT_TIME_MS
: After this duration of time, if the client doesn't see any activity it will ping the server to see if the transport is still alive. If set below 10s, a minimum value of 10s will be used. The current default value is infinity.OKTETO_KEEPALIVE_CLIENT_TIMEOUT_MS
: After sending a keepalive ping, the client waits for this duration of time and if no activity is seen even after that the connection is closed. The current default value is 20 seconds.OKTETO_KEEPALIVE_CLIENT_PERMIT_WITHOUT_STREAM
: If true, the client sends keepalive pings even with no active RPCs. If false, when there are no active RPCs, Time and Timeout will be ignored and no keepalive pings will be sent. False by default.
Available commands
analytics
Enable / Disable analytics collection. Analytics are enabled by default
$ okteto analytics [parameters]
Options | Description |
---|---|
--disable | Disables 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.
build
Build and push the images defined in the build
section of your okteto manifest:
$ okteto build [service...]
If your okteto context points to an Okteto URL, images are built using the Okteto Build Service.
Otherwise, images are built using your local Docker daemon. If you want to use another BuildKit instance, set the variable BUILDKIT_HOST
to point to its address, using the format HOST:PORT
.
The following flags can be used (very similar to docker build
):
Options | Type | Description |
---|---|---|
--file | (string) | The path to the okteto manifest |
--no-cache | (bool) | Do not use cache when building the image (default: false ) |
--secret | (list) | Secret files exposed to the build. Format: id=mysecret,src=/local/secret |
--export-cache | (string) | Image tag for exported cache when build (optional) |
--cache-from | (list) | List of cache source images (optional) |
--platform | (string) | Specify which platform to build the container image for (optional) |
You can also use the
-f
to point to a Dockerfile. In this mode,okteto build
will ignore your Okteto manifest, and directly build the image defined in the Dockerfile. Use this to build images that are not defined on your Okteto manifest.
With okteto build --platform
you can specify the platform (or architecture) for which you'd like to build the container images. For example, you could use a multiplatform image and the okteto build --platform
command to deploy your web application on a Kubernetes cluster that consists of nodes running on both x86-64 and ARMv7 architectures.
By using the multiplatform images built using this method, you can deploy the same images across the cluster without worrying about the underlying hardware differences.
Let's consider an example where you have a Node.js application that you want to build and deploy on both x86_64 and ARM-based platforms. You have a Dockerfile in your project directory that defines the build process. Here's how Okteto CLI can help you build multiplatform images for your application:
- Building the image for x86_64 architecture:
okteto build -t myapp:latest --platform linux/amd64
- Building the image for ARMv7 architecture:
okteto build -t myapp:latest --platform linux/arm/v7
- Building a multiarchitectural image:
okteto build -t myapp:latest --platform linux/amd64,linux/arm/v7
This command builds a multi-architecture Docker image named myapp with the latest tag for both x86_64 and ARM platforms.
By using these commands, you can easily build the application image for different platforms without needing to maintain separate Dockerfiles or perform manual modifications. This is particularly useful when you want to deploy your application to heterogeneous environments where you have both x86_64 and ARM-based devices, such as a mixed-cluster Kubernetes setup.
context
Set the default context.
A context is a group of cluster access parameters. Each context contains a Kubernetes cluster, a user, and a namespace. The current context is the default cluster/namespace for any Okteto CLI command.
$ okteto context
This will prompt you to select one of your existing 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://cloud.okteto.com (Okteto Cloud)
minikube
▸ https://okteto.example.com *
Create new context
Options | Type | Description |
---|---|---|
--token | (string) | API token for authentication. Use this when scripting or if you don't want to use browser-based authentication. |
--namespace | (string) | Namespace of your okteto context. |
--builder | (string) | URL of the builder service |
When you run okteto context
, an account will be created for your own URL
if it's the first time you set the context in.
The CLI will exchange an authorization token with URL
and save your API token and Okteto certificates information under $HOME/.okteto/
.
Using Environment Variables to authenticate
Environment variables provide another way to specify your credentials. This is the recommended method when scripting tasks or when creating preview environments.
The supported environment variables are:
OKTETO_TOKEN
: Specifies the personal access token to useOKTETO_URL
: Specifies the Okteto URL. If missing, it defaults to https://okteto.example.com
Available subcommands: