Skip to content

Commit c617253

Browse files
authored
Merge pull request #21 from singularityhub/add/paper
Add/paper
2 parents e64a68b + 02a346e commit c617253

File tree

3 files changed

+313
-0
lines changed

3 files changed

+313
-0
lines changed

paper/paper.bib

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
@ARTICLE{Kurtzer2017-xj,
2+
title = "Singularity: Scientific containers for mobility of compute",
3+
author = "Kurtzer, Gregory M and Sochat, Vanessa and Bauer, Michael W",
4+
abstract = "Here we present Singularity, software developed to bring
5+
containers and reproducibility to scientific computing. Using
6+
Singularity containers, developers can work in reproducible
7+
environments of their choosing and design, and these complete
8+
environments can easily be copied and executed on other
9+
platforms. Singularity is an open source initiative that
10+
harnesses the expertise of system and software engineers and
11+
researchers alike, and integrates seamlessly into common
12+
workflows for both of these groups. As its primary use case,
13+
Singularity brings mobility of computing to both users and HPC
14+
centers, providing a secure means to capture and distribute
15+
software and compute environments. This ability to create and
16+
deploy reproducible environments across these centers, a
17+
previously unmet need, makes Singularity a game changing
18+
development for computational science.",
19+
journal = "PLoS One",
20+
doi = "journal.pone.0177459",
21+
publisher = "Public Library of Science",
22+
volume = 12,
23+
number = 5,
24+
pages = "e0177459",
25+
month = "11~" # may,
26+
year = 2017
27+
}
28+
29+
30+
@Software{SingularityCompose,
31+
title = "singularity-compose",
32+
booktitle = "Singularity Compose",
33+
author = "Sochat, Vanessa",
34+
abstract = "orchestration tool for Singularity container instances",
35+
howpublished = "\url{https://singularityhub.github.io/singularity-compose}",
36+
note = "Accessed: 2019-6-24"
37+
}
38+
39+
40+
@Software{SingularityComposeGithub,
41+
title = "Singularity Compose Github",
42+
booktitle = "Singularity Compose Github",
43+
author = "Sochat, Vanessa",
44+
abstract = "open source code for singularity-compose",
45+
howpublished = "\url{https://github.com/singularityhub/singularity-compose}",
46+
note = "Accessed: 2019-6-24"
47+
}
48+
49+
50+
51+
@MISC{DockerCompose,
52+
title = "Docker Compose",
53+
booktitle = "Docker Documentation",
54+
abstract = "Introduction and Overview of Compose",
55+
month = jun,
56+
year = 2019,
57+
howpublished = "\url{https://docs.docker.com/compose/}",
58+
note = "Accessed: 2019-6-24"
59+
}
60+
61+
62+
@Software{SingularityComposeExamples,
63+
title = "Singularity Compose Examples",
64+
booktitle = "Singularity Compose Examples",
65+
author = "Sochat, Vanessa",
66+
abstract = "open source examples for singularity-compose",
67+
howpublished = "\url{https://github.com/singularityhub/singularity-compose-examples}",
68+
note = "Accessed: 2019-6-24"
69+
}
70+
71+
@MISC{Merkel2014-da,
72+
title = "Docker: Lightweight Linux Containers for Consistent Development
73+
and Deployment",
74+
author = "Merkel, Dirk",
75+
journal = "Linux J.",
76+
publisher = "Belltown Media",
77+
volume = 2014,
78+
number = 239,
79+
month = mar,
80+
year = 2014,
81+
address = "Houston, TX"
82+
}
83+
84+
85+
@MISC{Wikipedia_contributors2019-bw,
86+
title = "Kubernetes",
87+
booktitle = "Wikipedia, The Free Encyclopedia",
88+
author = "{Wikipedia contributors}",
89+
abstract = "Kubernetes (commonly stylized as k8s[3]) is an open-source
90+
container-orchestration system for automating application
91+
deployment, scaling, and management.[4] It was originally
92+
designed by Google, and is now maintained by the Cloud Native
93+
Computing Foundation. It aims to provide a ``platform for
94+
automating deployment, scaling, and operations of application
95+
containers across clusters of hosts''.[3] It works with a
96+
range of container tools, including Docker.[5] Many cloud
97+
services offer a Kubernetes-based platform or infrastructure
98+
as a service (PaaS or IaaS) on which Kubernetes can be
99+
deployed as a platform-providing service. Many vendors also
100+
provide their own branded Kubernetes distributions.",
101+
month = jun,
102+
year = 2019,
103+
howpublished = "\url{https://en.wikipedia.org/w/index.php?title=Kubernetes&oldid=903021989}",
104+
note = "Accessed: 2019-6-24"
105+
}
106+
107+
@MISC{SingularityInstances,
108+
title = "Running Services --- Singularity container 3.2 documentation",
109+
howpublished = "\url{https://sylabs.io/guides/3.2/user-guide/running_services.html?highlight=instances}",
110+
note = "Accessed: 2019-6-24"
111+
}
112+
113+
114+
@MISC{Meyer2019-sd,
115+
title = "Sylabs Slides Singularity Updates Into Its Enterprise Pro
116+
Package",
117+
booktitle = "{SDxCentral}",
118+
author = "Meyer, Dan",
119+
abstract = "Sylabs pushed out an update to its enterprise-focused
120+
SingularityPRO container platform that takes advantage of its
121+
3.x launch.",
122+
month = apr,
123+
year = 2019,
124+
howpublished = "\url{https://www.sdxcentral.com/articles/news/sylabs-slides-singularity-updates-into-its-enterprise-pro-package/2019/04/}",
125+
note = "Accessed: 2019-6-24"
126+
}

