SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
WHEN DOCKER ENDS
CHEF BEGINS
Hello!
I AM GIOVANNI TORALDO
Open Source enthusiast with SuperCow Powers
PHP/Java/whatever developer
writer of the OpenNebula book
Lead Developer @ ClouDesire
WHAT IS CLOUDESIRE?
Application Marketplace
◦ Helps S/M software vendors
◦ For simple applications it can
▫ provision VM
▫ on multiple cloud providers
▫ monitor resources
◦ For complex applications
▫ expose REST API
◦ For everyone
▫ manage subscriptions, billing, pay-
per-use, invoicing, payments
WOULD YOU BE MY CONTAINER?1
DOCKER: WHAT IS IT?
Enables software developers to
◦ package an application
◦ with all dependencies
◦ runs it everywhere unchanged
DOCKER: WHAT IS THE POINT?
Enables system administrators to
◦ simplify application deployment
◦ ease scale-up & scale-down
◦ processes separation
DOCKER: UNDERLYING TECHNOLOGIES
◦ Linux namespaces
◦ Control Groups (cgroups)
◦ Layered filesystems
◦ LXC (now libcontainer)
DOCKER: GLOSSARY
◦ Image: immutable snapshot of a
container, push/pull repository
◦ Container: an instance launched
from an image
◦ Volume: persistent writable area
of a container
◦ Registry: repository of images
(versioned via tags)
◦ Dockerfile: the descriptor from
which an image is built
DOCKER: HOW DO I RUN IT?
◦ GNU/Linux
wget -qO- https://get.docker.com/ | sh
◦ Windows
https://github.com/boot2docker/windows-installer/releases/latest
◦ OSX
https://kitematic.com/download/
◦ Hello world
$ docker run -ti ubuntu:14.04 /bin/bash
DOCKER: WHAT HAPPENS UNDER THE HOOD?
◦ Pulls the ubuntu image from registry
◦ Creates a new container
▫ Allocates a rw filesystem
▫ Allocates a network interface (on a bridge)
▫ Sets up network (IP address, dns..)
◦ Launch a process in the container
◦ Captures and provides application
output
Container terminates when the process
exit
DOCKER: A SIMPLE DOCKERFILE
DOCKER: STANDARD WORKFLOW
Build & push:
◦ docker build -t gionn/nodejs-app:1.0.0 .
▫ a tagged image is generated
◦ docker push gionn/nodejs-app:1.0.0
▫ publish to repository
Pull & run:
◦ docker pull gionn/nodejs-app:1.0.0
▫ fetch from repository
◦ docker run gionn/nodejs-app:1.0.0
▫ run container from this image
Example gist: link
DOCKER: ROUGH EDGE #1
Service in container A needs to
talk to service in container B
Docker solution:
◦ Use Container Links
Reality:
◦ Works only on the same host
◦ Ordered sequence to boot-up
◦ Can’t solve cyclic dependencies
DOCKER: ROUGH EDGE #2
My containerized application needs
environment-dependant
configurations
Docker solution:
◦ Inject environment variables
Reality:
◦ I need to fill YAML, XML, JSON
complex structures
DOCKER: ROUGH EDGE #3
I need to manage and upgrade a
non-trivial number of containers on
multiple hosts
Docker solution:
◦ Docker Swarm
Reality:
◦ currently in beta, not recommend
for production
DOCKER: RECAP
So far so good?
Docker is a piece of cake for
wrapping together the
technologies of Linux containers,
multi-layered filesystems and an
image build system, in an unique
tool easy and fast to use.
DOCKER: RECAP
But what about the environment?
Being a (relatively) young project,
the ecosystem of tools is pretty
scattered and inconsistent.
WHO YOU GONNA CALL?2
WHO YOU GONNA CALL?
Probably someone has solved this
kind of issues far time ago, even
before Docker existed?
Those kind of problems are all
about configuration management
and automation.
So use the tools already available.
CHEF
Chef enables you to:
◦ Version your infrastructure on
SCM, build an artifact
◦ Apply testing, CI, CD to
infrastructure
◦ Keep it aligned with your
software
◦ Automation via repeatable
actions (e.g. click to deploy)
CHEF: THE TOOLS
Everything you need in a single
package:
https://downloads.chef.io/chef-dk/
For (automated) testing
https://www.vagrantup.com
https://www.virtualbox.org
CHEF: EVERYTHING IS IN A REPOSITORY
The chef-repo is a standard repo
layout and contains:
◦ Cookbooks
◦ Environments
◦ Data bags
◦ Roles
CHEF: WHAT IS A COOKBOOK
Each cookbook is coupled with a
service (e.g. mysql).
Contains:
◦ Attributes: they are like global
variables (e.g. version to install)
◦ Recipes: an atomic unit of
configuration
◦ Templates: patterns to generate
real files, filled with data
◦ Files: static configuration
CHEF RECIPES
Each recipe contains behaviour
expressed by resources (and Ruby
code)
user_name = ‘gionn’
user user_name do
supports :manage_home => true
uid 1000
gid 'users'
home “/home/#{user_name}”
shell '/bin/bash'
password '$1$JJsvHslV$szsCjVEroftprNn4JHtDi'
end
CHEF COMPONENTS
The remaining components:
◦ Environments: contains common
attributes for a group of nodes
◦ Roles: contains attributes for
nodes sharing a particular
behaviour
◦ Data bags: general-purpose
JSON data, optionally
encrypted, usually to store
credentials
COOKBOOKS FOR EVERY NEEDS
All cookbooks are usually hosted
on GitHub
◦ Maintained by Opscode
https://github.com/opscode-cookbooks
◦ by vendors
https://github.com/elastic/cookbook-elasticsearch
◦ by the community
https://supermarket.chef.io
Community Stats (07/04/2015)
2,120 Cookbooks ~ 62,086 Chefs
ONE DOES NOT SIMPLY COOK A WHALE3
DOCKER COOKBOOK
https://github.com/bflad/chef-docker
◦ Install docker daemon on
supported platforms
▫ Ubuntu/Debian
▫ RHEL/CentOS/Fedora
▫ Amazon Linux
◦ Expose attributes for fine-tuning
(e.g. TLS certificates, DNS)
◦ Manage images & containers
lifecycle via ad-hoc resources
PROBLEM #0: IMAGE DISTRIBUTION / RUN CONTAINER
docker_image 'registry:0.9.0' do
action :pull
notifies :redeploy, 'docker_container[registry]', :immediately
end
docker_container 'registry' do
container_name 'registry'
image 'registry:0.9.0'
detach true
port '5000:5000'
volume '/srv/registry:/tmp/registry'
env 'SETTINGS_FLAVOR=local'
env 'SEARCH_BACKEND=sqlalchemy'
action :run
end
PROBLEM #0: IMAGE DISTRIBUTION / RUN CONTAINER
Check that docker has such tagged
image and if not:
◦ Download that version
◦ Stop existing container (if any)
◦ Run new container
◦ Raise error if anything goes wrong
PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION
Populate configuration files with
proper values (and automatically
restart on changes)
template node['tomcat']['host'] + '/cmw.xml' do
source 'tomcat/tomcat-context.xml.erb'
variables(
:resource_name => 'jdbc/datasource',
:username => node['cloudesire']['name'],
:password => node['cloudesire']['pass']
:url => node['cloudesire']['url'],
)
notifies :redeploy, 'docker_container[cmw]'
end
PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION
tomcat-context.xml.erb
<Context>
<Resource auth="Container"
driverClassName="org.postgresql.Driver"
initialSize="<%= @node['cloudesire']['backend']['db_pool']['min'] %>"
maxActive="<%= @node['cloudesire']['backend']['db_pool']['max'] %>"
maxIdle="<%= @node['cloudesire']['backend']['db_pool']['idle'] %>"
maxWait="<%= @node['cloudesire']['backend']['db_pool']['wait'] %>"
name="<%= @resource_name %>"
url="<%= @url %>"
username="<%= @username %>"
password="<%= @password %>"
type="javax.sql.DataSource"
validationQuery="select 1"
testOnBorrow="true"
/>
</Context>
PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION
Templates consist of:
◦ an .ERB template
◦ a template resource declared in
a recipe
The template is evaluated using
the variables passed directly or via
the global node object.
PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION
Inject a single file or entire folders
dst = node['tomcat']['base'] + '/conf/Catalina/' +
'localhost/cmw.xml'
docker_container 'cmw' do
image image_name
container_name 'cmw'
detach true
env LOG debug
volume [
"#{node['tomcat']['host']}/cmw.xml:#{dst}",
"/etc/cloudesire:/etc/cloudesire"
]
end
PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION
Docker permits defining volumes
to be used for persistent data (e.g.
database files), but may be used
to inject configurations into the
container at runtime.
Definitevely avoid the needs of
image rebuilding to adjust a
setting.
PROBLEM #2: CONTAINERS RUNNING ON MULTIPLE HOSTS
Each node has its own run_list,
defining which recipes should be
executed (in JSON):
{
“run_list”: [
"cd-infrastructure::docker-cmw",
"cd-infrastructure::docker-deployer",
"cd-infrastructure::docker-monitor",
"cd-infrastructure::docker-logger"
],
“cloudesire”: {
“key”: “value”
}
}
PROBLEM #2: CONTAINERS RUNNING ON MULTIPLE HOSTS
Same recipe on different nodes
(attributes may change)
node1.json
{
“run_list”: [
"cd-infrastructure::docker-cmw",
"cd-infrastructure::docker-logger"
]
}
node2.json
{
“run_list”: [
"cd-infrastructure::docker-deployer",
"cd-infrastructure::docker-monitor",
"cd-infrastructure::docker-logger"
]
}
MAY NOT BE GOLD BUT IT’S A START FOR SURE!
It’s easy to getting started with
Chef by using kitchen-ci or plain
Vagrant:
◦ Initialize a chef repo
◦ Create a new cookbook
◦ Start hacking
◦ Play on kitchen-ci or vagrant
◦ Repeat last 2
KITCHEN.YML EXAMPLE
$ kitchen converge
driver:
name: vagrant
provisioner:
name: chef_solo
platforms:
- name: ubuntu-1404
suites:
- name: default
run_list:
- recipe[mycookbook::docker-whatever]
attributes: { foo: "bar" }
READY TO USE CHEF REPOSITORY
A starting repository for aspiring
whale cookers:
https://github.com/gionn/cooking-
docker
DOCKER APPENDIX: GOLDEN RULES
◦ Only one process per Image
◦ No embedded configuration
◦ No, you don’t need SSH
◦ No, you don’t need syslog
◦ No, you won’t touch a running
container to adjust a thing
◦ No, you will not use a
community-contributed image
without looking at what it do
Thanks!
ANY QUESTIONS?
You can find me at:
@gionn on twitter / github
me@gionn.net
giovanni.toraldo@cloudesire.com

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Intro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and WindowsIntro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and Windows
 
