cpln workload run
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
- CLI installed and authenticated with a default profile, org and gvc.
- Permissions to interact with workloads.
Options
Required
--
- Command to execute in the first workload replica (e.g.,
echo hello world
).
- Command to execute in the first workload replica (e.g.,
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
).
- The tags to append to the new workload instance (e.g.,
--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
.
- Interact directly with the new workload’s terminal after command execution. Default:
--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
).
- Set allocated CPU for the container (e.g.,
--memory
,--mem
- Set allocated memory for the container (e.g.,
128Mi
).
- Set allocated memory for the container (e.g.,
--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.
- Specify the container to run the command in, applicable only to the containers available within the workload being cloned when using the
--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
.
- Shell to use, only valid when interactive flag is set to true. Default:
--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.
- The location associated with the workload deployment (e.g.,
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:
Override Default Image
Example usage:
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:
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:
Interact With The Workload
By specifying the --interactive
option, the remote terminal session will stay open after the specified command is executed.
Example usage:
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:
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:
Other Examples
Override CPU & Memory
Override Container Command & Args
Specific Location
Make sure the specified location is part of the specified GVC. Otherwise, the workload will never be ready and the command will never execute.