From 679014a052f3daedf1e5d6d2a476b203b2fa33f8 Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Fri, 18 Dec 2015 06:57:17 +0100 Subject: [PATCH] Add Dockerfiles for Mesos Change-Id: Iaf317817eccaa72f2a86b1058a0179afd3427859 Partially-Implements: blueprint mesos --- docker/chronos/Dockerfile.j2 | 24 +++++++++ docker/marathon/Dockerfile.j2 | 50 +++++++++++++++++++ docker/marathon/java8-runtime-headless | 9 ++++ docker/marathon/openjdk.list | 2 + docker/mesos/mesos-base/Dockerfile.j2 | 16 ++++++ docker/mesos/mesos-master/Dockerfile.j2 | 10 ++++ docker/mesos/mesos-slave/Dockerfile.j2 | 37 ++++++++++++++ docker/mesos/mesos-slave/docker.list | 2 + docker/mesos/mesos-slave/docker.repo | 6 +++ .../mesosphere/mesosphere-base/Dockerfile.j2 | 17 +++++++ .../mesosphere-base/mesosphere.list | 2 + docker/zookeeper/Dockerfile.j2 | 31 ++++++++++++ docker/zookeeper/extend_start.sh | 6 +++ docker/zookeeper/zookeeper_sudoers | 1 + kolla/common/config.py | 8 ++- 15 files changed, 219 insertions(+), 2 deletions(-) create mode 100644 docker/chronos/Dockerfile.j2 create mode 100644 docker/marathon/Dockerfile.j2 create mode 100644 docker/marathon/java8-runtime-headless create mode 100644 docker/marathon/openjdk.list create mode 100644 docker/mesos/mesos-base/Dockerfile.j2 create mode 100644 docker/mesos/mesos-master/Dockerfile.j2 create mode 100644 docker/mesos/mesos-slave/Dockerfile.j2 create mode 100644 docker/mesos/mesos-slave/docker.list create mode 100644 docker/mesos/mesos-slave/docker.repo create mode 100644 docker/mesosphere/mesosphere-base/Dockerfile.j2 create mode 100644 docker/mesosphere/mesosphere-base/mesosphere.list create mode 100644 docker/zookeeper/Dockerfile.j2 create mode 100644 docker/zookeeper/extend_start.sh create mode 100644 docker/zookeeper/zookeeper_sudoers diff --git a/docker/chronos/Dockerfile.j2 b/docker/chronos/Dockerfile.j2 new file mode 100644 index 0000000000..7c9d73c03c --- /dev/null +++ b/docker/chronos/Dockerfile.j2 @@ -0,0 +1,24 @@ +FROM {{ namespace }}/{{ image_prefix }}mesos-base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} + +RUN yum install -y \ + chronos \ + && yum clean all + +{% elif base_distro in ['ubuntu', 'debian'] %} + +RUN apt-get install -y --no-install-recommends \ + chronos \ + && apt-get clean + +{% endif %} + +RUN useradd --user-group chronos + +CMD chronos run_jar --http_port $CHRONOS_HTTP_PORT --master $CHRONOS_MASTER --zk_hosts $CHRONOS_ZK_HOSTS + +{{ include_footer }} + +USER chronos diff --git a/docker/marathon/Dockerfile.j2 b/docker/marathon/Dockerfile.j2 new file mode 100644 index 0000000000..ba289ec11f --- /dev/null +++ b/docker/marathon/Dockerfile.j2 @@ -0,0 +1,50 @@ +FROM {{ namespace }}/{{ image_prefix }}mesos-base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} + +RUN yum install -y \ + marathon \ + && yum clean all + +{% elif base_distro in ['ubuntu', 'debian'] %} + +COPY openjdk.list /etc/apt/sources.list.d/openjdk.list + +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv DA1A4A13543B466853BAF164EB9B1D8886F44E2A \ + && apt-get update + +# NOTE(nihilifer): Marathon package for Ubuntu depends on Oracle Java and +# there is no official way to use OpenJDK. There is no way to accept the +# license in kolla. That's why the fake package is created here and OpenJDK +# is used anyway. +# We only have to do this with Ubuntu - CentOS packages don't depend strictly +# on Oracle JDK and installing them by yum just installs OpenJDK as a +# dependency. + +RUN apt-get install -y --no-install-recommends \ + equivs \ + gcc \ + && apt-get clean + +COPY java8-runtime-headless / + +RUN equivs-build java8-runtime-headless \ + && dpkg -i java8-runtime-headless_42_all.deb \ + && rm java8-runtime-headless java8-runtime-headless_42_all.deb + +RUN apt-get install -y --no-install-recommends \ + marathon \ + openjdk-8-jre-headless \ + && apt-get clean + +{% endif %} + +RUN useradd --user-group marathon \ + && chmod 755 /usr/bin/marathon + +CMD ["marathon", "--no-logger"] + +{{ include_footer }} + +USER marathon diff --git a/docker/marathon/java8-runtime-headless b/docker/marathon/java8-runtime-headless new file mode 100644 index 0000000000..5c24a93392 --- /dev/null +++ b/docker/marathon/java8-runtime-headless @@ -0,0 +1,9 @@ +Section: misc +Priority: optional +Standards-Version: 3.9.2 + +Package: java8-runtime-headless +Version: 1:42 +Maintainer: Kolla Project (https://launchpad.net/kolla) +Architecture: all +Description: fake Oracle Java package to block a non-free dependency diff --git a/docker/marathon/openjdk.list b/docker/marathon/openjdk.list new file mode 100644 index 0000000000..e1fa60ad47 --- /dev/null +++ b/docker/marathon/openjdk.list @@ -0,0 +1,2 @@ +# OpenJDK 8 repo +deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu trusty main diff --git a/docker/mesos/mesos-base/Dockerfile.j2 b/docker/mesos/mesos-base/Dockerfile.j2 new file mode 100644 index 0000000000..f4dd4e450e --- /dev/null +++ b/docker/mesos/mesos-base/Dockerfile.j2 @@ -0,0 +1,16 @@ +FROM {{ namespace }}/{{ image_prefix }}mesosphere-base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} + +RUN yum install -y \ + mesos \ + && yum clean all + +{% elif base_distro in ['ubuntu', 'debian'] %} + +RUN apt-get install -y --no-install-recommends \ + mesos \ + && apt-get clean + +{% endif %} diff --git a/docker/mesos/mesos-master/Dockerfile.j2 b/docker/mesos/mesos-master/Dockerfile.j2 new file mode 100644 index 0000000000..7bad7dee10 --- /dev/null +++ b/docker/mesos/mesos-master/Dockerfile.j2 @@ -0,0 +1,10 @@ +FROM {{ namespace }}/{{ image_prefix }}mesos-base:{{ tag }} +MAINTAINER {{ maintainer }} + +RUN useradd --user-group mesos + +CMD ["mesos-master"] + +{{ include_footer }} + +USER mesos diff --git a/docker/mesos/mesos-slave/Dockerfile.j2 b/docker/mesos/mesos-slave/Dockerfile.j2 new file mode 100644 index 0000000000..339468d20c --- /dev/null +++ b/docker/mesos/mesos-slave/Dockerfile.j2 @@ -0,0 +1,37 @@ +FROM {{ namespace }}/{{ image_prefix }}mesos-base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} + +COPY docker.repo /etc/yum.repos.d/docker.repo + +RUN rpm --import https://yum.dockerproject.org/gpg + +RUN yum install -y \ + docker-engine \ + && yum clean all + +{% elif base_distro in ['ubuntu', 'debian'] %} + +COPY docker.list /etc/apt/sources.list.d/docker.list + +RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv 58118E89F3A912897C070ADBF76221572C52609D \ + && apt-get update + +RUN apt-get install -y --no-install-recommends \ + docker-engine \ + && apt-get clean + +{% endif %} + +ENV MESOS_CONTAINERIZERS docker +# Increase executor's timeout for pulling a Docker image to the slave +# https://mesosphere.github.io/marathon/docs/native-docker.html +ENV MESOS_EXECUTOR_REGISTRATION_TIMEOUT 5mins + +CMD ["mesos-slave"] + +{{ include_footer }} + +# This container should run as a root, because it's talking to the Docker +# socket directly. diff --git a/docker/mesos/mesos-slave/docker.list b/docker/mesos/mesos-slave/docker.list new file mode 100644 index 0000000000..45c9c88fbd --- /dev/null +++ b/docker/mesos/mesos-slave/docker.list @@ -0,0 +1,2 @@ +# Docker repo +deb http://apt.dockerproject.org/repo ubuntu-trusty main diff --git a/docker/mesos/mesos-slave/docker.repo b/docker/mesos/mesos-slave/docker.repo new file mode 100644 index 0000000000..a66294c930 --- /dev/null +++ b/docker/mesos/mesos-slave/docker.repo @@ -0,0 +1,6 @@ +[dockerrepo] +name=Docker Repository +baseurl=https://yum.dockerproject.org/repo/main/centos/7 +enabled=1 +gpgcheck=1 +gpgkey=https://yum.dockerproject.org/gpg diff --git a/docker/mesosphere/mesosphere-base/Dockerfile.j2 b/docker/mesosphere/mesosphere-base/Dockerfile.j2 new file mode 100644 index 0000000000..b3bb57d652 --- /dev/null +++ b/docker/mesosphere/mesosphere-base/Dockerfile.j2 @@ -0,0 +1,17 @@ +FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} + +RUN rpm --import http://repos.mesosphere.io/el/RPM-GPG-KEY-mesosphere + +RUN rpm -Uvh http://repos.mesosphere.com/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm + +{% elif base_distro in ['ubuntu', 'debian'] %} + +COPY mesosphere.list /etc/apt/sources.list.d/mesosphere.list + +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv 81026D0004C44CF7EF55ADF8DF7D54CBE56151BF \ + && apt-get update + +{% endif %} diff --git a/docker/mesosphere/mesosphere-base/mesosphere.list b/docker/mesosphere/mesosphere-base/mesosphere.list new file mode 100644 index 0000000000..54b7b1d778 --- /dev/null +++ b/docker/mesosphere/mesosphere-base/mesosphere.list @@ -0,0 +1,2 @@ +# Mesosphere repo +deb http://repos.mesosphere.com/ubuntu trusty main diff --git a/docker/zookeeper/Dockerfile.j2 b/docker/zookeeper/Dockerfile.j2 new file mode 100644 index 0000000000..93c8bcc4e3 --- /dev/null +++ b/docker/zookeeper/Dockerfile.j2 @@ -0,0 +1,31 @@ +FROM {{ namespace }}/{{ image_prefix }}mesosphere-base:{{ tag }} +MAINTAINER {{ maintainer }} + +{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} + +RUN yum install -y \ + mesosphere-zookeeper \ + && yum clean all + +RUN useradd --user-group zookeeper + +{% elif base_distro in ['ubuntu', 'debian'] %} + +RUN apt-get install -y --no-install-recommends \ + zookeeper \ + && apt-get clean + +{% endif %} + +COPY zookeeper_sudoers /etc/sudoers.d/zookeeper_sudoers +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 755 /usr/local/bin/kolla_extend_start \ + && chmod 750 /etc/sudoers.d \ + && chmod 440 /etc/sudoers.d/zookeeper_sudoers \ + && usermod -a -G kolla zookeeper + +ENV ZOOCFGDIR=/etc/zookeeper/conf + +{{ include_footer }} + +USER zookeeper diff --git a/docker/zookeeper/extend_start.sh b/docker/zookeeper/extend_start.sh new file mode 100644 index 0000000000..4ea18ccbbc --- /dev/null +++ b/docker/zookeeper/extend_start.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then + sudo chown zookeeper: /var/lib/zookeeper + exit 0 +fi diff --git a/docker/zookeeper/zookeeper_sudoers b/docker/zookeeper/zookeeper_sudoers new file mode 100644 index 0000000000..e0f82de201 --- /dev/null +++ b/docker/zookeeper/zookeeper_sudoers @@ -0,0 +1 @@ +%kolla ALL=(root) NOPASSWD: /bin/chown zookeeper\: /var/lib/zookeeper, /usr/bin/chown zookeeper\: /var/lib/zookeeper diff --git a/kolla/common/config.py b/kolla/common/config.py index bc821e0258..5988f382fd 100644 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -36,7 +36,7 @@ _PROFILE_OPTS = [ help='Main images'), cfg.ListOpt('aux', default=['aodh', 'designate', 'gnocchi', 'ironic', - 'magnum', 'mistral', 'trove,' 'zaqar'], + 'magnum', 'mistral', 'trove,' 'zaqar', 'zookeeper'], help='Aux Images'), cfg.ListOpt('default', default=['data', 'kolla-ansible', 'glance', 'haproxy', @@ -50,7 +50,11 @@ _PROFILE_OPTS = [ 'keystone', 'kolla-ansible', 'mariadb', 'memcached', 'neutron', 'nova', 'openvswitch', 'rabbitmq', 'rsyslog'], - help='Gate images') + help='Gate images'), + cfg.ListOpt('mesos', + default=['chronos', 'marathon', 'mesos-master', 'mesos-slave', + 'zookeeper'], + help='Mesos images') ] _CLI_OPTS = [