Skip to content

Commit

Permalink
moving marathon out to a pluggable container
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre committed May 15, 2015
1 parent 94dce93 commit a009e26
Show file tree
Hide file tree
Showing 24 changed files with 161 additions and 226 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ ssh.config
vendor
.bundle
.kitchen
plugins
125 changes: 125 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
How to contribute
=================

Apollo is based on an strong open-source philosophy so we would love your contributions.

## Apollo Core

Apollo is built on top of several opensource tecnologies:

* [Packer](https://packer.io) for automating the build of the base images
* [Terraform](https://www.terraform.io/) for provisioning the infrastructure
* [Apache Mesos](http://mesos.apache.org/) for cluster management, scheduling and resource isolation
* [Consul](http://consul.io) for service discovery, DNS
* [Docker](http://docker.io) for application container runtimes
* [Weave](https://github.com/zettio/weave) for networking of docker containers

We want Apollo core to be as slim as possible providing a cloud agnostic Mesos cluster with an autodiscovery system based on consul for multi-service tasks.

This reduces the impact of core changes allowing the user customise Apollo behaviour via plugins for satisfying the requirements of a given project.

If you find an issue belonging to any of the tools used by Apollo please, refer to the project in question.

## Contributing to Apollo Core

* Submit an issue describing your proposed change to the Apollo repo.

* Fork the repo, develop and test your feature.

* Submit a pull request.

## Contributing to Apollo Core Plugins

* Create a new issue describing your proposed change to the plugin repo.

* Fork the repo, develop and test your feature.

* Create a pull request.

## Developing Apollo Plugins

We want Apollo to be as pluggable as possible making contributions easier via core-agnostic plugins giving them freedom and flexibility regarding isolated testing, development and release management.

A new Apollo plugin is purely an Ansible role stuck to some Apollo conventions and hooked into an Apollo deploy.

* Generate your plugin scaffolder:

At the moment we rely on [ansible-galaxy](http://docs.ansible.com/galaxy.html) for generating the plugin scaffolder, we will be providing a custom tool for generating a scaffolder for matching better the Apollo conventions soon.

```yml
ansible-galaxy init marathon
```

* Hook up a the new plugin e.g yet another framework on top of Mesos into Apollo adding your role in the plugins.yml. For more info see [advanced-control-over-role-requirements-files](http://docs.ansible.com/galaxy.html#advanced-control-over-role-requirements-files). E.g:

```yml
# Apollo core plugins.
- src: https://github.com/Capgemini/apollo-core-plugin-marathon.git
path: ./plugins
name: marathon
```
* Add the plugin into the playbook editing site.yml like:
```yml
- hosts: mesos_masters
roles:
- { role: mesos, mesos_install_mode: "master", tags: ["mesos-master"] }
- zookeeper
- { role: '../plugins/marathon' }
```
## Best practices.
* When creating a new plugin we are keen on using the ansible role for deploying Mesos frameworks inside containers so we achieve total flexibility, reusability and portabilty across operating systems.
```yml
# tasks for running docker marathon
- name: run marathon container
when: marathon_enabled == "Y"
docker:
name: marathon
image: "{{ marathon_image }}"
state: started
restart_policy: always
ports:
- "{{ marathon_port }}:{{ marathon_port }}"
net: host
command: "--master {{marathon_master_peers}} --zk {{marathon_zk_peers}}"
hostname: "{{ hostname }}"
volumes:
- "/var/run/docker.sock:/tmp/docker.sock"
```
* The variables in the role following the pattern:
```yml
pluginname_variablename: value
```
will be automatically overridable via environment variables using the pattern "APOLLO_PLUGINNAME_VARNAME". Every plugin should provide the capacity for been enabled or disabled via these variables e.g:
```yml
marathon_enabled: 'Y'
marathon_version: 'v0.8.1'
```
* Your plugin must ensure state is consistent when it is disabled, e.g:
```yml
- name: stop marathon container
when: marathon_enabled == "N"
docker:
name: marathon
image: "{{ marathon_image }}"
state: stopped
```
## Contributing a new Apollo Plugin
* Apollo gives official support only for core plugins.
* If you think your plugin should be part of Apollo core plugins please create a new issue describing your feature, and explaining the motivation.
* You can hook up your own plugins into Apollo even if they are not core plugins as explained in section above.
6 changes: 4 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
"zookeeper_servers:children" => ["mesos_masters"],
"consul_servers:children" => ["mesos_masters"],
"weave_servers:children" => ["mesos_slaves", "load_balancers"],
"marathon_servers:children" => ["mesos_masters"],
}

# Mesos master nodes
Expand All @@ -43,6 +44,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
}
end
mesos_zk_url = "zk://"+master_infos.map{|master| master[:ip]+":2181"}.join(",")+"/mesos"
marathon_zk_url = "zk://"+master_infos.map{|master| master[:ip]+":2181"}.join(",")
zookeeper_conf = master_infos.map{|master| "server.#{master[:zookeeper_id]}"+"="+master[:ip]+":2888:3888"}.join("\n")
consul_join = master_infos.map{|master| master[:ip]}.join(" ")

Expand Down Expand Up @@ -75,8 +77,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
zookeeper_conf: zookeeper_conf,
mesos_master_quorum: 2,
mesos_zk_url: mesos_zk_url,
mesos_local_address: node[:ip],
marathon_local_address: node[:ip],
marathon_zk_url: marathon_zk_url,
marathon_hostname: node[:ip],
consul_join: consul_join,
consul_advertise: node[:ip],
consul_bind_addr: node[:ip],
Expand Down
1 change: 1 addition & 0 deletions bootstrap/aws/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ verify_prereqs() {

apollo_launch() {
terraform_apply
get_ansible_requirements
ansible_ssh_config
ansible_playbook_run

Expand Down
4 changes: 4 additions & 0 deletions bootstrap/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ get_apollo_variables() {
echo ${var_list[@]}
}

get_ansible_requirements() {
ansible-galaxy install -f -n -r plugins.yml
}

check_terraform_version() {

local IFS='.'
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/digitalocean/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ TF_VAR_region=${TF_VAR_region:-lon1}
TF_VAR_key_file=${TF_VAR_key_file:?"Need to set TF_VAR_key_file non-empty"}
TF_VAR_do_token=${TF_VAR_do_token:?"Need to set TF_VAR_do_token non-empty"}

TF_VAR_atlas_artifact_master=${TF_VAR_atlas_artifact_master:-capgemini/apollo-mesos-ubuntu-14.04-amd64}
TF_VAR_atlas_artifact_slave=${TF_VAR_atlas_artifact_slave:-capgemini/apollo-mesos-ubuntu-14.04-amd64}
TF_VAR_atlas_artifact_master=${TF_VAR_atlas_artifact_master:-enxebre/apollo-mesos-ubuntu-14.04-amd64}
TF_VAR_atlas_artifact_slave=${TF_VAR_atlas_artifact_slave:-enxebre/apollo-mesos-ubuntu-14.04-amd64}
TF_VAR_atlas_artifact_version_master=${TF_VAR_atlas_artifact_version_master:-1}
TF_VAR_atlas_artifact_version_slave=${TF_VAR_atlas_artifact_version_slave:-1}

Expand Down
1 change: 1 addition & 0 deletions bootstrap/digitalocean/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ verify_prereqs() {

apollo_launch() {
terraform_apply
get_ansible_requirements
ansible_playbook_run
open_urls
}
Expand Down
1 change: 1 addition & 0 deletions bootstrap/vagrant/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ verify_prereqs() {
}

apollo_launch() {
get_ansible_requirements
vagrant up --provision
}

Expand Down
3 changes: 3 additions & 0 deletions inventory/aws/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ load_balancers
[zookeeper_servers:children]
mesos_masters

[marathon_servers:children]
mesos_masters

[consul_servers:children]
mesos_masters

Expand Down
3 changes: 3 additions & 0 deletions inventory/digitalocean/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ load_balancers
[zookeeper_servers:children]
mesos_masters

[marathon_servers:children]
mesos_masters

[consul_servers:children]
mesos_masters

Expand Down
11 changes: 0 additions & 11 deletions packer/scripts/ubuntu/install_marathon.sh

This file was deleted.

9 changes: 3 additions & 6 deletions packer/ubuntu-14.04_amd64-amis.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_ACCESS_KEY`}}",
"mesos_version": "0.22.1-1.0.ubuntu1404",
"marathon_version": "0.8.1-1.0.171.ubuntu1404",
"mesos_version": "0.22.0-1.0.ubuntu1404",
"consul_version": "0.5.0",
"weave_version": "v0.10.0",
"version": "0.2.0",
Expand All @@ -14,7 +13,7 @@
"builders": [{
"type": "amazon-ebs",
"ami_name": "apollo-mesos-ubuntu-14.04-amd64 {{timestamp}}",
"ami_description": "Ubuntu 14.04 LTS, Mesos {{user `mesos_version`}}, Docker, Marathon, Consul {{user `consul_version`}}, Weave {{user `weave_version`}}, and Zookeeper.",
"ami_description": "Ubuntu 14.04 LTS, Mesos {{user `mesos_version`}}, Docker, Consul {{user `consul_version`}}, Weave {{user `weave_version`}}, and Zookeeper.",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "{{user `aws_region`}}",
Expand All @@ -35,15 +34,13 @@
"environment_vars": [
"CONSUL_VERSION={{user `consul_version`}}",
"WEAVE_VERSION={{user `weave_version`}}",
"MESOS_VERSION={{user `mesos_version`}}",
"MARATHON_VERSION={{user `marathon_version`}}"
"MESOS_VERSION={{user `mesos_version`}}"
],
"scripts": [
"scripts/ubuntu/base.sh",
"scripts/common/sshd.sh",
"scripts/ubuntu/install_docker.sh",
"scripts/ubuntu/install_mesos.sh",
"scripts/ubuntu/install_marathon.sh",
"scripts/common/install_consul.sh",
"scripts/ubuntu/install_dnsmasq.sh",
"scripts/common/install_weave.sh"
Expand Down
8 changes: 4 additions & 4 deletions packer/ubuntu-14.04_amd64-droplet.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"digitalocean_size": "{{env `DIGITALOCEAN_SIZE`}}",
"digitalocean_image": "{{env `DIGITALOCEAN_IMAGE`}}",
"mesos_version": "0.22.1-1.0.ubuntu1404",
"marathon_version": "0.8.1-1.0.171.ubuntu1404",
"digitalocean_region": "lon1",
"digitalocean_size": "512MB",
"mesos_version": "0.22.0-1.0.ubuntu1404",
"consul_version": "0.5.0",
"weave_version": "v0.10.0",
"version": "0.2.0"
Expand All @@ -30,15 +32,13 @@
"environment_vars": [
"CONSUL_VERSION={{user `consul_version`}}",
"WEAVE_VERSION={{user `weave_version`}}",
"MESOS_VERSION={{user `mesos_version`}}",
"MARATHON_VERSION={{user `marathon_version`}}"
"MESOS_VERSION={{user `mesos_version`}}"
],
"scripts": [
"scripts/ubuntu/base.sh",
"scripts/common/sshd.sh",
"scripts/ubuntu/install_docker.sh",
"scripts/ubuntu/install_mesos.sh",
"scripts/ubuntu/install_marathon.sh",
"scripts/common/install_consul.sh",
"scripts/ubuntu/install_dnsmasq.sh",
"scripts/common/install_weave.sh"
Expand Down
7 changes: 2 additions & 5 deletions packer/ubuntu-14.04_amd64-google.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
"source_image": "{{env `GCS_SOURCE_IMAGE`}}",
"zone": "{{env `GCS_ZONE`}}",
"mesos_version": "0.22.1-1.0.ubuntu1404",
"marathon_version": "0.8.1-1.0.171.ubuntu1404",
"consul_version": "0.5.0",
"weave_version": "v0.10.0",
"version": "0.2.0"
},
"builders": [{
"type": "googlecompute",
"image_name": "apollo-mesos-ubuntu-14.04-amd64",
"image_description": "Ubuntu 14.04 LTS, Meosos {{user `mesos_version`}}, Docker, Marathon, Consul {{user `consul_version`}}, Weave {{user `weave_version`}}, and Zookeeper.",
"image_description": "Ubuntu 14.04 LTS, Meosos {{user `mesos_version`}}, Docker, Consul {{user `consul_version`}}, Weave {{user `weave_version`}}, and Zookeeper.",
"ssh_username": "ubuntu",
"ssh_timeout": "10m",
"account_file": "{{user `account_file`}}",
Expand All @@ -32,15 +31,13 @@
"environment_vars": [
"CONSUL_VERSION={{user `consul_version`}}",
"WEAVE_VERSION={{user `weave_version`}}",
"MESOS_VERSION={{user `mesos_version`}}",
"MARATHON_VERSION={{user `marathon_version`}}"
"MESOS_VERSION={{user `mesos_version`}}"
],
"scripts": [
"scripts/ubuntu/base.sh",
"scripts/common/sshd.sh",
"scripts/ubuntu/install_docker.sh",
"scripts/ubuntu/install_mesos.sh",
"scripts/ubuntu/install_marathon.sh",
"scripts/common/install_consul.sh",
"scripts/ubuntu/install_dnsmasq.sh",
"scripts/common/install_weave.sh"
Expand Down
5 changes: 1 addition & 4 deletions packer/ubuntu-14.04_amd64.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"hostname": "ubuntu",
"version": "0.2.0",
"mesos_version": "0.22.1-1.0.ubuntu1404",
"marathon_version": "0.8.1-1.0.171.ubuntu1404",
"consul_version": "0.5.0",
"weave_version": "v0.10.0",
"access_token": "{{env `ATLAS_TOKEN`}}",
Expand Down Expand Up @@ -90,8 +89,7 @@
"environment_vars": [
"CONSUL_VERSION={{user `consul_version`}}",
"WEAVE_VERSION={{user `weave_version`}}",
"MESOS_VERSION={{user `mesos_version`}}",
"MARATHON_VERSION={{user `marathon_version`}}"
"MESOS_VERSION={{user `mesos_version`}}"
],
"scripts": [
"scripts/ubuntu/base.sh",
Expand All @@ -102,7 +100,6 @@
"scripts/common/sshd.sh",
"scripts/ubuntu/install_docker.sh",
"scripts/ubuntu/install_mesos.sh",
"scripts/ubuntu/install_marathon.sh",
"scripts/common/install_consul.sh",
"scripts/ubuntu/install_dnsmasq.sh",
"scripts/common/install_weave.sh"
Expand Down
4 changes: 4 additions & 0 deletions plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Apollo core plugins.
- src: https://github.com/Capgemini/apollo-core-plugin-marathon.git
path: ./plugins
name: marathon
5 changes: 0 additions & 5 deletions roles/marathon/defaults/main.yml

This file was deleted.

6 changes: 0 additions & 6 deletions roles/marathon/handlers/main.yml

This file was deleted.

Loading

0 comments on commit a009e26

Please sign in to comment.