Return-Path: Aries Containers is a project to manage container deployment, such as docker containers, from a Java API. Aries Containers is an Apache Aries subproject to manage container deployments, such as docker-based microservices, from a Java API. Many technologies exist to manage container deployments. Examples include Kubernetes, Marathon/Mesos, Docker Swarm, Amazon ECS
and others. While each technology provides specific features, many of these management technologies share common behaviour.
Aries Containers provides an abstraction that allows users to easily switch between these technologies. Benefits: Current modules: Current Aries Containers modules: This project may be used as input to the design process of the OSGi RFP 179. This project could influence the design process of the OSGi RFP 179. The Aries RSA source is in a separate git repository aries-containers there is also a mirror on github. To build the source, just run:Aries Containers¶
-
-
-docker.local
binding which makes it possible to run the same code with a different
-binding on a local developer machine, as long as docker is installed there.docker.local
binding which makes it possible to run the same code with using
+a local docker installation on the developer's machine.
-containers-api
- the API implemented by the various bindings.containers-docker-local
- Binding that uses the local docker installation.containers-examples
- Examples.Source¶
As an alternative, Aries Containers can also be used in a plain Java environment. Instead of obtaining the bindings from the service registry, they need to be instantiated directly in this case.
-This quick start focuses on a number of examples to suit your environment.
The OSGi example uses the Felix SCR implementation to get the currently active ServiceManager injected into a simple servlet. The servlet provides a simple UI to perform some of the management operations.
The servlet is written using OSGi Declarative Service annotations and OSGi Http Whiteboard annotations and can be found here: ServiceManagerServlet.java
-Main part of the functionality of the servlet can be summarized as follows:
+Main functionality of the servlet can be summarized as follows:
@Component(service = Servlet.class, property = {HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN + "=/manager"}) public class ServiceManagerServlet extends HttpServlet { @@ -348,7 +347,7 @@ protected void doGet(HttpServletRequestIn short - an OSGi Declarative Service Component is registered as a HTTP Whiteboard Servet. The Aries Containers Service Manager is injected into the
serviceManager
field and then used in the servlet to manage services.This demo can be launched in any OSGi framework that supports Declarative Services and the HTTP Whiteboard. For example, to run this demo -Apache Felix, add:
+with the Apache Felix OSGi framework, add:
Finally add the OSGI demo bundle itself. The resulting bundle list will look like this:
+Finally add the OSGi demo bundle itself. The resulting bundle list will look like this:
lb START LEVEL 1 ID|State |Level|Name @@ -386,11 +385,18 @@ Apache Felix, add:
Now you can access the servlet at http://localhost:8080/containers/manager
+Now you can access the servlet at http://localhost:8080/containers/manager
+After adding a container you can inspect its result by querying docker
for its running containers:
$ docker ps +CONTAINER ID IMAGE COMMAND STATUS PORTS NAMES +7cc5c753777e httpd "httpd-foreground" Up 4 seconds 0.0.0.0:51467->80/tcp myapache +
This example launches a small Java Application to create a service deployment. Initially a single container is deployed. The user can -modify the number of replicas using the application.
+modify the number of replicas from within the application.The code can be found here: Main.java
The main functionality is:
ServiceManager sm = new LocalDockerServiceManager(); @@ -417,7 +423,7 @@ modify the number of replicas using theDocker Local¶
This binding works by issuing
-docker
commands on the local machine and is very useful for testing. Make sure the environment variables normally provided viadocker-machine env <myenv>
are set.OSGi ServiceManager identifier:
+container.factory.binding = docker.local
OSGi ServiceManager identifier property:
container.factory.binding = docker.local
Constructor, for use outside of OSGi:
org.apache.aries.containers.docker.local.impl.LocalDockerServiceManager
Marathon¶
This binding uses Marathon as the underlying container manager. It requires the following configuration to be set:
@@ -426,8 +432,8 @@ variables normally provided viado
Once configured, the Marathon binding will register its OSGi service.
-OSGi ServiceManager identifier: container.factory.binding = marathon
Once configured, the Marathon binding will register its OSGi service.
+OSGi ServiceManager identifier property: container.factory.binding = marathon
Constructors, for use outside of OSGi: org.apache.aries.containers.marathon.impl.MarathonServiceManager
/** * Create the Marathon Service Manager.