diff --git a/README.md b/README.md index 638e1e7..eae099a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 | @@ -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: @@ -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. diff --git a/docs/examples/docker.properties b/docs/examples/docker.properties index bc46436..0818ddf 100644 --- a/docs/examples/docker.properties +++ b/docs/examples/docker.properties @@ -19,16 +19,17 @@ 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 @@ -36,4 +37,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:5601 diff --git a/docs/examples/jar.properties b/docs/examples/jar.properties index 056adc4..17a11cd 100644 --- a/docs/examples/jar.properties +++ b/docs/examples/jar.properties @@ -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 @@ -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 diff --git a/docs/examples/main.yml b/docs/examples/main.yml new file mode 100644 index 0000000..4e184e0 --- /dev/null +++ b/docs/examples/main.yml @@ -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 diff --git a/docs/examples/mantl-kibana.properties.j2 b/docs/examples/mantl-kibana.properties.j2 new file mode 100644 index 0000000..a95334b --- /dev/null +++ b/docs/examples/mantl-kibana.properties.j2 @@ -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 }} diff --git a/docs/examples/minimesos.properties b/docs/examples/minimesos.properties index 8199fa2..11110d0 100644 --- a/docs/examples/minimesos.properties +++ b/docs/examples/minimesos.properties @@ -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 @@ -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 diff --git a/manual-tests/marathon-docker.json b/manual-tests/marathon-docker.json index bb43a2d..f99376a 100644 --- a/manual-tests/marathon-docker.json +++ b/manual-tests/marathon-docker.json @@ -15,7 +15,7 @@ "container": { "type": "DOCKER", "docker": { - "image": "containersol/mesosframework:0.1.0-beta.0", + "image": "containersol/mesosframework:0.1.0", "network": "HOST" } }, diff --git a/manual-tests/marathon-jar.json b/manual-tests/marathon-jar.json index 63b1e26..95743c8 100644 --- a/manual-tests/marathon-jar.json +++ b/manual-tests/marathon-jar.json @@ -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": { diff --git a/manual-tests/marathon-minimesos-docker.json b/manual-tests/marathon-minimesos-docker.json new file mode 100644 index 0000000..3b3c225 --- /dev/null +++ b/manual-tests/marathon-minimesos-docker.json @@ -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 +} diff --git a/manual-tests/marathon-minimesos.json b/manual-tests/marathon-minimesos-jar.json similarity index 92% rename from manual-tests/marathon-minimesos.json rename to manual-tests/marathon-minimesos-jar.json index 2200e26..4311e67 100644 --- a/manual-tests/marathon-minimesos.json +++ b/manual-tests/marathon-minimesos-jar.json @@ -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": {