How to Rapidly Deploy DCOS Services with Ansible and Docker
This guide walks through an automated, fast‑track deployment of DCOS components—including service selection, Docker‑based containers, host initialization, system checks, Ansible provisioning, Consul service discovery, HAProxy load balancing, MySQL HA, and Zookeeper/Marathon integration—providing concrete commands, configuration snippets, and practical tips.
1. Overview of Services and Components
Core services used in the DCOS deployment include Ansible, a test yum repository created with createrepo, a private Docker registry secured by a self‑signed certificate, a simple HTTP server, Docker as the container runtime, cAdvisor for monitoring, HAProxy for load balancing, Keepalived for high availability, MySQL in a master‑slave configuration, custom DCOS UI components, Consul for service discovery and health checks, Zookeeper, Mesos, Marathon, and the DCOS resource manager.
2. Functional Architecture and Logic
Installation scripts first verify whether a service already exists; if it does, the script aborts for manual verification. Key components are:
Test yum repo : lightweight yum source built with createrepo that hosts required RPMs.
Test Docker registry : private registry without authentication, using a self‑signed certificate; all component images are pushed once and reused.
Consul : provides health checks, service discovery, and MySQL master‑slave failover. Services register via the Consul client API, and health checks run locally on each client.
HAProxy : external load balancer that routes traffic to services registered in Consul. HAProxy 1.6 is used to enable dynamic DNS resolution.
MySQL HA : master‑slave pair registers four Consul services (master, slave, and their health checks). When the master disappears, the virtual IP resolves to the slave.
Zookeeper / Mesos / Marathon : referenced for further reading.
3. Dockerizing Services
Typical Dockerfile instructions: FROM – base image RUN – execute shell commands ADD – add files or download archives COPY – copy local files ENTRYPOINT – default container command CMD – default parameters
Reference: https://docs.docker.com/engine/reference/builder/
Example build and run commands:
docker build -t my-zookeeper . docker run -d --name zookeeper my-zookeeper4. Installing the Control Host
Start the test yum repository and add a file /etc/yum.repos.d/test.repo pointing to it. Install essential tools:
yum --disablerepo=* --enablerepo=testrepo install -y net-tools iptables ansibleConfigure the NTP client as part of the host setup.
5. System Pre‑Installation Checks
Yum repository status
Test Docker registry health
NTP server synchronization
Operating system and kernel version
Filesystem layout
Disk capacity
If any check fails, the installation aborts.
6. Host Initialization
Disable firewalls and SELinux
Configure hostname and DNS resolution
Set up NTP client
Install and configure Docker
Install debugging tools (netstat, dig, etc.)
Verify post‑initialization environment
7. Cluster Initialization with Ansible
Prepare Ansible inventory files describing master nodes, worker nodes, MySQL hosts, Keepalived VIPs, and other roles. Playbooks perform:
Installation of Docker images and service agents (Consul, HAProxy, Keepalived, MySQL, Zookeeper, etc.)
Registration of each service to Consul
Dynamic DNS configuration for HAProxy
MySQL master‑slave registration and health‑based VIP failover
8. Summary
The DCOS deployment is abstracted into two steps: (1) define all services and parameters in a single configuration file; (2) execute the Ansible‑driven installation script. The current solution works for small‑scale clusters; performance improvements are planned for large‑scale host provisioning.
Additional resources:
OpenDockerFile repository: https://github.com/Dataman-Cloud/OpenDockerFile
Related article on container‑based product iteration: http://blog.dataman-inc.com/shurenyun-docker-164/
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
dbaplus Community
Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