paper/paper.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
---
2+
title: 'Singularity Compose: Orchestration for Singularity Instances'
3+
tags:
4+
- containers
5+
- singularity
6+
- linux
7+
- orchestration
8+
authors:
9+
- name: Vanessa Sochat
10+
orcid: 0000-0002-4387-3819
11+
affiliation: 1
12+
affiliations:
13+
- name: Stanford University Research Computing
14+
index: 1
15+
date: 24 June 2019
16+
bibliography: paper.bib
17+
---
18+
19+
# Summary
20+
21+
Singularity Compose is an orchestration tool for Singularity container instances.
22+
23+
![Singularity Compose](singularity-compose.png)
24+
25+
The Singularity container technology started to become popular in 2016,
26+
as it offered a more secure option to run encapsulated environments [@Kurtzer2017-xj].
27+
Traditionally, this meant that Singularity users could run a script built into the container
28+
(called a runscript), execute a custom command, or shell into a container.
29+
Unlike Docker [@Merkel2014-da], these basic interactions simply interacted with processes in the
30+
foreground (e.g., running a script and exiting) and were not appropriate to run
31+
background services. This was a task for container instances [@SingularityInstances].
32+
33+
A container instance [@SingularityInstances] equates to running a container in a detached or
34+
daemon mode. Instances allow for running persistent services in the background,
35+
and then interaction with these services from the host and other containers.
36+
Examples of services include databases, web servers, and associated applications
37+
that interact with them. While a container technology can provide command line
38+
and other programmatic interfaces for interaction with instances, what is also needed
39+
is a configuration file for orchestration and customization of several instances.
40+
For sibling container technology Docker, Docker Compose [@DockerCompose] was developed
41+
for this purpose. For local and production usage, the user could create a `docker-compose.yml`
42+
file to define services, volumes, ports exposed, and other customizations to networking and environment
43+
[@DockerCompose]. Notably, there was strong incentive for the development of such a tool,
44+
because Docker Compose existed before Kubernetes was available in the middle of 2015 [@Wikipedia_contributors2019-bw].
45+
46+
No equivalent orchestration tool was created for Singularity container
47+
instances. While Singularity has empowered enterprise users to run
48+
services via platforms such as Kubernetes [@Meyer2019-sd], these platforms come
49+
with privilege. It is often the case that a production Kubernetes cluster is not
50+
readily available to a user via his or her institution, or that the user
51+
cannot pay a cloud provider to deploy one. However, this does not imply that
52+
a non enterprise user (e.g., an open source developer
53+
or academic) would not benefit from such an orchestration tool. Unfortunately,
54+
since the current trend and strongest potential for making profits is centered
55+
around encouraging usage of enterprise tools like Kubernetes [@Wikipedia_contributors2019-bw],
56+
there is not any urgent incentive on part of the provider companies to
57+
invest in a non-enterprise orchestration tool. It is logical, rational, and
58+
understandable that companies exist to make profit, and must make profit
59+
to exist. As the need is unfulfilled, it is the responsibility of the open source community to step up.
60+
61+
62+
## Singularity Compose
63+
64+
The solution for orchestration of container instances from the open source
65+
community is Singularity Compose [@SingularityCompose]. Singularity Compose
66+
is software for non enterprise users to easily create a configuration file to
67+
control creation and interaction of Singularity container instances.
68+
It allows for the creation of a `singularity-compose.yml` file, in which
69+
the user can define one or more container services, optionally with exposed ports
70+
and volumes on the host. The user can easily define a container binary
71+
to build or pull from a remote resource, along with custom scripts to
72+
run after creation of the instances. Singularity Compose handles designation
73+
of addresses on a local bridge network for each container, and creation of
74+
resource files to bind to the containers to "see" one another.
75+
Importantly, by way of adding a Singularity Compose to a repository,
76+
a user is ensuring not just reproducibility of a container recipe, but also
77+
reproducibility of it's build and creation of services. For example, a simplified
78+
version of a sequence of steps to build two containers and bring them up
79+
as instances might look like this:
80+
81+
```bash
82+
$ sudo singularity build app/app.sif app/Singularity
83+
$ sudo singularity build nginx/nginx.sif nginx/Singularity.nginx
84+
85+
$ singularity instance start \
86+
--bind nginx.conf:/etc/nginx/conf.d/default.conf \
87+
--bind nginx/uwsgi_params.par:/etc/nginx/uwsgi_params.par \
88+
--bind nginx/cache:/var/cache/nginx \
89+
--bind nginx/run:/var/run \
90+
--bind app:/code \
91+
--bind static:/var/www/static \
92+
--bind images:/var/www/images \
93+
--bind etc.hosts:/etc/hosts \
94+
--net --network-args "portmap=80:80/tcp" --network-args "IP=10.22.0.2" \
95+
--hostname nginx --writable-tmpfs nginx/nginx.sif nginx
96+
97+
$ singularity instance start \
98+
--bind app:/code \
99+
--bind static:/var/www/static \
100+
--bind images:/var/www/images \
101+
--bind etc.hosts:/etc/hosts \
102+
--net --network-args "portmap=8000:8000/tcp" --network-args "IP=10.22.0.3" \
103+
--hostname app --writable-tmpfs app/app.sif app
104+
105+
$ singularity instance list
106+
```
107+
108+
This is a complicated set of commands. In the above, we
109+
first build the two containers. There are no checks here if the recipes
110+
exist, or if the containers themselves already exist.
111+
We then start instances for them. If we save these commands in a file,
112+
we need to consistently hard code the paths to the container binaries,
113+
along with the ip addresses, hostnames, and volumes. There are no checks
114+
done before attempting the creation if the volumes meant to be bound
115+
actually exist. We also take for granted that we've already generated an
116+
`etc.hosts` file to bind to the container at `/etc/hosts`, which will
117+
define the container instances to have the same names supplied with `--hostname`.
118+
For the networking, we have to be mindful of the default bridge provided by Singularity,
119+
along with how to specify networking arguments under different conditions.
120+
This entire practice is clearly tedious. For a user to constantly need to generate and then
121+
re-issue these commands, it's not a comfortable workflow. However,
122+
with Singularity Compose, the user writes a `singularity-compose.yml`
123+
file once:
124+
125+
```yaml
126+
version: "1.0"
127+
instances:
128+
129+
nginx:
130+
build:
131+
context: ./nginx
132+
recipe: Singularity.nginx
133+
volumes:
134+
- ./nginx.conf:/etc/nginx/conf.d/default.conf
135+
- ./uwsgi_params.par:/etc/nginx/uwsgi_params.par
136+
- ./nginx/cache:/var/cache/nginx
137+
- ./nginx/run:/var/run
138+
ports:
139+
- 80:80
140+
depends_on:
141+
- app
142+
volumes_from:
143+
- app
144+
145+
app:
146+
build:
147+
context: ./app
148+
volumes:
149+
- ./app:/code
150+
- ./static:/var/www/static
151+
- ./images:/var/www/images
152+
ports:
153+
- 8000:8000
154+
```
155+
156+
And then can much more readily see and reproduce generation of the same services.
157+
The user can easily build all non-existing containers, and bring up all services
158+
with one command:
159+
160+
```bash
161+
$ singularity-compose up
162+
```
163+
164+
And then easily bring services down, restart, shell into a container, execute
165+
a command to a container, or run a container's internal runscript.
166+
167+
```bash
168+
$ singularity-compose down # stop services
169+
$ singularity-compose restart # stop and start services
170+
$ singularity-compose shell app # shell into an instance
171+
$ singularity-compose exec app "Hello!" # execute a command
172+
$ singularity-compose run app # run internal runscript
173+
```
174+
175+
These interactions greatly improve both reproducibility and running of
176+
any development workflow that is not appropriate for an enterprise cluster but
177+
relies on orchestration of container instances.
178+
179+
For the interested reader, the complete documentation for Singularity Compose [@SingularityCompose]
180+
is provided, along with the code on GitHub [@SingularityComposeGithub]. For
181+
additional walkthroughs and complete examples, we direct the reader to the examples
182+
repository, also on GitHub [@SingularityComposeExamples]. Contribution by way
183+
of additional examples, questions, or requests for development of a new example
184+
are appreciated and welcome.
185+
186+
187+
# References

paper/singularity-compose.png

130 KB
Loading

0 commit comments

Comments
 (0)