Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Minimal Mesosphere DC/OS v1.9 (With Only 1 Node)

DZone's Guide to

Minimal Mesosphere DC/OS v1.9 (With Only 1 Node)

This lightweight deploy of Mesosphere DC/OS is perfect for tooling around with containers and microservices while keeping the overhead low.

· Cloud Zone ·
Free Resource

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

Mesosphere DC/OS is built on top of Apache Mesos, which is a leading open-source framework for distributed applications. The key design differentiation is its two-level scheduler, which enables it to handle complex workloads like Big Data analytics, grid computing, etc.

The official recommendation for a lab-install is Vagrant, which may not be available in most of the big enterprise environments (for obvious reasons).

In this article, we’ll go over the procedure for setting up a tiny DC/OS cluster using a single VM and a demonstration of basic orchestration capabilities using the Marathon framework.

Requirements

  • One VM only! (for a resource constrained lab or laptop)
  • CentOS 7.3 Minimal + SELINUX disabled + Firewall disabled + IPv6 disabled
  • Docker (docker-ce 17.06.0.ce)

Configuration

Host Role VM Size
mesos-single bootstrap + master + slave + dcos-cli 2 CPU, 6GB RAM, 60GB HDD

Prerequisites

NOTE: Set proxy-related environment variables if needed.

# only if proxy is needed
export http_proxy="http://192.168.20.225:3128"
export https_proxy="http://192.168.20.225:3128"
# get yum repo for docker-ce
curl -sfo /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo

# install docker-ce and other required packages
yum install -y epel-release docker-ce tar xz unzip curl ipset chrony
groupadd nogroup
# clean yum cache (optional)
yum clean all

# only if proxy is needed
# proxy needed - start
mkdir -p /etc/systemd/system/docker.service.d

cat > /etc/systemd/system/docker.service.d/override.conf << '__EOF__'
[Service] 
Environment="HTTP_PROXY=http://192.168.20.225:3128"
Environment="HTTPS_PROXY=http://192.168.20.225:3128"
Environment="NO_PROXY=localhost,127.0.0.0/8,192.168.20.0/24,*.sudhaker.com"
__EOF__

systemctl daemon-reload
# proxy needed - end

# enable and start docker
systemctl enable docker
systemctl start docker

# add to host file if DNS doesn't resolve the hostname
tee -a /etc/hosts << '__EOF__'
192.168.20.80 mesos-single
__EOF__


To Be Run for Bootstrap

Generate bootstrap:

# create setup directory, download the install binary
mkdir /opt/dcos-setup && cd /opt/dcos-setup && curl -O https://downloads.dcos.io/dcos/stable/dcos_generate_config.sh

# create config directory 
mkdir -p genconf

