Date post: | 16-Aug-2015 |
Category: |
Software |
Upload: | jonatanblue |
View: | 101 times |
Download: | 1 times |
Solution:Write playbooks with tasks, bundle into roles and run
against your hosts localhost for services
First stabWrite a Dockerfile (basically a shell script written as a children's book)
RUN apt-get update RUN apt-get –y install awesomeCOPY myfile /tmp/
Dockerfile: 1. Install Ansible 2. Copy over/git clone Ansible project 3. Run Ansible playbook against localhost
Pros: - Re-use existing playbooks - Portability (VM!container)
Cons: - Ansible installed in container
$ cat myapp/Dockerfile FROM ubuntu:14.04 MAINTAINER jonatanblue version: 0.3 # Install Ansible RUN apt-get -y update && apt-get install -y software-properties-common RUN echo | apt-add-repository ppa:ansible/ansible RUN apt-get -y update && apt-get -y install ansible # Copy over playbook COPY moo/container.yml /tmp/ # Run playbook RUN ansible-playbook /tmp/container.yml
- name: build image docker_image: name: “jonatanblue/myapp:0.3”
OR ( if because above is still a bit unstable)
$ cd myapp
$ docker build --tag=“jonatanblue/myapp:0.3” .
Run with Ansible* “Static” workloads – docker module
* Distributed applications – … it’s complicated
docker module - name: my app docker: name: myapp image: jonatanblue/myapp:0.3 command: /usr/bin/myapp --mode awesome
Active orchestration 1. Resources (busy, free, time to
release, control) 2. Running containers 3. Application health
• Act on this information • Automatic control problem != trivial
Example on AWS Server1: 2 of 4 cores & 6 of 8GB RAM freeServer2: 4 of 4 cores & 8 of 8GB RAM free
Requirements Container1: 1core, 1GB Other stats: No containers started in last hour, historical data suggests off-peak period ! Launch container on server1 and terminate server2
Mesos - a single pool of resources http://mesos.apache.org/ Kubernetes - orchestration system http://kubernetes.io/
2 observations • Applications to manage Docker
(deployed by Ansible) • Docker in docker in docker… Registry
great example (built & started by Ansible)
• Easy method ! DockerHub – Public (pay for private)
• Full control ! Registry –Open source version free – (pay for enterprise version)
• Build image (Ansible playbooks + docker_image)
• Push to registry (Ansible command module)
• Run container (Ansible docker module)
Private Registry