From df4952fc0d3ddf3b035ccd159630958004f54dab Mon Sep 17 00:00:00 2001 From: Pradyumna Kaushik Date: Thu, 7 Nov 2019 18:49:55 -0500 Subject: [PATCH 1/5] docker-compose setup Updated .gitignore to ignore test log dirs from project. HOST_IP env var is used by entrypoint script to populate the PCP config. The entrypoint script does the following. 1. construct the PCP config file using the value of the env var HOST_IP. 2. run elektron by providing all the basic command-line options. Added build and run instructions in the README. These include instructions to run elektron on bare-metal or using docker-compose. --- .gitignore | 2 ++ Dockerfile | 62 ++++++++++++++++++++++++++++++++ README.md | 54 ++++++++++++++++++++++++++-- docker-compose.yaml | 86 +++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 16 +++++++++ 5 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml create mode 100755 entrypoint.sh diff --git a/.gitignore b/.gitignore index 531255d..b053e85 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .idea/ # name of executable when built using command 'go build' elektron +# test log directory name. +elektron-test-run* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d8bc0ff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,62 @@ +# Copyright (C) 2018 spdfg +# +# This file is part of Elektron. +# +# Elektron is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Elektron is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Elektron. If not, see . +# + +FROM ubuntu:xenial + +RUN apt-get update && apt-get -y install \ + apt-transport-https \ + ca-certificates \ + curl \ + software-properties-common && \ + apt-get install -yq ssh git + +RUN add-apt-repository ppa:deadsnakes/ppa && \ + apt-get update && \ + apt-get install -y python3.7 + +# Installing performance co-pilot. +RUN apt-get install -y pcp pcp-gui + +# The name of the elektron executable. +ARG elektronexecutablename=elektron +ENV ELEKTRON_EXECUTABLE_NAME=$elektronexecutablename + +# HOST:PORT of the mesos master. +ARG elektronmesosmasterlocation=localhost:5050 +ENV ELEKTRON_MESOS_MASTER_LOCATION=$elektronmesosmasterlocation + +# Workload to be scheduled. +ARG elektronworkload=workload_sample.json +ENV ELEKTRON_WORKLOAD=$elektronworkload + +# Prefix of the log directory. +ARG elektronlogdirprefix=Elektron-Test-Run +ENV ELEKTRON_LOGDIR_PREFIX=$elektronlogdirprefix + +# Hostname/IP Address of the physical machine on which the docker containers are being run. +# This is used to create the pcp config file. +ARG hostip="" +ENV HOST_IP=$hostip + +# Creating directory into which the current directory is going to be mounted. +RUN mkdir /elektron +ADD ./ /elektron +WORKDIR /elektron +RUN chmod 777 /elektron/entrypoint.sh + +ENTRYPOINT ["/elektron/entrypoint.sh"] diff --git a/README.md b/README.md index f166bdd..2b7284d 100644 --- a/README.md +++ b/README.md @@ -55,14 +55,64 @@ If vendoring dependencies, then use the below commands after cloning _elektron_. An alternative is to clone _elektron_ using the command `git clone --recurse-submodules git@github.com:spdfg/elektron.git`. - -## Build and Run +## Build Compile the source code using the `go build` tool as shown below. ```commandline go build -o elektron ``` Use the `-h` option to get information about other command-line options. +## Run +Elektron can be run on bare-metal or using a docker-compose environment. +### Bare-Metal +Follow instructions [here](http://mesos.apache.org/documentation/latest/building/) to setup a Mesos cluster. +In addition, the following software should be installed. + +| Software | Target Machines | +|-----------------------|---------------------------| +| [Performance Co-Pilot](http://pcp.io/) | Mesos master nodes + agent nodes | +| [Docker](https://docs.docker.com/install/linux/docker-ce/ubuntu/) | Mesos agent nodes | + +If power consumption needs to be monitored, install the perfevent PMDA by following the instructions [here](https://pcp.io/man/man1/pmdaperfevent.1.html). +_Note: You might need to update the exposed event names for RAPL depending on the architecture_. +For example, update _perfevent.conf_ with the following events if measuring both CPU and DRAM power. +``` +rapl::RAPL_ENERGY_PKG node +rapl::RAPL_ENERGY_DRAM node +``` + +**_Detail document on the bare-metal setup coming up soon!_** + +### Docker-Compose +For local testing purposes, the docker-compose setup can be used. Follow instructions [here](https://docs.docker.com/compose/install/) to install docker-compose. + +The [entrypoint](./entrypoint.sh) script requires the IP address of the host machine to generate the [PCP config](./config). +On a linux machine, the below command can be used to set it. +```commandline +export HOST_IP=$(curl ifconfig.me) +``` + +#### Environment Variables +The following are the environment variables required to run _elektron_. + +| Environment Variable | Description | Commandline Option (if any) | +|--------------------------------|-------------------------------|-----------------------------| +| ELEKTRON_EXECUTABLE_NAME | Name of the elektron executable. Default = elektron | +| ELEKTRON_MESOS_MASTER_LOCATION | HOST:PORT of the mesos master. Default = localhost:5050 | `-master` | +| ELEKTRON_WORKLOAD | Filename of workload json to be scheduled. Default = workload_sample.json | `-workload` | +| ELEKLTRON_LOGDIR_PREFIX | Prefix of the log directory generated. Default = Elektron-Test-Run | `-logPrefix` | + +Use the below command to run elektron using the docker-compose setup. +```commandline + docker-compose run elektron +``` +The Mesos master UI can be viewed from the host machine using _http://localhost:5050_. + +If any other commandline options need to be specified, for example using the [bin-packing](./schedulers/bin-packing.go) scheduling policy, use the below command. +```commandline +docker-compose run elektron -schedPolicy bin-packing +``` + ### Workload Use the `-workload` option to specify the location of the workload json file. Below is an example workload. ```json diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..5ce0907 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,86 @@ +version: "2" + +services: + zk: + image: rdelvalle/zookeeper + restart: on-failure + ports: + - "2181:2181" + environment: + ZK_CONFIG: tickTime=2000,initLimit=10,syncLimit=5,maxClientCnxns=128,forceSync=no,clientPort=2181 + ZK_ID: 1 + networks: + elektron-cluster: + ipv4_address: 19.16.4.3 + logging: + driver: none + + mesos-master: + image: rdelvalle/mesos-master:1.5.1 + restart: on-failure + ports: + - "5050:5050" + environment: + MESOS_ZK: zk://19.16.4.3:2181/mesos + MESOS_QUORUM: 1 + MESOS_HOSTNAME: localhost + MESOS_CLUSTER: test-cluster + MESOS_REGISTRY: replicated_log + MESOS_WORK_DIR: /tmp/mesos + networks: + elektron-cluster: + ipv4_address: 19.16.4.4 + logging: + driver: none + depends_on: + - zk + + mesos-agent: + image: pkaushi1/mesos-agent-elektron:1.5.1 + pid: host + restart: on-failure + ports: + - "5051:5051" + environment: + MESOS_MASTER: zk://19.16.4.3:2181/mesos + MESOS_CONTAINERIZERS: mesos,docker + MESOS_ISOLATION: cgroups/cpu + MESOS_PORT: 5051 + MESOS_HOSTNAME: localhost + MESOS_RESOURCES: ports(*):[11000-11999] + MESOS_SYSTEMD_ENABLE_SUPPORT: 'false' + MESOS_WORK_DIR: /tmp/mesos + networks: + elektron-cluster: + ipv4_address: 19.16.4.5 + logging: + driver: none + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup + - /var/run/docker.sock:/var/run/docker.sock + depends_on: + - mesos-master + + elektron: + image: pkaushi1/elektron:v1 + restart: on-failure + environment: + ELEKTRON_EXECUTABLE_NAME: elektron + ELEKTRON_WORKLOAD: workload_sample.json + ELEKTRON_MESOS_MASTER_LOCATION: 19.16.4.4:5050 + ELEKTRON_LOGDIR_PREFIX: elektron-test-run + HOST_IP: ${HOST_IP} + networks: + elektron-cluster: + ipv4_address: 19.16.4.6 + volumes: + - ./:/elektron + depends_on: + - mesos-agent + +networks: + elektron-cluster: + ipam: + config: + - subnet: 19.16.4.0/16 + gateway: 19.16.4.1 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..2f49869 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Accessing host machine's ip address. +hostip=$HOST_IP + +# setting up metrics to be monitored. +# creating PCP config with the cpu and memory usage metrics to be monitored. +cat >config < Date: Thu, 7 Nov 2019 18:52:09 -0500 Subject: [PATCH 2/5] fixed logdir prefix for consistency with Dockerfile --- .gitignore | 2 +- docker-compose.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b053e85..415d93b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ # name of executable when built using command 'go build' elektron # test log directory name. -elektron-test-run* +Elektron-Test-Run* diff --git a/docker-compose.yaml b/docker-compose.yaml index 5ce0907..547d83f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -68,7 +68,7 @@ services: ELEKTRON_EXECUTABLE_NAME: elektron ELEKTRON_WORKLOAD: workload_sample.json ELEKTRON_MESOS_MASTER_LOCATION: 19.16.4.4:5050 - ELEKTRON_LOGDIR_PREFIX: elektron-test-run + ELEKTRON_LOGDIR_PREFIX: Elektron-Test-Run HOST_IP: ${HOST_IP} networks: elektron-cluster: From b29bbb2f798b7ee43f0d98b0dccd3e5ebfdb31b3 Mon Sep 17 00:00:00 2001 From: Pradyumna Kaushik Date: Thu, 7 Nov 2019 19:13:21 -0500 Subject: [PATCH 3/5] added license --- entrypoint.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 2f49869..84fd691 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,21 @@ #!/usr/bin/env bash +# Copyright (C) 2018 spdfg +# +# This file is part of Elektron. +# +# Elektron is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Elektron is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Elektron. If not, see . +# # Accessing host machine's ip address. hostip=$HOST_IP From f41f7ef2c4f380cbe7bf030f9ac63d69940acd5d Mon Sep 17 00:00:00 2001 From: Pradyumna Kaushik Date: Thu, 7 Nov 2019 19:17:08 -0500 Subject: [PATCH 4/5] added license --- docker-compose.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index 547d83f..6c1a993 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,3 +1,20 @@ +# Copyright (C) 2018 spdfg +# +# This file is part of Elektron. +# +# Elektron is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Elektron is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Elektron. If not, see . +# version: "2" services: From f974fa8b841ec2c182469069d8938354f4161877 Mon Sep 17 00:00:00 2001 From: Pradyumna Kaushik Date: Fri, 8 Nov 2019 17:13:39 -0500 Subject: [PATCH 5/5] change mesos-agent + elektron image to spdf repo --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 6c1a993..80b6e06 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -53,7 +53,7 @@ services: - zk mesos-agent: - image: pkaushi1/mesos-agent-elektron:1.5.1 + image: spdf/mesos-agent-elektron:1.5.1 pid: host restart: on-failure ports: @@ -79,7 +79,7 @@ services: - mesos-master elektron: - image: pkaushi1/elektron:v1 + image: spdf/elektron:v1 restart: on-failure environment: ELEKTRON_EXECUTABLE_NAME: elektron