# create ip-detect script; change 'ens192' if needed
cat > genconf/ip-detect << '__EOF__'
#!/usr/bin/env bash
set -o nounset -o errexit
export PATH=/usr/sbin:/usr/bin:$PATH
echo $(ip addr show ens192 | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
__EOF__
chmod 755 genconf/ip-detect

### VERY IMPORTANT: validate that the following ip-detect is working
### if not then follow https://dcos.io/docs/1.9/administration/installing/custom/advanced/
###   to get a working script, must work consistently on this node
./genconf/ip-detect

# configuration yaml
cat > genconf/config.yaml << '__EOF__'
---
bootstrap_url: http://mesos-single:8081       
cluster_name: dcos
exhibitor_storage_backend: static
master_discovery: static
master_list:
- 192.168.20.80
resolvers:
- 8.8.4.4
- 8.8.8.8
telemetry_enabled: 'false'
# only if proxy is needed
use_proxy: 'true'
http_proxy: http://192.168.20.225:3128
https_proxy: http://192.168.20.225:3128
no_proxy:
- localhost
- 127.0.0.0/8
- 192.168.20.0/24
- '*.sudhaker.com'
__EOF__

# generate bootstarp
bash dcos_generate_config.sh


Launch bootstrap:

# serve the bootstrap code-base using tiny nginx (alpine based)
docker pull nginx:alpine
docker run -d --restart=unless-stopped -p 8081:80 -v /opt/dcos-setup/genconf/serve:/usr/share/nginx/html:ro --name=dcos-bootstrap-nginx nginx:alpine


To Be Run for {master}

mkdir -p /tmp/dcos && cd /tmp/dcos && curl -O --noproxy '*' http://mesos-single:8081/dcos_install.sh && bash dcos_install.sh master && cd -


The installation's progress can be seen at the exhibitor URL, i.e. http://192.168.20.80:8181/

Install dcos-cli (while we are waiting for the master to come up).

mkdir -p ~/bin && cd ~/bin && curl -sfO https://downloads.dcos.io/binaries/cli/linux/x86-64/0.4.17/dcos && chmod 755 ~/bin/dcos && cd -

dcos config set core.dcos_url http://192.168.20.80
dcos auth login


To Be Run for {slave}

NOTE: This is the tweak for running a slave on the master node (not supported officially, may break in future releases).

export opt_mesos=$(ls -1d /opt/mesosphere/packages/mesos--*)
ln -s $opt_mesos/dcos.target.wants_slave/dcos-mesos-slave.service /etc/systemd/system
ln -s $opt_mesos/dcos.target.wants_slave/dcos-mesos-slave.service /etc/systemd/system/dcos.target.wants
systemctl start dcos-mesos-slave


DC/OS UI

Browse to http://192.168.20.80 (when ready, usually takes 5-to-10 minutes):

DC/OS v1.9 UI

Install the Tiny marathon-lb (0.1 CPU, 128mb RAM)

IMPORTANT: The dcos package-based install won’t allow our proposed tiny configuration, so we’ll use Marathon!

Export the Marathon JSON:

# allows to run on slave and skip port 80+443 binding
cat > marathon-lb-internal.json << '__EOF__'
{ "marathon-lb":{ "name": "marathon-lb-internal", "instances": 1, "haproxy-group": "internal", "role": "", "bind-http-https": false} }
__EOF__
# export the marathon configuration (for tweaking)
dcos package describe --app --render marathon-lb --options=marathon-lb-internal.json > marathon-lb.json


Edit the JSON. Use sed or manually edit it. Set cpu to 0.1 and mem to 128 (more than enough for a demo setup):

sed -i 's/"cpus": 2/"cpus": 0.1/' marathon-lb.json
sed -i 's/ "mem": 1024/ "mem": 128/' marathon-lb.json


Let marathon deploy this app:

dcos marathon app add marathon-lb.json

Install the Demo App (dockercloud/hello-world)

Our demo app for this setup is dockercloud/hello-world

cat > dockercloud-hello-world.json << '__EOF__'
{
    "id": "dockercloud-hello-world",
    "container": {
        "type": "DOCKER",
        "docker": {
            "image": "dockercloud/hello-world",
            "network": "BRIDGE",
            "portMappings": [
                { "hostPort": 0, "containerPort": 80, "servicePort":10000 }
            ],
            "forcePullImage":true
        }
    },
    "instances": 2,
    "cpus": 0.1,
    "mem": 128,
    "healthChecks": [{
        "protocol": "HTTP",
        "path": "/",
        "portIndex": 0,
        "timeoutSeconds": 10,
        "gracePeriodSeconds": 10,
        "intervalSeconds": 2,
        "maxConsecutiveFailures": 10
    }],
    "labels":{
        "HAPROXY_GROUP":"internal"
    }
}
__EOF__

# deploy the demo app
dcos marathon app add dockercloud-hello-world.json


Browse to => http://192.168.20.80:10000/ or run the following command:

for i in $(seq 1 5); do curl -sf http://192.168.20.80:10000/ | grep -oP "My hostname is [0-9,a-z]+"; done


Output:

My hostname is 705bc9fdf535
My hostname is d74cf174fff0
My hostname is 705bc9fdf535
My hostname is d74cf174fff0
My hostname is 705bc9fdf535

Summary

The single node DC/OS setup has a lower (roughly 3GB) resource/memory overhead and can be great for learning and trying out simple container/microservice workloads. It is possible to run additional non-distributed frameworks (like Jenkins) if adequate RAM is available.

Have fun!

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

Topics:
mesosphere ,dcos ,cloud ,microservices ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}