Overview

The cpln workload run command lets you run a specific command followed by custom arguments in a new workload instance. The CLI will wait for the new workload instance to be healthy and will then execute the specified command in the first workload replica and first container. The workload run command starts an interactive session with the first replica of the workload and execute the specified command.

Prerequisites

Options

Required

  • --
    • Command to execute in the first workload replica (e.g., echo hello world).
This option must always be defined at the end of the command.

Optional

  • --clone
    • The designated workload to clone and run the command within its cloned instance.
  • --tag
    • The tags to append to the new workload instance (e.g., --tag drink=water).
  • --image
    • The image intended to replace the image currently associated with the new workload instance.
  • --interactive, --i
    • Interact directly with the new workload’s terminal after command execution. Default: false.
  • --remove, --rm
    • Specifying this will perform a cleanup, where it will delete the new workload instance after the command execution.
  • --cpu
    • Set allocated CPU for the container (e.g., 50m).
  • --memory, --mem
    • Set allocated memory for the container (e.g., 128Mi).
  • --container
    • Specify the container to run the command in, applicable only to the containers available within the workload being cloned when using the --clone option. Defaults to first container.
  • --command, -c
    • Set container command.
  • --arg, -a
    • Set container args.
  • --shell, -s
    • Shell to use, only valid when interactive flag is set to true. Default: bash.
  • --location
    • The location associated with the workload deployment (e.g., aws-us-west-1). Defaults to the first location fetched from the specified GVC. When specifying, make sure that the specified location is part of the specified GVC.

Default Behavior

When specifying the command to execute, the workload run command will reate a new standard workload based on the ubuntu:22.04 image, wait for it to be healthy, and will execute the specified command within the workload replica and then exit.

Example usage:

cpln workload run -- COMMAND

Override Default Image

Example usage:

cpln workload run --image IMAGE_TAG -- COMMAND

Clone & Run Command in a Specific Workload

By specifying the --clone option, the specified workload will be cloned with the same specs. The workload run command will wait for the new cloned workload instance to be healthy, execute the specified command within the first workload replica, and then exit.

Example usage:

cpln workload run --clone WORKLOAD_NAME -- COMMAND

With a Specific Container

If there is more than one running container in the new workload instance and you wish to run a specific command within it, you can provide the name of the container to the --container option.

Example usage:

cpln workload run --clone WORKLOAD_NAME --container CONTAINER_NAME -- COMMAND

Interact With The Workload

By specifying the --interactive option, the remote terminal session will stay open after the specified command is executed.

Example usage:

cpln workload run --interactive -- COMMAND

With a Specific Shell

By default, the workload run command attempts to initiate an interactive bash session; if unavailable, it sequentially tries zsh, then sh. If all attempts fail, an interactive session cannot be established, and the specified command will not execute.

To override the default shell, specify one with the --shell option.

Example usage:

cpln workload run --interactive --shell SHELL_NAME -- COMMAND

Perform Cleanup

If you wish for the newly created workload instance to be deleted after the command is executed, pass the --remove or the --rm option to the workload run command.

Example usage:

cpln workload run --remove -- COMMAND

Other Examples

Override CPU & Memory

cpln workload run --cpu 75m --memory 150Mi -- ls -al

Override Container Command & Args

cpln workload run --command sleep --arg "999d" -- ls -al

Specific Location

cpln workload run --location aws-eu-central-1 -- ls -al

Make sure the specified location is part of the specified GVC. Otherwise, the workload will never be ready and the command will never execute.

Append Tags

cpln workload run --tag drink=water -- ls -al