Docker 原理與實作
Docker 原理與實作Docker 原理與實作
Docker 原理與實作
 
Ansible docker
Ansible dockerAnsible docker
Ansible docker
 
Docker linuxday 2015
Docker linuxday 2015Docker linuxday 2015
Docker linuxday 2015
 
Docker Compose to Production with Docker Swarm
Docker Compose to Production with Docker SwarmDocker Compose to Production with Docker Swarm
Docker Compose to Production with Docker Swarm
 
From Docker Run To Docker Compose
From Docker Run To Docker ComposeFrom Docker Run To Docker Compose
From Docker Run To Docker Compose
 
GDG Lima - Docker Compose
GDG Lima - Docker ComposeGDG Lima - Docker Compose
GDG Lima - Docker Compose
 
Academy PRO: Docker. Lecture 3
Academy PRO: Docker. Lecture 3Academy PRO: Docker. Lecture 3
Academy PRO: Docker. Lecture 3
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
 
Docker orchestration
Docker orchestrationDocker orchestration
Docker orchestration
 
Infrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & AnsibleInfrastructure Deployment with Docker & Ansible
Infrastructure Deployment with Docker & Ansible
 
Iniciando com Docker
Iniciando com DockerIniciando com Docker
Iniciando com Docker
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
 
Docker compose
Docker composeDocker compose
Docker compose
 
