OpenFactory Deployment Strategies#

OpenFactory Assets are deployed on the OpenFactory cluster using one of the deployment strategy classes listed below. These classes inherit from the abstract base class openfactory.openfactory_deploy_strategy.OpenFactoryServiceDeploymentStrategy.

Currently, two deployment strategies are implemented:

class openfactory.openfactory_deploy_strategy.OpenFactoryServiceDeploymentStrategy[source]#

Bases: ABC

Abstract base class for OpenFactory service deployment strategies.

abstractmethod deploy(*, image, name, env, labels=None, command=None, ports=None, networks=None, constraints=None, resources=None, mode=None, mounts=None)[source]#

Deploy a service using the specified parameters.

Return type:

None

Parameters:
  • image (str) – Docker image to deploy.

  • name (str) – Name of the service or container.

  • env (List[str]) – Environment variables in KEY=VALUE format.

  • labels (Optional[Dict[str, str]]) – Metadata labels (Swarm only).

  • command (Optional[str]) – Command to override the default entrypoint.

  • ports (Optional[Dict[int, int]]) – Port mappings from host to container (host:container).

  • networks (Optional[List[str]]) – Networks to connect the service or container to.

  • constraints (Optional[List[str]]) – Constraints for placement (Swarm only).

  • resources (Optional[Dict[str, Any]]) – Resource limits and reservations.

  • mode (Optional[Dict[str, Any]]) – Service mode (Swarm only).

  • mounts (Optional[List[dict]]) – List of Docker mount specifications.

abstractmethod remove(service_name)[source]#

Remove a service.

Parameters:

service_name (str) – Service to be removed.

class openfactory.openfactory_deploy_strategy.LocalDockerDeploymentStrategy[source]#

Bases: OpenFactoryServiceDeploymentStrategy

Deployment strategy for local Docker containers (non-Swarm).

deploy(*, image, name, env, labels=None, command=None, ports=None, networks=None, constraints=None, resources=None, mode=None, mounts=None)[source]#

Run a local Docker container.

See parent method for argument descriptions.

Return type:

None

Note

  • Only the first network in the list is used.

  • constraints and mode are ignored for local containers.

remove(service_name)[source]#

Remove a Docker container.

Parameters:

service_name (str) – Docker container to be removed.

Raises:
  • docker.errors.NotFound – If the container does not exist.

  • docker.errors.APIError – If removal fails due to a Docker API issue.

class openfactory.openfactory_deploy_strategy.SwarmDeploymentStrategy[source]#

Bases: OpenFactoryServiceDeploymentStrategy

Deployment strategy for Docker Swarm mode.

deploy(*, image, name, env, labels=None, command=None, ports=None, networks=None, constraints=None, resources=None, mode=None, mounts=None)[source]#

Deploy a Docker service using Docker Swarm.

See parent method for argument descriptions.

Return type:

None

remove(service_name)[source]#

Remove a Docker service from a Docker Swarm cluster.

Parameters:

service_name (str) – Docker swarm service to be removed.