+ All Categories
Home > Software > Ansible Oxford - Cows & Containers

Ansible Oxford - Cows & Containers

Date post: 16-Aug-2015
Category:
Upload: jonatanblue
View: 101 times
Download: 1 times
Share this document with a friend
25
Ansible Oxford Cows and Containers 29 th July 2015 DevSpace/Hatch/old Barclays, Oxford
Transcript

Ansible Oxford

Cows and Containers 29th July 2015

DevSpace/Hatch/old Barclays, Oxford

Ansible

Runs a TASK on a HOST

Problem:

How do I configure my servers and services?

Solution:Write playbooks with tasks, bundle into roles and run

against your hosts localhost for services

Docker

Virtualised OS

New problems:How do I build my Dockerimages? How do I run my containers? How do I ship them?

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/

“works”Time spent troubleshooting

counted in days Revert back to shell commands for

configuration

Build with Ansible

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

Distributed applications

• Scheduling • Active orchestration

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)

•Build image •? •Run container

Ship with 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

Jonatan Bjork DevOps Engineer

@jonatanblue


Recommended