Containerizing Web Application with Docker
Containerizing Web Application with DockerContainerizing Web Application with Docker
Containerizing Web Application with Docker
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Linux Containers (LXC)
Linux Containers (LXC)Linux Containers (LXC)
Linux Containers (LXC)
 
Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014
 
Surveillance on slam technology
Surveillance on slam technologySurveillance on slam technology
Surveillance on slam technology
 
Austin - Container Days - Docker 101
Austin - Container Days - Docker 101Austin - Container Days - Docker 101
Austin - Container Days - Docker 101
 

Destacado

Sabrina scarborough Endocrine System Suffixes Chpt 11
Sabrina scarborough  Endocrine System Suffixes  Chpt 11Sabrina scarborough  Endocrine System Suffixes  Chpt 11
Sabrina scarborough Endocrine System Suffixes Chpt 11
sscarborough
 
Museo San Marco
Museo San MarcoMuseo San Marco
Museo San Marco
elena_r
 

Destacado (7)

Sabrina scarborough Endocrine System Suffixes Chpt 11
Sabrina scarborough  Endocrine System Suffixes  Chpt 11Sabrina scarborough  Endocrine System Suffixes  Chpt 11
Sabrina scarborough Endocrine System Suffixes Chpt 11
 
Museo San Marco
Museo San MarcoMuseo San Marco
Museo San Marco
 
