Okteto CLI Reference

The Okteto Command Line Interface is a unified tool to manage your development environments.

Synopsis

1
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

--loglevel (debug, info, warn, error).

The amount of information outputted (defaults to warn).

Available commands

analytics

Enable / Disable analytics collection. Analytics are enabled by default.

1
okteto analytics [parameters]

Options

--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:

Please reach out to us if you have any questions or concerns about the information collected.

build

Build an image from a Dockerfile and optionally push it to a registry:

1
okteto build PATH

The okteto build command builds images tags from a Dockerfile and the context indicated by PATH. If the -t argument is specified, the image tag is also pushed to the registry. By default, images are built using the Okteto Build Service. Set the variable BUILDKIT_HOST if you want to use your own BuildKit instance.

Options

--file (string) The path to the Dockerfile file (default “PATH/Dockerfile”)
--tag (string) Name and optionally a tag in the ‘name:tag’ format (it is automatically pushed)
--target (string) Set the target build stage to build
--no-cache (string) Do not use cache when building the image
--build-args (list) Set build-time variables

doctor

Generates a doctor file with the okteto logs:

1
okteto doctor

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 environment.
  • A metadata file with information about your host machine’s OS and architecture.

The doctor file is a handy way to collect the all okteto logs. Use it when filing an issue or asking the Okteto community for help in the #okteto channel in the Kubernetes community Slack when asking for assistance.

down

Deactivates your development environment, stops the file synchronization service, and restores your previous deployment configuration.

1
okteto down

The down command should be run from the same location than okteto up.

Options

--file (string) The path to the manifest file (default “okteto.yml”)
--namespace (string) The kubernetes namespace to use (defaults to the current kube config namespace)
--volumes (bool) Remove persistent volumes where your local folder is synched on remote

exec

Executes the COMMAND in your development environment. The command will fail if there’s no active development environment corresponding to the current folder.

1
okteto exec COMMAND

For more complex commands we recommend using a double dash (--) before the command parameter.

1
okteto exec -- COMMAND

The exec command should be run from the same location than okteto up.

Options

--file (string) The path to the manifest file (default “okteto.yml”)
--namespace (string) The kubernetes namespace to use (defaults to the current kube config namespace)

help

Displays the full help.

1
okteto help

init

Automatically generates the okteto manifest file and a .stignore file. Okteto will scan the current folder and will generate a default manifest file based on your programming language and platform.

1
okteto init

Options

--file (string) The path to the manifest file to create (default “okteto.yml”)

login

Log into Okteto Cloud, and download your API token and certificates required to interact with Okteto Cloud. It defaults to Okteto Cloud, but you can specify your own Okteto Enterprise instance by specifying a URL

1
okteto login [URL]

Options

--token (string) Your Okteto API token. Use this when scripting or if you don’t want to use browser-based authentication.

When you run okteto login, an account will be created for your on URL if it’s the first time you log in. The CLI will exchange an authorization token with URL, and save your API token and Okteto Cloud certificates information under $HOME/.okteto/.

namespace

Downloads k8s credentials for a kubernetes namespace. It defaults to your personal namespace.

1
okteto namespace [namespace]

When you run okteto namespace, okteto will download the credentials for the namespace you specified, stored them in your kubeconfig file, and set the current context to it. You need to be logged in to Okteto before running this command.

push

Build, push and redeploy your source code to Kubernetes.

1
okteto push

okteto push builds a new docker image, pushes it to the registry and redeploys your containers. If you have an active development environment created by okteto up, it is also deactivated as part of the push operation. By default, images are built using the Okteto Build Service. Set the variable BUILDKIT_HOST if you want to use your own BuildKit instance.

Options

--file (string) The path to the manifest file. The manifest file indicates the deployment to push (default “okteto.yml”)
--namespace (string) The kubernetes namespace to use (defaults to the current kube config namespace)
--tag (string) The name of the image tag to build, push and redeploy. By default it is the original container image but using the tag okteto.

restart

Restarts your development environment pods corresponding to the services section of the okteto manifest. This is useful to reload configuration that cannot be hot-reloaded.

1
okteto restart

The restart command should be run from the same location than okteto up.

Options

--file (string) The path to the manifest file (default “okteto.yml”)
--namespace (string) The kubernetes namespace to use (defaults to the current kube config namespace)

status

Status of the file synchronization process:

1
okteto status

The status command should be run from the same location than okteto up.

Options

--file (string) The path to the manifest file (default “okteto.yml”)
--namespace (string) The kubernetes namespace to use (defaults to the current kube config namespace)
--info (bool) Show syncthing links for troubleshooting the synchronization service
--watch (bool) Watch for changes

up

Activate your development environment.

1
okteto up

When you run okteto up, okteto will swap the specified deployment with your development environment. A development environment is a copy of your existing kubernetes deployment with the following improvements:

  • Update your application containers with the docker image specified in the okteto manifest. This image should have the required dev tools to build, test and run your application.
  • Create a bidirectional file synchronization service to keep your changes up to date between your local filesystem and your remote containers.

Once your development environment is active, you can execute commands directly in your cluster with okteto exec. Run okteto down to restore your original deployment.

Options

--file (string) The path to the manifest file (default “okteto.yml”)
--namespace (string) The kubernetes namespace to use (defaults to the current kube config namespace)
--deploy (bool) Don’t ask for confirmation to create dev environments if deployment doesn’t exist
--pull (bool) Sets the imagePullPolicy to Always and forces the recreation of the dev environments
--reset (bool) Resets the file synchronization service. Use it if the file synchronization service stops working.

version

Displays the current installed version.

1
okteto version