Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 74 additions & 40 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,43 @@ If you find an issue belonging to any of the tools used by Apollo please, refer

* Submit a pull request.

## Contributing a mesos framework

We relying on Marathon and [dcos-cli-docker](https://github.com/Capgemini/dcos-cli-docker) for installing mesos frameworks via [DCOS-CLI](https://docs.mesosphere.com/using/cli/)
See [frameworks role.](https://github.com/Capgemini/Apollo/tree/master/roles/frameworks)

For providing a new mesos framework you need to add it to the frameworks list in "default/mail.yml" e.g chronos:

```
frameworks_list:
- cassandra
- chronos
```

You'll need to add a template with the required configuration for the package e.g. chronos-config.j2:

```
{
"mesos": {"master": "{{ frameworks_zk_master_peers }}"},
"chronos": {
"zk-hosts": "{{ zookeeper_peers_nodes }}",
"mem": {{ frameworks_chronos_mem }}
}
}
```

You can define the values for the config at "vars/chronos.yml". The values defined here will be overridable via environment variables, e.g

```
APOLLO_frameworks_chronos_enabled=True
```

```
frameworks_chronos_sources: '["https://github.com/Capgemini/universe/archive/develop.zip",]'
frameworks_chronos_enabled: true
frameworks_chronos_mem: 512
```


## Developing Apollo Plugins

Expand All @@ -43,23 +80,23 @@ At the moment we rely on [ansible-galaxy](http://docs.ansible.com/galaxy.html) f
ansible-galaxy init marathon
```

Write your code e.g yet another framework on top of Mesos and push it into its own git repo.
Write the code providing the add-on feature on top of Apollo and push it into its own git repo.

* Hook up a the new plugin adding your role into contrib-plugins/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 plugins.
- src: https://github.com/Capgemini/your-plugin-repo.git
path: contrib-plugins/roles
name: marathon
name: cadvisor
```

* Add the plugin into the playbook by editing contrib-plugins/playbook.yml like:

```yml
- hosts: mesos_masters
- hosts: all
roles:
- marathon
- cadvisor
```

* You can now put "contrib-plugins" folder under a control version system.
Expand All @@ -73,31 +110,28 @@ ansible-galaxy install -r contrib-plugins/plugins.yml

## 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.
* When creating a new plugin we are keen on using the ansible role for deploying services 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
# tasks for running cadvisor
- name: run cadvisor container
when: cadvisor_enabled
docker:
name: marathon
image: "{{ marathon_image }}"
name: cadvisor
image: "{{ cadvisor_image }}"
state: started
restart_policy: "{{ marathon_restart_policy }}"
restart_policy: "{{ cadvisor_restart_policy }}"
net: "{{ cadvisor_net }}"
ports:
- "{{ marathon_port }}:{{ marathon_port }}"
expose:
- "{{ marathon_port }}"
net: "{{ marathon_net }}"
command: "{{ marathon_command }}"
- "{{ cadvisor_host_port }}:8080"
hostname: "{{ cadvisor_hostname }}"
volumes:
- "{{ marathon_artifact_store_dir }}:/store"
- "/var/run/docker.sock:/tmp/docker.sock"
memory_limit: "{{ marathon_container_memory_limit }}"
env:
JAVA_OPTS: "{{ marathon_java_settings }}"
notify:
- wait for marathon to listen
- "/var/lib/docker/:/var/lib/docker:ro"
- "/:/rootfs:ro"
- "/var/run:/var/run:rw"
- "/sys:/sys:ro"
tags:
- cadvisor
```

* The variables in the role following the pattern:
Expand All @@ -109,20 +143,20 @@ 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: true
marathon_version: '0.9.0-RC3'
```
cadvisor_enabled: true
cadvisor_version: 'latest'
```

* It's usually a good idea [attach a process manager to manage it](https://docs.docker.com/articles/host_integration/)

```
description "Marathon container"
description "cadvisor container"

start on started docker
stop on stopping docker

script
/usr/bin/docker start -a marathon
/usr/bin/docker start -a cadvisor
end script

respawn
Expand All @@ -131,40 +165,40 @@ kill timeout 10
```

```yml
- name: ensure marathon is running (and enable it at boot)
when: marathon_enabled
- name: ensure cadvisor is running (and enable it at boot)
when: cadvisor_enabled
sudo: yes
service:
name: marathon
name: cadvisor
state: started
enabled: yes
tags:
- marathon
- cadvisor
```

* Your plugin must ensure state is consistent when it is disabled, e.g:
```yml
- name: ensure marathon is stopped
when: not marathon_enabled
- name: ensure cadvisor is running (and enable it at boot)
when: not cadvisor_enabled
sudo: yes
service:
name: marathon
name: cadvisor
state: stopped
enabled: yes
tags:
- marathon
- cadvisor
```

* Create Consul Healchecks

```json
{
"service": {
"name": "marathon",
"tags": [ "marathon" ],
"port": {{ marathon_port }},
"name": "cadvisor",
"tags": [ "cadvisor" ],
"port": {{ cadvisor_host_port }},
"check": {
"script": "curl --silent --show-error --fail --dump-header /dev/stderr --retry 2 http://{{ marathon_hostname }}:{{ marathon_port }}/ping",
"script": "curl --silent --show-error --fail --dump-header /dev/stderr --retry 2 http://{{ cadvisor_hostname }}:{{ cadvisor_host_port}}",
"interval": "10s"
}
}
Expand Down
1 change: 0 additions & 1 deletion bootstrap/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ open_urls() {
/usr/bin/open "${master_url}:8080"
/usr/bin/open "${master_url}:8500"
/usr/bin/open "${master_url}:4040"
/usr/bin/open "${master_url}:4400"
/usr/bin/open "${master_url}:8081"
fi
}
Expand Down
15 changes: 0 additions & 15 deletions roles/chronos/defaults/main.yml

This file was deleted.

Empty file removed roles/chronos/handlers/main.yml
Empty file.
127 changes: 0 additions & 127 deletions roles/chronos/meta/main.yml

This file was deleted.

Loading