Para mi bb emoxo
Para mi bb emoxoPara mi bb emoxo
Para mi bb emoxo
 
Open@BNCF
Open@BNCFOpen@BNCF
Open@BNCF
 
Introduction to Continuous Delivery
Introduction to Continuous DeliveryIntroduction to Continuous Delivery
Introduction to Continuous Delivery
 
Airborne And Wax Cotton
Airborne And Wax CottonAirborne And Wax Cotton
Airborne And Wax Cotton
 
Easy applications deployment on OpenStack clouds
Easy applications deployment on OpenStack cloudsEasy applications deployment on OpenStack clouds
Easy applications deployment on OpenStack clouds
 

Similar a When Docker ends, Chef begins ~ #idi2015 Incontro DevOps Italia

Similar a When Docker ends, Chef begins ~ #idi2015 Incontro DevOps Italia (20)

Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 
ContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small businessContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small business
 
Docker dDessi november 2015
Docker dDessi november 2015Docker dDessi november 2015
Docker dDessi november 2015
 
Continuous Integration with Docker on AWS
Continuous Integration with Docker on AWSContinuous Integration with Docker on AWS
Continuous Integration with Docker on AWS
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and image
 
Docker+java
Docker+javaDocker+java
Docker+java
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Run automated tests in Docker
Run automated tests in DockerRun automated tests in Docker
Run automated tests in Docker
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
 
Introduction to Containers & Diving a little deeper into the benefits of Con...
 Introduction to Containers & Diving a little deeper into the benefits of Con... Introduction to Containers & Diving a little deeper into the benefits of Con...
Introduction to Containers & Diving a little deeper into the benefits of Con...
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
Introduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New YorkIntroduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New York
 
Cloud Native Computing - Part III - Containers
Cloud Native Computing - Part III - ContainersCloud Native Computing - Part III - Containers
Cloud Native Computing - Part III - Containers
 
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Docker
 

Más de Giovanni Toraldo

Continuous Delivery: 5 years later (Incontro DevOps 2018)
Continuous Delivery: 5 years later (Incontro DevOps 2018)Continuous Delivery: 5 years later (Incontro DevOps 2018)
Continuous Delivery: 5 years later (Incontro DevOps 2018)
Giovanni Toraldo
 
Docker in production service discovery with consul - road to opscon 2015
Docker in production  service discovery with consul - road to opscon 2015Docker in production  service discovery with consul - road to opscon 2015
Docker in production service discovery with consul - road to opscon 2015
Giovanni Toraldo
 
Cloud Computing in practice with OpenNebula ~ Develer workshop 2012
Cloud Computing in practice with OpenNebula ~ Develer workshop 2012Cloud Computing in practice with OpenNebula ~ Develer workshop 2012
Cloud Computing in practice with OpenNebula ~ Develer workshop 2012
Giovanni Toraldo
 
An introduction to cloud computing
An introduction to cloud computingAn introduction to cloud computing
An introduction to cloud computing
Giovanni Toraldo
 

Más de Giovanni Toraldo (11)

About code review and BUGS
About code review and BUGSAbout code review and BUGS
About code review and BUGS
 
Introduction to Traefik
Introduction to TraefikIntroduction to Traefik
Introduction to Traefik
 
Managing GCP Projects with Terraform (devfest Pisa 2018)
Managing GCP Projects with Terraform (devfest Pisa 2018)Managing GCP Projects with Terraform (devfest Pisa 2018)
Managing GCP Projects with Terraform (devfest Pisa 2018)
 
