cpln workload exec
Overview
The cpln workload exec command lets you execute a specific command followed by custom arguments in a workload replica at a specific location.
Prerequisites
- CLI installed and authenticated with a default profile, org and gvc.
- A running workload in at least one location. Refer to our create a workload guide.
- Permissions to interact with the workload.
Options
Required
--
- Command to execute on replica (e.g.,
echo hello world
).
- Command to execute on replica (e.g.,
Optional
--stdin
,-i
- Pass stdin to the container. Default:
false
.
- Pass stdin to the container. Default:
--tty
,-t
- Stdin is a TTY. Default:
false
.
- Stdin is a TTY. Default:
--quiet
,-q
- Only print output from the remote session. Default:
false
.
- Only print output from the remote session. 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.,
--replica
- The replica name associated with the workload deployment. Defaults to the first replica.
--container
- The container name associated with the workload deployment. Defaults to the first container.
Basic Usage
Retrieve Workload Deployments
cpln workload get-deployments WORKLOAD_NAME
This command lists available locations. Identify the location name from the output.
Usage
Example usage:
cpln workload exec WORKLOAD_NAME --location LOCATION -- COMMAND ARG1 ARG2
Advanced Usage
Specific Replica
In cases where you have more than one replica in a workload deployment and you would like to execute a command in one of them, you can provide the --replica
option followed by the replicas name.
List Replicas
cpln workload replica get WORKLOAD_NAME --location LOCATION
To override the output format, use the --output
option followed by the desired format (YAML, JSON, etc.).
Execute Within a Specific Replica
Example usage:
cpln workload exec WORKLOAD_NAME --location LOCATION --replica REPLICA_NAME -- COMMAND ARG1 ARG2
Specific Container
Within a workload where numerous containers are configured, regardless if a container is handling traffic or functioning as a sidecar, it is feasible to execute a command to it by using the --container
option.
Example usage:
cpln workload exec WORKLOAD_NAME --location LOCATION --container CONTAINER_NAME -- COMMAND ARG1 ARG2
Sending Stdin
To send stdin to a command executed within a workload, use the -i
or --stdin
option.
Example usage:
cpln workload exec WORKLOAD_NAME -i --location LOCATION --container CONTAINER_NAME -- COMMAND ARG1 ARG2
Starting an Interactive Session
To start an interactive session using the exec command, combine the -i
and -t
options (or use -it
). This allows you to run a shell command within a container interactively.
Example usage:
cpln workload exec WORKLOAD_NAME -it -- /bin/bash