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:
openfactory.openfactory_deploy_strategy.LocalDockerDeploymentStrategyIntended for development purposes when no OpenFactory cluster is available. This strategy deploys all OpenFactory services as standalone Docker containers on the local machine.
openfactory.openfactory_deploy_strategy.SwarmDeploymentStrategyThis is the default deployment strategy used in OpenFactory. It deploys services as Docker Swarm services, suitable for production or multi-node environments.
- class openfactory.openfactory_deploy_strategy.OpenFactoryServiceDeploymentStrategy[source]#
Bases:
ABCAbstract base class for OpenFactory service deployment strategies.
- abstractmethod deploy(*, image, image_pull_policy='missing', user=None, name, env, labels=None, command=None, ports=None, networks=None, constraints=None, resources=None, open_files=None, mode=None, mounts=None)[source]#
Deploy a service using the specified parameters.
- Return type:
- Parameters:
image (str) – Docker image to deploy.
image_pull_policy (str) –
Image pull behavior.
missing: Pull the image only if it is not available locally.always: Always pull the image before deployment.
user (Optional[str]) – Runtime user in Docker format
UID:GID.name (str) – Name of the service or container.
env (List[str]) – Environment variables in KEY=VALUE format.
labels (Optional[Dict[str, str]]) – Metadata labels attached to the deployed container or service.
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.
open_files (Optional[int]) – Maximum number of open file descriptors (RLIMIT_NOFILE) available to the process inside the container. If not specified, the container runtime default is used.
mode (Optional[Dict[str, Any]]) – Service mode (Swarm only).
mounts (Optional[List[dict]]) – List of Docker mount specifications.
- class openfactory.openfactory_deploy_strategy.LocalDockerDeploymentStrategy[source]#
Bases:
OpenFactoryServiceDeploymentStrategyDeployment strategy for local Docker containers (non-Swarm).
- deploy(*, image, image_pull_policy='missing', user=None, name, env, labels=None, command=None, ports=None, networks=None, constraints=None, resources=None, open_files=None, mode=None, mounts=None)[source]#
Run a local Docker container.
See parent method for argument descriptions.
- Return type:
Note
constraintsandmodeare ignored for local containers.image_pull_policy="always"forces a Docker image pull before deployment.When
open_filesis specified, anofileulimit is configured with identical soft and hard limits.If
open_filesis not specified, the Docker Engine default file descriptor limit is used.
- 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.
- swarm_mount_to_container_mount(mount_dict)[source]#
Convert a Docker Swarm-style mount dictionary to a local Docker Mount object.
- Return type:
Mount- Parameters:
mount_dict (dict) – Mount dictionary in Swarm format, as returned by
openfactory.filelayer.nfs_backend.NFSBackend.get_mount_spec().- Returns:
docker.types.Mount – A Mount object suitable for use with docker.containers.run().
Note
Supports
volumemounts only;bindmounts should be handled separately.The returned Mount preserves the target path, source name, read-only flag, and driver configuration specified in the input dictionary.
NFS-specific options (e.g.,
nfsvers=4) are already included in the mount dictionary byget_mount_spec().
- class openfactory.openfactory_deploy_strategy.SwarmDeploymentStrategy[source]#
Bases:
OpenFactoryServiceDeploymentStrategyDeployment strategy for Docker Swarm mode.
Uses the Docker Engine API directly to create services, allowing support for advanced container settings such as file descriptor limits (ulimits) that are not exposed by the high-level Docker SDK service API.
- deploy(*, image, image_pull_policy='missing', user=None, name, env, labels=None, command=None, ports=None, networks=None, constraints=None, resources=None, open_files=None, mode=None, mounts=None)[source]#
Deploy a Docker service using Docker Swarm.
See parent method for argument descriptions.
- Return type:
Note
image_pull_policyis currently ignored for Swarm deployments.When
open_filesis specified, the service is deployed with anofileulimit using identical soft and hard limits.If
open_filesis not specified, the Docker Engine default file descriptor limit is used.