Why would one create a package?
Once you get familiar with DC/OS, the open source project that was created by Mesosphere you get access to packages certified by Mesosphere. There are several ways to deploy your service into DC/OS: (1) use dcos marathon command in CLI; (2) use Marathon REST API directly; (3) deploy your service as a package. Using package approach makes your solution consistent with the environment and gives other benefits.
Please refer to documentation regarding developing your custom services and packages https://github.com/dcos/dcos-docs/blob/master/1.7/usage/developing-services/service-requirements-spec.md.
The aim of this post is to show how to create your own simple package and start using it in your DC/OS managed cluster.
You need to have DC/OS cluster up and running and DC/OS CLI installed. You can find instructions how to do this here https://dcos.io/installing.
Redis as a Package
As an example here I will create a package for vanilla Redis. It is a standalone instance that can be used by your solution. Note that there is Redis framework already in the list of DC/OS packages. While being extremely powerful this framework is not required for every solution. Sometimes all we need is a simple and lightweight service running as container.
The service you want to create a package for should have a Docker image already. For this example there is an image called redis:3.0.7.
Download this image and get it’s id
First thing to do is to take a look at the universe repo https://github.com/mesosphere/universe and create a fork. Create a branch in your fork and name it topic/single-redis.
repo/packages/R folder and create redis folder inside. Create
0 folder in that
repo/packages/R/redis folder. Create empty
config.json, marathon.json.mustache, package.json and
You should have the following tree:
Define your package.
Now it is time to actually define your package. Here are these four files we created before:
Before committing files make sure you enabled pre commit hooks as described here https://github.com/mesosphere/universe#development-set-up.
When it is done please try to commit your package. This will lead to changes in
repo/meta/index.json so you need to add it and commit your package with this json file. Push your changes to the remote.
Start using your package
Having your package published you need to add it to your DC/OS.
Use this command:
Make sure you can download this zip archive (basically the content of branch from your fork).
Now you can just run dcos package install redis. It will ask confirmation and print messages that we configured. After that your redis instance will appear in Marathon and be ready to work.
As you’ve seen in this post DC/OS makes work with containers easier and you can start running your service at scale in minutes.
djiao23 January, 2017 04:47 pm
I followed your tutorial to create a universe repo on github at https://github.com/hal-dj/hal-universe/blob/master/archive/universe-solr.zip. However after this repo is added on dcos, any "dcos package" command would give me error "Unexpected down stream http error: GET https://github.com/hal-dj/hal-universe/blob/master/archive/universe-solr.zip 406". Why is that?