Skip to content

Service

Bases: DuploTenantResourceV2

Duplocloud Service Resource

This resource is used to manage services in Duplocloud. Using the duploctl command line tool, you can manage services with actions:

Basic CLI Use
duploctl service <action>

apply

Apply a service.

bulk_update_image

Bulk update the image of multiple services.

Basic CLI Use
duploctl service bulk_update_image -S <service-name-1> <image-name-1> -S <service-name-2> <image-name-2>

Parameters:

Name Type Description Default
serviceimage SERVICEIMAGE

Takes n sets of two arguments, service name and image name. e.g., -S service1 image1:tag -S service2 image2:tag

required
wait WAIT

Boolean flag to wait for service updates.

False

create

Create a service.

Create a service in Duplocloud.

Basic CLI Use

duploctl service create --file service.yaml
Contents of the service.yaml file
Name: duploctl
DockerImage: nginx:latest
Replicas: 1
Cloud: 0
IsLBSyncedDeployment: true
AgentPlatform: 7
ReplicasMatchingAsgName: null
HPASpecs: null
IsDaemonset: false
OtherDockerHostConfig: ''
OtherDockerConfig: '{"Env":null}'
NetworkId: default

Parameters:

Name Type Description Default
body BODY

The service to create.

required
wait WAIT

Wait for the service to be created.

False

Returns:

Name Type Description
message dict

Success message.

current_replicaset

Get the current replicaset for a service.

Parameters:

Name Type Description Default
name str

The name of the service to get replicaset for.

required

Returns: The current replicaset for the service. Raises: DuploError: If the service could not be found.

delete

Delete a service.

Delete a service in Duplocloud.

Basic CLI Use
duploctl service delete <service-name>

Parameters:

Name Type Description Default
name NAME

The name of the service to delete.

required

Returns:

Name Type Description
message dict

Success message.

find

Find a Service by name.

cli usage
duploctl service find <name>

Parameters:

Name Type Description Default
name NAME

The name of the Service to find.

required

Returns:

Name Type Description
resource dict

The Service object.

Raises:

Type Description
DuploError

If the {{kind}} could not be found.

image_from_body

Get the image from a service body.

Parameters:

Name Type Description Default
body dict

The body of the service.

required

Returns: The image for the service.

list

Retrieve a List of Service

cli usage
duploctl service list

Returns:

Name Type Description
list list

A list of Service.

logs

Service Logs

Get the logs for a service.

Basic CLI Use
duploctl service logs <service-name>

Args: name (str): The name of the service to get logs for. wait (bool): Whether to wait for logs to update. Returns: message: A success message.

pods

Get the pods for a service.

Parameters:

Name Type Description Default
name NAME

The name of the service to get pods for.

required

Returns: message: A list of pods for the service. Raises: DuploError: If the service could not be found.

restart

Restart a service.

Restart a service.

Basic CLI Use
duploctl service restart <service-name>

Parameters:

Name Type Description Default
name NAME

The name of the service to restart.

required

Returns:

Type Description
dict

A success message if the service was restarted successfully.

Raises:

Type Description
DuploError

If the service could not be restarted.

start

Start a service.

Start a service.

Basic CLI Use
duploctl service start <service-name>

Parameters:

Name Type Description Default
name str

The name of the service to start.

required

Returns:

Type Description
dict

A success message if the service was started successfully.

Raises:

Type Description
DuploError

If the service could not be started.

stop

Stop a service.

Stop a service.

Basic CLI Use
duploctl service stop <service-name>

Parameters:

Name Type Description Default
name str

The name of the service to stop.

required

Returns:

Type Description
dict

A success message if the service was stopped successfully.

Raises:

Type Description
DuploError

If the service could not be stopped.

update

Update a service.

Update the state of a service.

Basic CLI Use

Update the replicas to 3 for a service.

duploctl service update <service-name> --replace Replicas 3 

Parameters:

Name Type Description Default
name NAME

The name of the service to update.

required
body BODY

The body of the service to update.

None
patches PATCHES

A list of JSON patches as args to apply to the service. The options are --add, --remove, --replace, --move, and --copy. Then followed by <path> and <value> for --add, --replace, and --test.

None
wait WAIT

Whether to wait for the service to update.

False

update_env

Update the environment variables of a service. If service has no environment variables set, use -strat replace to set new values. Usage: Basic CLI Use

duploctl service update_env <service-name> --setvar env-key1 env-val1 --setvar env-key2 env-val2 --setvar env-key3 env-val3 -strat merge --host $DUPLO_HOST --tenant $DUPLO_TENANT --token $DUPLO_TOKEN
Args: name (str): The name of the service to update.

setvar/-V (list): A list of key value pairs to set as environment variables.

strategy/strat (str): The merge strategy to use for env vars. Valid options are "merge" or "replace". Default is merge.

deletevar/-D (list): A list of keys to delete from the environment variables.

update_image

Update the image of a service.

Update the image of a service.

Basic CLI Use
duploctl service update_image <service-name> <image-name>

Parameters:

Name Type Description Default
name NAME

The name of the service to update.

required
image IMAGE

The new image to use for the service.

required

Returns:

Name Type Description
message dict

Success message

update_pod_label

Update the pod labels of a service. If service has no pod labels set, use -strat replace to set new values. Usage: 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 -strat 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 -strat 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/-V: A list of key value pairs to set as environment variables. strategy/strat: The merge strategy to use for env vars. Valid options are "merge" or "replace". Default is merge. deletevar/-D: A list of keys to delete from the environment variables.

update_replicas

Scale Service

Update the number of replicas for a service.

Basic CLI Use
duploctl service update_replicas <service-name> <replicas>

Parameters:

Name Type Description Default
name str

The name of the service to update.

required
replica str

Number of replicas to set for service.

required

wait

Wait for a service to update.