Service
Commands
apply
Apply a service.
Parameters:
--file, -f, --cli-input
--wait, -w
bulk_update_image
Bulk Update Images
Bulk update the image of multiple services.
Basic CLI Use
Returns:
| Name | Type | Description |
|---|---|---|
message |
dict
|
A message about success. |
Parameters:
--serviceimage, -S
repeatable
create
Create a service.
Create a service in Duplocloud.
Basic CLI Use
Contents of theservice.yaml file
Name: duploctl
DockerImage: nginx:latest
Replicas: 1
Cloud: 0
IsLBSyncedDeployment: true
AgentPlatform: 7
ReplicasMatchingAsgName: null
HPASpecs:
maxReplicas: 3
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 2
IsDaemonset: false
OtherDockerHostConfig: ''
OtherDockerConfig: '{"Env":null}'
NetworkId: default
Create and Wait
Use the global --wait flag to wait for the service to be created and all replicas in a ready status.
Returns:
| Name | Type | Description |
|---|---|---|
message |
dict
|
Success message. |
Parameters:
--file, -f, --cli-input
delete
expose
Expose a service.
Exposes a service through a load balancer. Attaches a Duplocloud service lb configuration to the service.
Basic CLI Use
Returns:
| Type | Description |
|---|---|
dict
|
A success message indicating the exposure status. |
Raises:
| Type | Description |
|---|---|
DuploError
|
If the service could not be exposed. |
Parameters:
name
positional
--container-port, --container-port
--external-port, --external-port
--lb-type, --lb-type
applicationlb
k8clusterip
k8nodeport
networklb
targetgrouponly
--protocol, --protocol
http
https
tcp
udp
tls
--visibility, --visibility
public
private
--mode, --mode
docker-mode
native-app
--health-check-url, --health-check-url
find
list
logs
Service Logs
Get the logs for a service. This will be an aggregate of all logs from the pods. The pod names will be prefixed on each line.
Get the logs for a service.
Watch Logs
This command supports the global --wait. Waits and watches for new logs. As new logs come they are printed to the console. Use ctrl+c to stop watching.
Returns:
| Name | Type | Description |
|---|---|---|
logs |
dict
|
A big list of logs. |
Parameters:
name
positional
pods
Get Pods
Get a list of all of the pods owned by this service.
Returns:
| Name | Type | Description |
|---|---|---|
message |
dict
|
A list of pods for the service. |
Raises:
| Type | Description |
|---|---|
DuploError
|
If the service could not be found. |
Parameters:
name
positional
restart
Restart a service.
Restart a service. Cause kubernetes to do a full rollover of it's replicaset. This does honor the deployment strategy settings.
Wait for Restart
This command supports the global --wait. Waits for the desired count of pods to become ready.
Returns:
| Name | Type | Description |
|---|---|---|
message |
dict
|
A success message if the service was restarted successfully. |
Raises:
| Type | Description |
|---|---|
DuploError
|
If the service could not be restarted. |
Parameters:
name
positional
rollback
Rollback Service
Roll back a service to a specific revision (if provided) or the last known good state.
Usage
Returns:
| Name | Type | Description |
|---|---|---|
message |
dict
|
A success message indicating the rollback status. |
Raises:
| Type | Description |
|---|---|
DuploError
|
If the service could not be rollback. |
Parameters:
name
positional
--revision, --to-revision
start
Start a service.
Start a service.
Basic CLI Use
Wait for Start
This command supports the global --wait. Waits for the desired count of pods to become ready.
Returns:
| Type | Description |
|---|---|
dict
|
A summary containing services that were started successfully and those that encountered errors. |
Raises:
| Type | Description |
|---|---|
DuploError
|
If the service could not be started. |
Parameters:
name
positional
--all, --all
--targets, --targets
stop
Stop a service.
Stop a service.
Basic CLI Use
Wait for Stop
This command supports the global --wait. Waits for all pods to disappear.
Returns:
| Type | Description |
|---|---|
dict
|
A summary containing services that were stopped successfully and those that encountered errors. |
Raises:
| Type | Description |
|---|---|
DuploError
|
If the service could not be stopped. |
Parameters:
name
positional
--all, --all
--targets, --targets
update
Update a service.
Update the state of a service.
Basic CLI Use
Update the replicas to 3 for a service.
Parameters:
name
positional
--file, -f, --cli-input
--patches, --add, --remove, --copy, --replace, --test, --move
update_env
Update environment variables
Updates the environment variables of a service. If service has no environment variables set, use -strat replace to set new values. You may pass any number of --setvar flags to set multiple environment variables.
Basic CLI Use
Example: Update all environment variables All variables for the service would be replaced by the variables in the command. This is a full state refresh.
Parameters:
name
positional
--setvar, -V
repeatable
--strategy, -strat
merge
replace
--deletevar, -D
repeatable
update_image
Update the image of a service.
Basic CLI Use
Update Image and Wait
Waits till the desired count of pods all reach the running state with the new image.
Returns:
| Name | Type | Description |
|---|---|---|
message |
dict
|
Success message |
Parameters:
name
positional
image
positional
--container-image, --container-image
repeatable
--init-container-image, --init-container-image
repeatable
update_otherdockerconfig
Update Other Docker Config of a service.
Add a new secret reference to OtherDockerConfig:
Replace existing OtherDockerConfig:
Returns:
| Name | Type | Description |
|---|---|---|
message |
dict
|
Success message. |
Parameters:
name
positional
--patches, --add, --remove, --copy, --replace, --test, --move
update_pod_label
Update pod labels
Updates the labels on the pod of a service. If service has no pod labels set, use -strat replace to set new values.
Basic CLI Use
duploctl service update_pod_label <service-name> --setvar env-key1 env-val1 --setvar env-key2 env-val2 --setvar env-key3 env-val3 --strategy merge --host $DUPLO_HOST --tenant $DUPLO_TENANT --token $DUPLO_TOKEN
duploctl service update_pod_label <service-name> --setvar env-key1 env-val1 --setvar env-key2 env-val2 --strategy replace --host $DUPLO_HOST --tenant $DUPLO_TENANT --token $DUPLO_TOKEN
duploctl service update_pod_label <service-name> --deletevar env-key1 --host $DUPLO_HOST --tenant $DUPLO_TENANT --token $DUPLO_TOKEN
Args: name: The name of the service to update. setvar: A list of key value pairs to set as environment variables. strategy: The merge strategy to use for env vars. Valid options are "merge" or "replace". Default is merge. deletevar: A list of keys to delete from the environment variables.
Returns:
| Name | Type | Description |
|---|---|---|
message |
A message about success. |
Parameters:
name
positional
--setvar, -V
repeatable
--strategy, -strat
merge
replace
--deletevar, -D
repeatable
update_replicas
Scale Service
Update the number of replicas for a service.
Wait for Scaling
The update replicas supports the global --wait flag. This will wait till the number of pods match the desired count.
Parameters:
name
positional
--replicas, -r
Methods
current_replicaset
Get the current replicaset for a service.
Finds the name of the underlying replicaset for a named service.
info
This is not a cli command. It's primarily used internally but could be useful in a custom script.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the service to get replicaset for. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The current replicaset for the service. |
Raises:
| Type | Description |
|---|---|
DuploError
|
If the service could not be found. |
image_from_body
Get the image from a service body.
info
This is not a cli command. It's primarily used internally but could be useful in a custom script.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
dict
|
The body of the service. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
image |
str
|
The image for the service. |
name_from_body
Service name from body.
Simply returns the services name given an entire service object.
info
This is not a cli command. It's primarily used internally but could be useful in a custom script.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
dict
|
The service object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the service. |