Continuous Delivery: 5 years later (Incontro DevOps 2018)
Continuous Delivery: 5 years later (Incontro DevOps 2018)Continuous Delivery: 5 years later (Incontro DevOps 2018)
Continuous Delivery: 5 years later (Incontro DevOps 2018)
 
Software Delivery in 2016 - A Continuous Delivery Approach
Software Delivery in 2016 - A Continuous Delivery ApproachSoftware Delivery in 2016 - A Continuous Delivery Approach
Software Delivery in 2016 - A Continuous Delivery Approach
 
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) ItalyClustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
Clustering with Docker Swarm - Dockerops 2016 @ Cento (FE) Italy
 
Docker in production service discovery with consul - road to opscon 2015
Docker in production  service discovery with consul - road to opscon 2015Docker in production  service discovery with consul - road to opscon 2015
Docker in production service discovery with consul - road to opscon 2015
 
ClouDesire @ Italian DevOps Initiative 2013 #idi2013
ClouDesire @ Italian DevOps Initiative 2013 #idi2013ClouDesire @ Italian DevOps Initiative 2013 #idi2013
ClouDesire @ Italian DevOps Initiative 2013 #idi2013
 
Cloud Computing in practice with OpenNebula ~ Develer workshop 2012
Cloud Computing in practice with OpenNebula ~ Develer workshop 2012Cloud Computing in practice with OpenNebula ~ Develer workshop 2012
Cloud Computing in practice with OpenNebula ~ Develer workshop 2012
 
An introduction to cloud computing
An introduction to cloud computingAn introduction to cloud computing
An introduction to cloud computing
 
EVA Florence 2012 ~ Open low-cost HA cluster cloud
EVA Florence 2012 ~ Open low-cost HA cluster cloudEVA Florence 2012 ~ Open low-cost HA cluster cloud
EVA Florence 2012 ~ Open low-cost HA cluster cloud
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 

