Skip to content

Commit

Permalink
0.4.2 : introduce traefik with examples -prove with travis (#298)
Browse files Browse the repository at this point in the history
* Version 0.4.2 with traefik
  • Loading branch information
sielaq authored Aug 14, 2019
1 parent 4cfa7b0 commit ee18bb3
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 29 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ before_install:
- export IP=$(/sbin/ifconfig eth0 | awk '/inet addr:/{gsub(/.*:/,"",$2);print $2;exit}')
- echo $IP
- export START_DNSMASQ=false
- export START_TRAEFIK=true
- export ZOOKEEPER_HOSTS=${IP}:2181
- "./generate_yml.sh"
- cat docker-compose.yml
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/eBayClassifiedsGroup/PanteraS.svg?branch=master)](https://travis-ci.org/eBayClassifiedsGroup/PanteraS)
[![Docker Hub](https://img.shields.io/badge/docker-ready-blue.svg)](https://hub.docker.com/r/panteras/paas-in-a-box/)
[![Current Release](https://img.shields.io/badge/release-0.4.1-blue.svg)](https://github.com/eBayClassifiedsGroup/PanteraS/releases/tag/v0.4.1)
[![Current Release](https://img.shields.io/badge/release-0.4.2-blue.svg)](https://github.com/eBayClassifiedsGroup/PanteraS/releases/tag/v0.4.2)

# PanteraS <br> _entire_ Platform as a Service, in a box
_"One container to rule them all"_
Expand Down Expand Up @@ -57,11 +57,11 @@ Depending on `MASTER` and `SLAVE` you can define role of the container
Mesos Slave | x | - | x
Registrator | x | - | x
Fabio | x | - | x
Traefik | - | - | x
Dnsmasq | - | - | -
Netdata | - | - | -

Last two require manual override like `START_FABIO=true`
Enabling `Fabio` require stop the other concurent service `START_CONSUL_TEMPLATE=false`
Optional services (disabled by default) require manual override like `START_TRAEFIK=true`


## Requirements:
Expand All @@ -71,7 +71,7 @@ Enabling `Fabio` require stop the other concurent service `START_CONSUL_TEMPLATE
## Usage:
Clone it
```
git clone -b 0.4.1 https://github.com/eBayClassifiedsGroup/PanteraS.git
git clone -b 0.4.2 https://github.com/eBayClassifiedsGroup/PanteraS.git
cd PanteraS
```
#### Default: Stand alone mode
Expand Down
12 changes: 8 additions & 4 deletions docker-compose.yml.tpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
panteras:
image: ${PANTERAS_DOCKER_IMAGE}
# net: bridge
net: host
privileged: true
pid: host
restart: "${PANTERAS_RESTART}"
${PORTS}
ports:
- "9000:9000"
${FABIO_UI_PORTS}
${TRAEFIK_UI_PORTS}
${CONSUL_UI_PORTS}
${MARATHON_PORTS}
${MESOS_PORTS}
Expand All @@ -18,8 +21,8 @@ panteras:
FQDN: "${FQDN}"
GOMAXPROCS: "${GOMAXPROCS}"

SERVICE_81_NAME: fabio-ui
SERVICE_81_TAGS: paas-fabio.ui.service.consul/
SERVICE_81_NAME: router-ui
SERVICE_81_TAGS: paas-router.ui.service.consul/
SERVICE_81_CHECK_HTTP: /routes

SERVICE_8500_NAME: consul-ui
Expand All @@ -46,6 +49,7 @@ panteras:
START_REGISTRATOR: "${START_REGISTRATOR}"
START_ZOOKEEPER: "${START_ZOOKEEPER}"
START_FABIO: "${START_FABIO}"
START_TRAEFIK: "${START_TRAEFIK}"
START_NETDATA: "${START_NETDATA}"

CONSUL_APP_PARAMS: "${CONSUL_APP_PARAMS}"
Expand All @@ -60,6 +64,7 @@ panteras:
ZOOKEEPER_HOSTS: "${ZOOKEEPER_HOSTS}"
ZOOKEEPER_ID: "${ZOOKEEPER_ID}"
FABIO_APP_PARAMS: "${FABIO_APP_PARAMS}"
TRAEFIK_APP_PARAMS: "${TRAEFIK_APP_PARAMS}"
NETDATA_APP_PARAMS: "${NETDATA_APP_PARAMS}"

HOSTNAME: "${PANTERAS_HOSTNAME}"
Expand All @@ -69,7 +74,6 @@ panteras:

volumes:
- "/etc/resolv.conf:/etc/resolv.conf.orig"
- "/var/spool/marathon/artifacts/store:/var/spool/store"
- "/var/run/docker.sock:/tmp/docker.sock"
- "/var/run/docker.sock:/var/run/docker.sock"
- "/var/lib/docker:/var/lib/docker"
Expand Down
2 changes: 1 addition & 1 deletion examples/SimpleWebappPython/deploy0_marathon.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
},
"env": {
"SERVICE_TAGS" : "paas-python.service.consul/",
"SERVICE_TAGS" : "paas-python.service.consul/,paas.enable=true,paas.backend.loadbalancer.method=drr,paas.frontends.service.rule=Host:python.service.consul",
"SERVICE_NAME" : "python",
"SERVICE_8080_CHECK_HTTP" : "/index.html"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/SimpleWebappPython/start_with_marathon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# boot2docker
[ -n "${DOCKER_HOST}" ] && IP=${IP:-$(echo $DOCKER_HOST | sed 's;.*//\(.*\):.*;\1;')}
# outside vagrant
which vagrant && IP=${IP:-$(vagrant ssh -c ifconfig 2>/dev/null| grep -oh "\w*192.168.10.10\w*")}
#which vagrant && IP=${IP:-$(vagrant ssh -c ifconfig 2>/dev/null| grep -oh "\w*192.168.10.10\w*")}
# inside vagrant
[ "$HOSTNAME" == "standalone" ] && IP=${IP:-192.168.10.10}
# try to guess
Expand Down
2 changes: 1 addition & 1 deletion examples/SmoothWebappPython/deploy0_marathon.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"mem": 64.0,
"instances": 2,
"env": {
"SERVICE_TAGS" : "paas-python-smooth.service.consul/",
"SERVICE_TAGS" : "paas-python-smooth.service.consul/,paas.enable=true,paas.backend.loadbalancer.method=drr,paas.frontends.service.rule=Host:python-smooth.service.consul",
"SERVICE_NAME" : "python-smooth",
"SERVICE_8000_CHECK_HTTP" : "/cgi-bin/index"
},
Expand Down
18 changes: 12 additions & 6 deletions generate_yml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ PANTERAS_DOCKER_IMAGE=${PANTERAS_DOCKER_IMAGE:-${REGISTRY}panteras/paas-in-a-box
#COMMON
START_CONSUL=${START_CONSUL:-"true"}
START_FABIO=${START_FABIO:-"true"}
START_TRAEFIK=${START_TRAEFIK:-"false"}
[ "${START_TRAEFIK,,}" == "true" ] && START_FABIO="false"

#MASTER
START_MESOS_MASTER=${START_MESOS_MASTER:-${MASTER}}
Expand Down Expand Up @@ -88,18 +90,19 @@ FQDN=${FQDN:-${HOSTNAME}}
ZOOKEEPER_JAVA_OPTS=${ZOOKEEPER_JAVA_OPTS:-"-Xmx512m"}

# Disable dnsmasq address re-mapping on non slaves
[ "${SLAVE}" == "false" ] && DNSMASQ_ADDRESS=${DNSMASQ_ADDRESS:-' '}
[ "${SLAVE,,}" == "false" ] && DNSMASQ_ADDRESS=${DNSMASQ_ADDRESS:-' '}
# dnsmaq cannot be set to listen on 0.0.0.0 - it causes lot of issues
# and by default it works on all addresses
DNSMASQ_ADDRESS=${DNSMASQ_ADDRESS:-"--address=/consul/${CONSUL_IP}"}
[ ${LISTEN_IP} != "0.0.0.0" ] && DNSMASQ_BIND_INTERFACES="--bind-interfaces --listen-address=${LISTEN_IP}"

# Expose ports depends on which service has been mark to start
[ "${START_FABIO}" == "true" ] && PORTS="ports:" && FABIO_UI_PORTS='- "81:81"'
[ "${START_CONSUL}" == "true" ] && PORTS="ports:" && CONSUL_UI_PORTS='- "8500:8500"'
[ "${START_MARATHON}" == "true" ] && PORTS="ports:" && MARATHON_PORTS='- "8080:8080"'
[ "${START_MESOS_MASTER}" == "true" ] && PORTS="ports:" && MESOS_PORTS='- "5050:5050"'
[ "${START_NETDATA}" == "true" ] && PORTS="ports:" && NETDATA_PORTS='- "19999:19999"'
[ "${START_FABIO,,}" == "true" ] && FABIO_UI_PORTS='- "81:81"'
[ "${START_TRAEFIK,,}" == "true" ] && TRAEFIK_UI_PORTS='- "81:81"'
[ "${START_CONSUL,,}" == "true" ] && CONSUL_UI_PORTS='- "8500:8500"'
[ "${START_MARATHON,,}" == "true" ] && MARATHON_PORTS='- "8080:8080"'
[ "${START_MESOS_MASTER,,}" == "true" ] && MESOS_PORTS='- "5050:5050"'
[ "${START_NETDATA,,}" == "true" ] && NETDATA_PORTS='- "19999:19999"'

# Override docker with local binary
[ "${HOST_DOCKER}" == "true" ] && VOLUME_DOCKER=${VOLUME_DOCKER:-'- "/usr/local/bin/docker:/usr/local/bin/docker"'}
Expand Down Expand Up @@ -164,6 +167,8 @@ ZOOKEEPER_PARAMS="start-foreground"
#
FABIO_PARAMS="-cfg ./fabio.properties"
#
TRAEFIK_PARAMS="-c ./traefik.toml"
#
NETDATA_PARAMS="-nd -ch /host"

CONSUL_APP_PARAMS=${CONSUL_APP_PARAMS:-$CONSUL_PARAMS}
Expand All @@ -174,6 +179,7 @@ MESOS_SLAVE_APP_PARAMS=${MESOS_SLAVE_APP_PARAMS:-$MESOS_SLAVE_PARAMS}
REGISTRATOR_APP_PARAMS=${REGISTRATOR_APP_PARAMS:-$REGISTRATOR_PARAMS}
ZOOKEEPER_APP_PARAMS=${ZOOKEEPER_APP_PARAMS:-$ZOOKEEPER_PARAMS}
FABIO_APP_PARAMS=${FABIO_APP_PARAMS:-$FABIO_PARAMS}
TRAEFIK_APP_PARAMS=${TRAEFIK_APP_PARAMS:-$TRAEFIK_PARAMS}
NETDATA_APP_PARAMS=${NETDATA_APP_PARAMS:-$NETDATA_PARAMS}

PANTERAS_HOSTNAME=${PANTERAS_HOSTNAME:-${HOSTNAME}}
Expand Down
30 changes: 24 additions & 6 deletions infrastructure/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ ENV TERM xterm
ENV HOME /root
ENV GOPATH ${HOME}/go

ENV SUPERVISORD_APP_VERSION 4.0.0
ENV DOCKER_APP_VERSION 5:18.09.3~3-0~ubuntu-xenial
ENV CONSUL_APP_VERSION 1.4.2
ENV MESOS_APP_VERSION 1.7.2-2.0.1
ENV SUPERVISORD_APP_VERSION 4.0.4
ENV DOCKER_APP_VERSION 5:19.03.1~3-0~ubuntu-xenial
ENV CONSUL_APP_VERSION 1.5.3
ENV MESOS_APP_VERSION 1.8.0-2.0.6.ubuntu1604
#ENV MARATHON_APP_VERSION 1.7.189-0.1.20190125223314.ubuntu1604
ENV MARATHON_APP_VERSION 1.7.189-48bfd6000
ENV REGISTRATOR_APP_VERSION v7
ENV FABIO_APP_VERSION 1.5.11
ENV FABIO_GO_APP_VERSION go1.11.5
ENV NETDATA_APP_VERSION 1.12.2
ENV NETDATA_APP_VERSION 1.16.1
#ENV TRAEFIK_APP_VERSION v2.0.0-beta1
ENV TRAEFIK_APP_VERSION v1.7.12


ENV DOCKER_HOST unix:///tmp/docker.sock

Expand Down Expand Up @@ -135,8 +138,23 @@ RUN wget https://github.com/eBay/fabio/releases/download/v${FABIO_APP_VERSION}/f
&& chown -R fabio:fabio /opt/fabio \
&& setcap 'cap_net_bind_service=+ep' ./fabio

# NETDATA
# TRAEFIK
#
RUN mkdir /opt/traefik \
&& groupadd -g 3002 traefik \
&& useradd -g 3002 -u 3002 -d /opt/traefik -s /bin/false traefik
ENV PATH ${PATH}:/opt/traefik
WORKDIR /opt/traefik
#RUN wget https://github.com/containous/traefik/releases/download/${TRAEFIK_APP_VERSION}/traefik_${TRAEFIK_APP_VERSION}_linux_amd64.tar.gz -O traefik.tar.gz \
RUN wget https://github.com/containous/traefik/releases/download/${TRAEFIK_APP_VERSION}/traefik_linux-amd64 -O traefik \
# && tar zxf traefik.tar.gz \
&& chmod a+x traefik \
&& chown -R traefik:traefik /opt/traefik \
&& setcap 'cap_net_bind_service=+ep' ./traefik
ADD traefik.toml /opt/traefik

# NETDATA
#
RUN apt-get update \
&& apt-get -y install \
zlib1g-dev \
Expand Down
22 changes: 17 additions & 5 deletions infrastructure/supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[supervisord]
root=true
nodaemon=true
childlogdir=/tmp/supervisord
logfile=/tmp/supervisord/supervisord.log
Expand Down Expand Up @@ -40,6 +41,15 @@ user=root
stdout_events_enabled = true
stderr_events_enabled = true

[program:zookeeper]
priority=8
command=/opt/zkStart.sh %(ENV_ZOOKEEPER_APP_PARAMS)s
autorestart=true
autostart=%(ENV_START_ZOOKEEPER)s
user=zookeeper
stdout_events_enabled = true
stderr_events_enabled = true

[program:fabio]
priority=16
directory=/opt/fabio
Expand All @@ -50,15 +60,17 @@ user=fabio
stdout_events_enabled = true
stderr_events_enabled = true

[program:zookeeper]
priority=8
command=/opt/zkStart.sh %(ENV_ZOOKEEPER_APP_PARAMS)s
[program:traefik]
priority=16
directory=/opt/traefik
command=traefik %(ENV_TRAEFIK_APP_PARAMS)s
autorestart=true
autostart=%(ENV_START_ZOOKEEPER)s
user=zookeeper
autostart=%(ENV_START_TRAEFIK)s
user=traefik
stdout_events_enabled = true
stderr_events_enabled = true


[program:mesos-master]
priority=32
command=mesos-master %(ENV_MESOS_MASTER_APP_PARAMS)s
Expand Down
25 changes: 25 additions & 0 deletions infrastructure/traefik.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
debug = true
logLevel = "INFO"

[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.api]
address = ":81"

[consulCatalog]
endpoint = "127.0.0.1:8500"
exposedByDefault = false
stale = false
prefix = "paas"
frontEndRule = "Host:{{.ServiceName}}.service"

[api]
entryPoint = "api"
dashboard = true

[metrics]
[metrics.prometheus]
entryPoint = "api"
buckets = [0.1,0.3,1.2,5.0]
2 changes: 1 addition & 1 deletion infrastructure/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.1
0.4.2

0 comments on commit ee18bb3

Please sign in to comment.