building docker images with puppet

26
Building Docker Images With Puppet Nick Jones, DataCentred @yankcrime

Upload: nick-jones

Post on 23-Jan-2018

957 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Building Docker images with Puppet

Building Docker Images

With PuppetNick Jones, DataCentred

@yankcrime

Page 2: Building Docker images with Puppet

Schedule

DataCentred overview

Why Docker

Why PuppetDemo

Problems / solutions

Wrap-up

Page 3: Building Docker images with Puppet

OpenStack

Keystone, Nova, Neutron, Glance, Cinder, Horizon, etc.

KVMOpen vSwitchControl, compute, network, data nodes

Page 4: Building Docker images with Puppet

OpenStack Services

GaleraRabbitMQMongoDB

MemcacheApache httpdHaproxy & keepalived

Page 5: Building Docker images with Puppet

Ceph

Loadbalancers

GatewaysMonitors

OSDs

Page 6: Building Docker images with Puppet

Monitoring

Icinga2Telegraf, InfluxDB, Grafana

ElasticSearch, Logstash, Kibana

Page 7: Building Docker images with Puppet

Services

CI - JenkinsDNS, TFTP, DHCP

IPAMMirrors

Page 8: Building Docker images with Puppet

Puppet

Puppet MasterPuppetDBPuppet CAForeman

Page 9: Building Docker images with Puppet

ಠ_ಠ

Page 10: Building Docker images with Puppet

Puppet

With Puppet you use a common language to describe what you want your infrastructure to look like, and Puppet makes it happen - and helps you keep it that way.

Page 11: Building Docker images with Puppet

OpenStack Infrastructure Overview

Page 12: Building Docker images with Puppet

OpenStack Control Nodes

Page 13: Building Docker images with Puppet

OpenStack Control Node

Page 14: Building Docker images with Puppet

Why Docker

Consolidate OpenStack components into discrete building blocksMix-and-match versions of components

Ease the pain of upgrades

Page 15: Building Docker images with Puppet

Why Configuration Management

Need to build custom images

Harness the power of something that's the right tool for the job

Puppet incumbent for configuration management, would like to reuse data

Make the two work together

Page 16: Building Docker images with Puppet

Assumptions

Containers should be ephemeral

Running SSH in a container is out

Running Puppet as an agent in a container is out

Page 17: Building Docker images with Puppet

Typical Dockerfile

FROM phusion/baseimage:0.9.15

ENV HOME /rootENV LANG en_US.UTF-8

RUN locale-gen en_US.UTF-8RUN ln -s -f /bin/true /usr/bin/chfnRUN apt-get update && apt-get -y upgrade

[..]

RUN apt-get remove -y --auto-remove openstack-dashboard-ubuntu-themeADD local_settings.py /etc/openstack-dashboard/local_settings.pyVOLUME ["/etc/openstack-dashboard"]ADD openstack-dashboard.conf /etc/apache2/conf-available/openstack-dashboard.confADD start_memcached.sh /etc/service/memcached/runADD start_apache2.sh /etc/service/apache2/run

Page 18: Building Docker images with Puppet

With Puppet

FROM puppet:latestMAINTAINER Nick Jones "[email protected]"

ENV FACTER_role='horizon'

RUN puppet apply --verbose \ --modulepath /puppet/modules \ --hiera_config /puppet/hiera.yaml \ --manifestdir /puppet/ /puppet/default.pp

RUN apt-get -y clean && rm -rf /puppet

EXPOSE 80

CMD ["/usr/bin/supervisord", "-n"]

Page 19: Building Docker images with Puppet

Another Example

FROM puppet:latestMAINTAINER Nick Jones "[email protected]"

ENV FACTER_role='database'ENV FACTER_container='dischord_database'

RUN puppet apply --debug --verbose \ --modulepath /puppet/modules \ --hiera_config /puppet/hiera.yaml \ --manifestdir /puppet/ /puppet/default.pp

RUN apt-get -y clean && rm -rf /puppet

EXPOSE 3306VOLUME /var/lib/mysql

CMD ["/usr/bin/supervisord", "-n"]

Page 20: Building Docker images with Puppet

Database Container

database.yaml:classes: - '::profile::mariadb'

dischord_database.yaml:databases: 'fever': 'user': 'fever' 'password': 'xxx' 'host': '%'

service: 'mariadb-server': 'command': '/usr/sbin/mysqld'

Page 21: Building Docker images with Puppet

Puppet

class profile::mariadb {

include ::mysql::server

create_resources(::mysql::db, hiera('databases'))

}

Page 22: Building Docker images with Puppet

Demo

Building a Horizon image

Page 23: Building Docker images with Puppet

What doesn't work so well

Repo data in images

Breaks image layers philosophy

Puppet modules not handling container behaviour

Lack of support in Puppet's RAL for minimal distros

Page 24: Building Docker images with Puppet

Solutions

Mount configuration data repo at build - Rocker!

Build APIOCI Image Format SpecificationAlternative configuration management tools:

—mgmt—Habitat

Page 25: Building Docker images with Puppet

Questions?

Page 26: Building Docker images with Puppet

References

https://puppet.com/blog/building-puppet-based-applications-inside-docker

http://dischord.org/2016/03/27/docker-and-puppet/

https://github.com/purpleidea/mgmt

https://github.com/puppetlabs/puppet-rocker-demo

https://www.habitat.shhttps://github.com/grammarly/rocker