Skip to content

Commit

Permalink
Merge pull request #23 from mesos/docs/upgrade-mesos-starter
Browse files Browse the repository at this point in the history
Initial public release based upon MesosFramework
  • Loading branch information
Phil Winder committed Mar 21, 2016
2 parents 7f0e5dc + 29a82c2 commit 4328d8c
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 32 deletions.
43 changes: 26 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
This uses the [Mesos-Framework](https://github.com/ContainerSolutions/mesosframework) project. The framework is generic and only becomes a Kibana framework with the correct configuration.

# Features
(Features come from the [Mesos-Starter](https://github.com/ContainerSolutions/mesos-starter) project)
(Features come from the upstream [Mesos-Framework](https://github.com/ContainerSolutions/mesosframework) and [Mesos-Starter](https://github.com/ContainerSolutions/mesos-starter) projects)

- [x] State stored in ZooKeeper
- [x] Mesos Authorisation
- [ ] ZooKeeper Authorisation
- [ ] Live horizontal scaling
- [/] ZooKeeper Authorisation (should work, requires testing)
- [x] Live horizontal scaling via REST endpoint
- [x] Jar mode (no docker)
- [x] Resource specification (including port)
- [x] Import Kibana.yml settings file
- [x] "Spread" orchestration strategy (Spreads instances across distinct hosts)
- [x] Decoupled from Kibana. Use any version.
- [ ] Decoupled from Mesos. Use any version 0.25+.
- [x] Decoupled from Mesos. Use any version 0.25+.
- [x] Single endpoint to check health of all instances

# Usage
Expand All @@ -43,11 +43,11 @@ All settings are written in properties or argument format. Remember that these c
| `mesos.zookeeper.server` | IP:PORT of the zookeeper server |
| `mesos.resources.cpus` | CPUs allocated to the task |
| `mesos.resources.mem` | RAM allocated to the task |
| `mesos.resources.scale` | Number of task instances |
| `mesos.resources.ports.${VAR}` | A requested port, where VAR is the name of the port |
| `mesos.resources.count` | Number of task instances |
| `mesos.resources.ports.${VAR}.host` | A requested port, where VAR is the name of the port. |
| `mesos.resources.ports.${VAR}.container` | When in bridge mode, the container port to map the host port to. |
| `mesos.docker.image` | Docker image to use |
| `mesos.docker.network` | Type of docker network |
| `mesos.docker.parameter.${VAR}` | Any "double-dash" Docker parameter, where VAR is the name of the parameter |
| `mesos.command` | The command to run |
| `mesos.uri[0..]` | Files to download into the Mesos sandbox |
| `logging.level.com.containersolutions.mesos` | Logging level |
Expand Down Expand Up @@ -78,9 +78,10 @@ mesos.command=mv $MESOS_SANDBOX/kibana.yml /opt/kibana/config/kibana.yml ; kiban
### Port allocation
Ports are allocated by Mesos and provided to the application as an environmental variable. For example:
```
mesos.resources.ports.UI_5061=ANY
mesos.resources.ports.UI_5061.host=ANY
mesos.resources.ports.UI_5061.container=5601
```
Assigns an unprivileged port to the environmental variable `UI_5061`. This environmental variable can now be use in the `mesos.command` or `mesos.docker.parameter.${VAR}`.
Assigns an unprivileged port to the environmental variable `UI_5061`. This environmental variable can now be use in the `mesos.command`, if required.

The value can be one of the following types:

Expand All @@ -91,18 +92,26 @@ The value can be one of the following types:
| `PRIVILEGED` | The next available privileged port (<=1024) |
| `1234` | A specific port (e.g. 1234) |

### Passing extra Docker parameters
It is possible to pass task custom Docker parameters. For example:
```
mesos.docker.parameter.expose=$UI_5061
mesos.docker.parameter.env=["CUSTOM_ENV=hello!"]
```
Will result in a Docker command that looks like: `docker run --expose=1234 --env=["CUSTOM_ENV=hello!"] ...`. The environmental variable `$UI_5061` has been expanded.
## Health checks
[Mesos-Framework](https://github.com/ContainerSolutions/mesosframework) uses Spring Actuator to provide health and metrics endpoints. To access the health endpoint visit: `http://${SCHEDULER_IP_ADDRESS}:${server.port}/health`. Acuator defaults the `server.port` to 8080, although it is recommended to reserve ports in the marathon command and set this port explicitly. E.g. [jar mode json file](./manual-tests/marathon-jar.json)
[MesosFramework](https://github.com/ContainerSolutions/mesosframework) uses Spring Actuator to provide health and metrics endpoints. To access the health endpoint visit: `http://${SCHEDULER_IP_ADDRESS}:${server.port}/health`. Acuator defaults the `server.port` to 8080, although it is recommended to reserve ports in the marathon command and set this port explicitly. E.g. [jar mode json file](./manual-tests/marathon-jar.json)

See the [Spring documentation](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready-endpoints) for more information.

## Horizontal scaling
This adds an endpoint at the following location to control the number of instances in the cluster. The endpoint matches the properties file definition of the same name:

`GET /mesos/resources/count` Returns the current number of requested instances. For example to get the current number of instances:

```
$ curl -s http://${SCHEDULER_IP_ADDRESS}:${server.port}/mesos/resources/count
3
```

`POST /mesos/resources/count` with a body of type `Integer` will set the number of requested instances. For example, to set the number of instances to 1:

```
$ curl -XPOST -H 'Content-Type: text/plain' http://${SCHEDULER_IP_ADDRESS}:${server.port}/mesos/resources/count -d 1
```

# Sponsors
This project is sponsored by Cisco Cloud Services.
Expand Down
11 changes: 6 additions & 5 deletions docs/examples/docker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,22 @@ mesos.master=zk://${mesos.zookeeper.server}/mesos
# Task resources
mesos.resources.cpus=0.5
mesos.resources.mem=256
mesos.resources.scale=3
mesos.resources.ports.UI_5061=ANY
mesos.resources.count=3
mesos.resources.ports.UI_5601.host=ANY
mesos.resources.ports.UI_5601.container=5601

# Docker image
mesos.docker.image=kibana:latest
mesos.docker.network=HOST
mesos.docker.network=BRIDGE

# Command to run
mesos.uri[0]=https://gist.githubusercontent.com/philwinder/592a1ab2db40431c1b08/raw/kibana.yml
mesos.command=mv $MESOS_SANDBOX/kibana.yml /opt/kibana/config/kibana.yml ; kibana --port=$UI_5061 --elasticsearch ${elasticsearch.http}
mesos.command=mv $MESOS_SANDBOX/kibana.yml /opt/kibana/config/kibana.yml ; kibana --elasticsearch ${elasticsearch.http}

# Log level
logging.level.com.containersolutions.mesos=DEBUG

# Task HealthChecks (Will kill executors that don't respond) (Note: HealthChecks do not work in Mesos 0.25.0, 0.24.0 or 0.23.0)
# See https://issues.apache.org/jira/browse/MESOS-3738 and https://issues.apache.org/jira/browse/MESOS-3136
# And HTTP healthchecks still don't work: https://issues.apache.org/jira/browse/MESOS-2533
mesos.healthCheck.command=curl --retry 0 -s localhost:$UI_5061 > /dev/null
mesos.healthCheck.command=wget -q localhost:5601
8 changes: 4 additions & 4 deletions docs/examples/jar.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ mesos.master=zk://${mesos.zookeeper.server}/mesos
# Task resources
mesos.resources.cpus=0.5
mesos.resources.mem=256
mesos.resources.scale=3
mesos.resources.ports.UI_5061=ANY
mesos.resources.count=3
mesos.resources.ports.UI_5601.host=ANY

# Command to run
mesos.uri[0]=https://gist.githubusercontent.com/philwinder/592a1ab2db40431c1b08/raw/kibana.yml
mesos.uri[1]=https://download.elastic.co/kibana/kibana/kibana-4.4.1-linux-x64.tar.gz
mesos.command= cp $MESOS_SANDBOX/kibana.yml $MESOS_SANDBOX/kibana-*/config/kibana.yml ; cd kibana-* ; bin/kibana --port=$UI_5061 --elasticsearch ${elasticsearch.http}
mesos.command= cp $MESOS_SANDBOX/kibana.yml $MESOS_SANDBOX/kibana-*/config/kibana.yml ; cd kibana-* ; bin/kibana --port=$UI_5601 --elasticsearch ${elasticsearch.http}

# Log level
logging.level.com.containersolutions.mesos=DEBUG
Expand All @@ -34,4 +34,4 @@ logging.level.com.containersolutions.mesos=DEBUG
# Task HealthChecks (Will kill executors that don't respond) (Note: HealthChecks do not work in Mesos 0.25.0, 0.24.0 or 0.23.0)
# See https://issues.apache.org/jira/browse/MESOS-3738 and https://issues.apache.org/jira/browse/MESOS-3136
# And HTTP healthchecks still don't work: https://issues.apache.org/jira/browse/MESOS-2533
mesos.healthCheck.command=curl --retry 0 -s localhost:$UI_5061 > /dev/null
mesos.healthCheck.command=wget -q localhost:$UI_5601
27 changes: 27 additions & 0 deletions docs/examples/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# UI_5061 is an environmental variable provided inside the docker container. This is the mesos-chosen port.

elasticsearch_http: elasticsearch-executor.service.consul:9200
framework_ui_port: 31200
kibana_command: mv $MESOS_SANDBOX/*.yml /opt/kibana/config/kibana.yml ; kibana --elasticsearch {{ elasticsearch_http }}
kibana_executor_cpu: 0.5
kibana_executor_instances: 3
kibana_executor_network: BRIDGE
kibana_executor_ram: 1024
kibana_framework_cpu: 0.5
kibana_framework_healthcheck_command: wget -q localhost:5601
kibana_framework_heap: 128
kibana_framework_image_name: containersol/mesosframework
kibana_framework_image_tag: 0.1.0-beta.4
kibana_framework_instances: 1
kibana_framework_ip: kibana.service.consul
kibana_framework_log_level: WARN
kibana_framework_name: kibana
kibana_framework_network: HOST
kibana_framework_properties_name: mantl-kibana.properties
kibana_framework_properties_path: /etc/kibana/{{ kibana_framework_properties_name }}
kibana_framework_ram: 256
kibana_image_name: kibana
kibana_image_tag: 4.3.1
kibana_settings_path: /etc/kibana/kibana.yml
mesos_zk: {{ mesos_zk }}
zookeeper: zookeeper.service.consul:2181
40 changes: 40 additions & 0 deletions docs/examples/mantl-kibana.properties.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Introduction
# This is a properties file for the mantl project. Most options are injected by ansible.
# All of the properties in the mesos-starter project are overridable.


# Required application name for Spring
spring.application.name={{ kibana_framework_name }}

# Mesos framework name
mesos.framework.name={{ kibana_framework_name }}

# Mesos settings
mesos.zookeeper.server={{ zookeeper }}
mesos.master={{ mesos_zk }}

# ES location
elasticsearch.http={{ elasticsearch_http }}

# Task resources
mesos.resources.cpus={{ kibana_executor_cpu }}
mesos.resources.mem={{ kibana_executor_ram }}
mesos.resources.count={{ kibana_executor_instances }}
mesos.resources.ports.UI_5601.host=ANY
mesos.resources.ports.UI_5601.container=5601

# Docker image
mesos.docker.image={{ kibana_image_name }}:{{ kibana_image_tag }}
mesos.docker.network={{ kibana_executor_network }}

# Log level
logging.level.com.containersolutions.mesos={{ kibana_framework_log_level }}

# Task HealthChecks (Will kill executors that don't respond) (Note: HealthChecks do not work in Mesos 0.25.0, 0.24.0 or 0.23.0)
# See https://issues.apache.org/jira/browse/MESOS-3738 and https://issues.apache.org/jira/browse/MESOS-3136
# And HTTP healthchecks still don't work: https://issues.apache.org/jira/browse/MESOS-2533
mesos.healthCheck.command={{ kibana_framework_healthcheck_command }}

# Command to run
mesos.uri[0]={{ kibana_settings_path }}
mesos.command={{ kibana_command }}
6 changes: 3 additions & 3 deletions docs/examples/minimesos.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ mesos.master=zk://${mesos.zookeeper.server}/mesos
# Task resources
mesos.resources.cpus=0.1
mesos.resources.mem=128
mesos.resources.scale=3
mesos.resources.ports.UI_5061=ANY
mesos.resources.count=3
mesos.resources.ports.UI_5061.host=ANY

# Command to run
mesos.uri[0]=https://gist.githubusercontent.com/philwinder/592a1ab2db40431c1b08/raw/kibana.yml
Expand All @@ -34,4 +34,4 @@ logging.level.com.containersolutions.mesos=DEBUG
# Task HealthChecks (Will kill executors that don't respond) (Note: HealthChecks do not work in Mesos 0.25.0, 0.24.0 or 0.23.0)
# See https://issues.apache.org/jira/browse/MESOS-3738 and https://issues.apache.org/jira/browse/MESOS-3136
# And HTTP healthchecks still don't work: https://issues.apache.org/jira/browse/MESOS-2533
mesos.healthCheck.command=curl localhost:$UI_5061
mesos.healthCheck.command=wget -q localhost:$UI_5061
2 changes: 1 addition & 1 deletion manual-tests/marathon-docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"container": {
"type": "DOCKER",
"docker": {
"image": "containersol/mesosframework:0.1.0-beta.0",
"image": "containersol/mesosframework:0.1.0",
"network": "HOST"
}
},
Expand Down
2 changes: 1 addition & 1 deletion manual-tests/marathon-jar.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"instances": 1,
"cmd": "mv *.jar scheduler.jar ; java $JAVA_OPTS -jar scheduler.jar --spring.config.location=./jar.properties --mesos.zookeeper.server=$MASTER:2181 --elasticsearch.http=http://$SLAVE0:9200 --server.port=31100",
"uris": [
"https://github.com/ContainerSolutions/mesosframework/releases/download/0.1.0-beta.0/mesosframework-0.0.1.jar",
"https://github.com/ContainerSolutions/mesosframework/releases/download/0.1.0/mesosframework-0.1.0.jar",
"https://raw.githubusercontent.com/mesos/kibana/master/docs/examples/jar.properties"
],
"env": {
Expand Down
35 changes: 35 additions & 0 deletions manual-tests/marathon-minimesos-docker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"id": "kibana-docker",
"cpus": 0.2,
"mem": 256,
"instances": 1,
"args": [
"--spring.application.name=kibana-docker",
"--mesos.framework.name=kibana-docker",
"--mesos.master=zk://$MASTER:2181/mesos",
"--mesos.docker.image=kibana:latest",
"--mesos.docker.network=BRIDGE",
"--mesos.resources.mem=256",
"--mesos.resources.cpu=0.2",
"--mesos.resources.count=3",
"--mesos.command=kibana --elasticsearch ${elasticsearch.http}",
"--logging.level.com.containersolutions.mesos=DEBUG",
"--mesos.zookeeper.server=$MASTER:2181",
"--elasticsearch.http=http://$SLAVE0:9200",
"--server.port=31100"
],
"env": {
"JAVA_OPTS": "-Xms32m -Xmx128m"
},
"container": {
"type": "DOCKER",
"docker": {
"image": "containersol/mesosframework:0.1.0",
"network": "BRIDGE"
}
},
"ports": [
31100
],
"requirePorts": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"instances": 1,
"cmd": "unset MESOS_RESOURCES ; mv *.jar scheduler.jar ; java $JAVA_OPTS -jar scheduler.jar --spring.config.location=./minimesos.properties --mesos.zookeeper.server=172.17.0.3:2181 --elasticsearch.http=http://172.17.0.2:9200 --server.port=31100",
"uris": [
"https://github.com/ContainerSolutions/mesosframework/releases/download/0.1.0-beta.0/mesosframework-0.0.1.jar",
"https://github.com/ContainerSolutions/mesosframework/releases/download/0.1.0/mesosframework-0.1.0.jar",
"https://raw.githubusercontent.com/mesos/kibana/master/docs/examples/minimesos.properties"
],
"env": {
Expand Down

0 comments on commit 4328d8c

Please sign in to comment.