When Docker ends, Chef begins ~ #idi2015 Incontro DevOps Italia

  • 2. Hello! I AM GIOVANNI TORALDO Open Source enthusiast with SuperCow Powers PHP/Java/whatever developer writer of the OpenNebula book Lead Developer @ ClouDesire
  • 3. WHAT IS CLOUDESIRE? Application Marketplace ◦ Helps S/M software vendors ◦ For simple applications it can ▫ provision VM ▫ on multiple cloud providers ▫ monitor resources ◦ For complex applications ▫ expose REST API ◦ For everyone ▫ manage subscriptions, billing, pay- per-use, invoicing, payments
  • 4. WOULD YOU BE MY CONTAINER?1
  • 5. DOCKER: WHAT IS IT? Enables software developers to ◦ package an application ◦ with all dependencies ◦ runs it everywhere unchanged
  • 6. DOCKER: WHAT IS THE POINT? Enables system administrators to ◦ simplify application deployment ◦ ease scale-up & scale-down ◦ processes separation
  • 7. DOCKER: UNDERLYING TECHNOLOGIES ◦ Linux namespaces ◦ Control Groups (cgroups) ◦ Layered filesystems ◦ LXC (now libcontainer)
  • 8.
  • 9. DOCKER: GLOSSARY ◦ Image: immutable snapshot of a container, push/pull repository ◦ Container: an instance launched from an image ◦ Volume: persistent writable area of a container ◦ Registry: repository of images (versioned via tags) ◦ Dockerfile: the descriptor from which an image is built
  • 10. DOCKER: HOW DO I RUN IT? ◦ GNU/Linux wget -qO- https://get.docker.com/ | sh ◦ Windows https://github.com/boot2docker/windows-installer/releases/latest ◦ OSX https://kitematic.com/download/ ◦ Hello world $ docker run -ti ubuntu:14.04 /bin/bash
  • 11. DOCKER: WHAT HAPPENS UNDER THE HOOD? ◦ Pulls the ubuntu image from registry ◦ Creates a new container ▫ Allocates a rw filesystem ▫ Allocates a network interface (on a bridge) ▫ Sets up network (IP address, dns..) ◦ Launch a process in the container ◦ Captures and provides application output Container terminates when the process exit
  • 12. DOCKER: A SIMPLE DOCKERFILE
  • 13. DOCKER: STANDARD WORKFLOW Build & push: ◦ docker build -t gionn/nodejs-app:1.0.0 . ▫ a tagged image is generated ◦ docker push gionn/nodejs-app:1.0.0 ▫ publish to repository Pull & run: ◦ docker pull gionn/nodejs-app:1.0.0 ▫ fetch from repository ◦ docker run gionn/nodejs-app:1.0.0 ▫ run container from this image Example gist: link
  • 14. DOCKER: ROUGH EDGE #1 Service in container A needs to talk to service in container B Docker solution: ◦ Use Container Links Reality: ◦ Works only on the same host ◦ Ordered sequence to boot-up ◦ Can’t solve cyclic dependencies
  • 15. DOCKER: ROUGH EDGE #2 My containerized application needs environment-dependant configurations Docker solution: ◦ Inject environment variables Reality: ◦ I need to fill YAML, XML, JSON complex structures
  • 16. DOCKER: ROUGH EDGE #3 I need to manage and upgrade a non-trivial number of containers on multiple hosts Docker solution: ◦ Docker Swarm Reality: ◦ currently in beta, not recommend for production
  • 17. DOCKER: RECAP So far so good? Docker is a piece of cake for wrapping together the technologies of Linux containers, multi-layered filesystems and an image build system, in an unique tool easy and fast to use.
  • 18. DOCKER: RECAP But what about the environment? Being a (relatively) young project, the ecosystem of tools is pretty scattered and inconsistent.
  • 19. WHO YOU GONNA CALL?2
  • 20. WHO YOU GONNA CALL? Probably someone has solved this kind of issues far time ago, even before Docker existed? Those kind of problems are all about configuration management and automation. So use the tools already available.
  • 21.
  • 22. CHEF Chef enables you to: ◦ Version your infrastructure on SCM, build an artifact ◦ Apply testing, CI, CD to infrastructure ◦ Keep it aligned with your software ◦ Automation via repeatable actions (e.g. click to deploy)
  • 23. CHEF: THE TOOLS Everything you need in a single package: https://downloads.chef.io/chef-dk/ For (automated) testing https://www.vagrantup.com https://www.virtualbox.org
  • 24. CHEF: EVERYTHING IS IN A REPOSITORY The chef-repo is a standard repo layout and contains: ◦ Cookbooks ◦ Environments ◦ Data bags ◦ Roles
  • 25. CHEF: WHAT IS A COOKBOOK Each cookbook is coupled with a service (e.g. mysql). Contains: ◦ Attributes: they are like global variables (e.g. version to install) ◦ Recipes: an atomic unit of configuration ◦ Templates: patterns to generate real files, filled with data ◦ Files: static configuration
  • 26. CHEF RECIPES Each recipe contains behaviour expressed by resources (and Ruby code) user_name = ‘gionn’ user user_name do supports :manage_home => true uid 1000 gid 'users' home “/home/#{user_name}” shell '/bin/bash' password '$1$JJsvHslV$szsCjVEroftprNn4JHtDi' end
  • 27. CHEF COMPONENTS The remaining components: ◦ Environments: contains common attributes for a group of nodes ◦ Roles: contains attributes for nodes sharing a particular behaviour ◦ Data bags: general-purpose JSON data, optionally encrypted, usually to store credentials
  • 28. COOKBOOKS FOR EVERY NEEDS All cookbooks are usually hosted on GitHub ◦ Maintained by Opscode https://github.com/opscode-cookbooks ◦ by vendors https://github.com/elastic/cookbook-elasticsearch ◦ by the community https://supermarket.chef.io Community Stats (07/04/2015) 2,120 Cookbooks ~ 62,086 Chefs
  • 29. ONE DOES NOT SIMPLY COOK A WHALE3
  • 30. DOCKER COOKBOOK https://github.com/bflad/chef-docker ◦ Install docker daemon on supported platforms ▫ Ubuntu/Debian ▫ RHEL/CentOS/Fedora ▫ Amazon Linux ◦ Expose attributes for fine-tuning (e.g. TLS certificates, DNS) ◦ Manage images & containers lifecycle via ad-hoc resources
  • 31.
  • 32. PROBLEM #0: IMAGE DISTRIBUTION / RUN CONTAINER docker_image 'registry:0.9.0' do action :pull notifies :redeploy, 'docker_container[registry]', :immediately end docker_container 'registry' do container_name 'registry' image 'registry:0.9.0' detach true port '5000:5000' volume '/srv/registry:/tmp/registry' env 'SETTINGS_FLAVOR=local' env 'SEARCH_BACKEND=sqlalchemy' action :run end
  • 33. PROBLEM #0: IMAGE DISTRIBUTION / RUN CONTAINER Check that docker has such tagged image and if not: ◦ Download that version ◦ Stop existing container (if any) ◦ Run new container ◦ Raise error if anything goes wrong
  • 34. PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION Populate configuration files with proper values (and automatically restart on changes) template node['tomcat']['host'] + '/cmw.xml' do source 'tomcat/tomcat-context.xml.erb' variables( :resource_name => 'jdbc/datasource', :username => node['cloudesire']['name'], :password => node['cloudesire']['pass'] :url => node['cloudesire']['url'], ) notifies :redeploy, 'docker_container[cmw]' end
  • 35. PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION tomcat-context.xml.erb <Context> <Resource auth="Container" driverClassName="org.postgresql.Driver" initialSize="<%= @node['cloudesire']['backend']['db_pool']['min'] %>" maxActive="<%= @node['cloudesire']['backend']['db_pool']['max'] %>" maxIdle="<%= @node['cloudesire']['backend']['db_pool']['idle'] %>" maxWait="<%= @node['cloudesire']['backend']['db_pool']['wait'] %>" name="<%= @resource_name %>" url="<%= @url %>" username="<%= @username %>" password="<%= @password %>" type="javax.sql.DataSource" validationQuery="select 1" testOnBorrow="true" /> </Context>
  • 36. PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION Templates consist of: ◦ an .ERB template ◦ a template resource declared in a recipe The template is evaluated using the variables passed directly or via the global node object.
  • 37. PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION Inject a single file or entire folders dst = node['tomcat']['base'] + '/conf/Catalina/' + 'localhost/cmw.xml' docker_container 'cmw' do image image_name container_name 'cmw' detach true env LOG debug volume [ "#{node['tomcat']['host']}/cmw.xml:#{dst}", "/etc/cloudesire:/etc/cloudesire" ] end
  • 38. PROBLEM #1: MY APPLICATION NEEDS CONFIGURATION Docker permits defining volumes to be used for persistent data (e.g. database files), but may be used to inject configurations into the container at runtime. Definitevely avoid the needs of image rebuilding to adjust a setting.
  • 39. PROBLEM #2: CONTAINERS RUNNING ON MULTIPLE HOSTS Each node has its own run_list, defining which recipes should be executed (in JSON): { “run_list”: [ "cd-infrastructure::docker-cmw", "cd-infrastructure::docker-deployer", "cd-infrastructure::docker-monitor", "cd-infrastructure::docker-logger" ], “cloudesire”: { “key”: “value” } }
  • 40. PROBLEM #2: CONTAINERS RUNNING ON MULTIPLE HOSTS Same recipe on different nodes (attributes may change) node1.json { “run_list”: [ "cd-infrastructure::docker-cmw", "cd-infrastructure::docker-logger" ] } node2.json { “run_list”: [ "cd-infrastructure::docker-deployer", "cd-infrastructure::docker-monitor", "cd-infrastructure::docker-logger" ] }
  • 41. MAY NOT BE GOLD BUT IT’S A START FOR SURE! It’s easy to getting started with Chef by using kitchen-ci or plain Vagrant: ◦ Initialize a chef repo ◦ Create a new cookbook ◦ Start hacking ◦ Play on kitchen-ci or vagrant ◦ Repeat last 2
  • 42. KITCHEN.YML EXAMPLE $ kitchen converge driver: name: vagrant provisioner: name: chef_solo platforms: - name: ubuntu-1404 suites: - name: default run_list: - recipe[mycookbook::docker-whatever] attributes: { foo: "bar" }
  • 43. READY TO USE CHEF REPOSITORY A starting repository for aspiring whale cookers: https://github.com/gionn/cooking- docker
  • 44. DOCKER APPENDIX: GOLDEN RULES ◦ Only one process per Image ◦ No embedded configuration ◦ No, you don’t need SSH ◦ No, you don’t need syslog ◦ No, you won’t touch a running container to adjust a thing ◦ No, you will not use a community-contributed image without looking at what it do
  • 45. Thanks! ANY QUESTIONS? You can find me at: @gionn on twitter / github me@gionn.net giovanni.toraldo@cloudesire.com