Dr. Roland Huß, Red

Similar documents
Think Small to Scale Big

Important DevOps Technologies (3+2+3days) for Deployment

Service discovery in Kubernetes with Fabric8

OpenShift 3 Technical Architecture. Clayton Coleman, Dan McPherson Lead Engineers

Code: Slides:

Building A Better Test Platform:

Microservices and Container Development

DevOps Technologies. for Deployment

Docker and Oracle Everything You Wanted To Know

DevOps Course Content

Docker for Development: Getting Started

Accelerate at DevOps Speed With Openshift v3. Alessandro Vozza & Samuel Terburg Red Hat

Continuous Delivery of Micro Applications with Jenkins, Docker & Kubernetes at Apollo

Container-based virtualization: Docker

UP! TO DOCKER PAAS. Ming

Scaling Jenkins with Docker and Kubernetes Carlos

Containers, Serverless and Functions in a nutshell. Eugene Fedorenko

MySQL and Docker Strategies Patrick Galbraith Giuseppe Maxia

docker & HEP: containerization of applications for development, distribution and preservation

SCALING DRUPAL TO THE CLOUD WITH DOCKER AND AWS

Virtual Infrastructure: VMs and Containers

Getting Started With Amazon EC2 Container Service

/ Cloud Computing. Recitation 5 February 14th, 2017

Be smart. Think open source.

~Deep dive into Windows Containers and Docker~

100% Containers Powered Carpooling

Taming your heterogeneous cloud with Red Hat OpenShift Container Platform.

Investigating Containers for Future Services and User Application Support

12 (15) Factor App Workshop

Buenos Aires 31 de Octubre de 2018

SBB. Java User Group 27.9 & Tobias Denzler, Philipp Oser

Cloud Native Java with Kubernetes

Red Hat OpenShift Roadmap Q4 CY16 and H1 CY17 Releases. Lutz Lange Solution

SAINT LOUIS JAVA USER GROUP MAY 2014

Kuber-what?! Learn about Kubernetes

Docker A FRAMEWORK FOR DATA INTENSIVE COMPUTING

Go Faster: Containers, Platforms and the Path to Better Software Development (Including Live Demo)

Arup Nanda VP, Data Services Priceline.com

Amazon EC2 Container Service: Manage Docker-Enabled Apps in EC2

Microservice Bus Tutorial. Huabing Zhao, PTL of MSB Project, ZTE

RAFT library for Java

Red Hat Atomic Details Dockah, Dockah, Dockah! Containerization as a shift of paradigm for the GNU/Linux OS

Launching StarlingX. The Journey to Drive Compute to the Edge Pilot Project Supported by the OpenStack

Reading Assignment (Prepare yourself for the next assignment)

Supporting Docker in Emulab-Based Network Testbeds. David Johnson, Elijah Grubb, Eric Eide University of Utah

Fixing the "It works on my machine!" Problem with Docker

Developing and Testing Java Microservices on Docker. Todd Fasullo Dir. Engineering

OPENSHIFT CONTAINER PLATFORM TECHNICAL OVERVIEW. Presenter Presenter s title Date

USING DOCKER FOR MXCUBE DEVELOPMENT AT MAX IV

Creating pipelines that build, test and deploy containerized artifacts Slides: Tom Adams

Application Centric Microservices Ken Owens, CTO Cisco Intercloud Services. Redhat Summit 2015

Red Hat JBoss Middleware for OpenShift 3

Containerisation with Docker & Kubernetes

OpenShift Online 3 Creating Images

INFRASTRUCTURE AS CODE

WHITE PAPER. RedHat OpenShift Container Platform. Benefits: Abstract. 1.1 Introduction

Red Hat OpenShift Application Runtimes 1

Cloud & container monitoring , Lars Michelsen Check_MK Conference #4

The Post-Cloud. Where Google, DevOps, and Docker Converge

The Long Road from Capistrano to Kubernetes

AGILE DEVELOPMENT AND PAAS USING THE MESOSPHERE DCOS

INDIGO PAAS TUTORIAL. ! Marica Antonacci RIA INFN-Bari

DevOps + Infrastructure TRACK SUPPORTED BY

Containers OpenStack. Murano brings Docker & Kubernetes to OpenStack. Serg Melikyan. software.mirantis.com. January 27, 2015

ASP.NET Core & Docker

A REFERENCE ARCHITECTURE FOR DEPLOYING WSO2 MIDDLEWARE ON KUBERNETES

Infrastructure Security 2.0

Build your dev environment with Docker.

for Devs Christopher M. Judd

OpenShift Roadmap Enterprise Kubernetes for Developers. Clayton Coleman, Architect, OpenShift

Best Practices for Developing & Deploying Java Applications with Docker

The Path to GPU as a Service in Kubernetes Renaud Gaubert Lead Kubernetes Engineer

Lightweight Containerization at Facebook

Kubernetes introduction. Container orchestration

Docker and Security. September 28, 2017 VASCAN Michael Irwin

Declarative Modeling for Cloud Deployments

CS-580K/480K Advanced Topics in Cloud Computing. Container III

Advanced Continuous Delivery Strategies for Containerized Applications Using DC/OS

Introduction to Kubernetes Storage Primitives for Stateful Workloads

Knative: Building serverless platforms on top of Kubernetes

Continuous delivery while migrating to Kubernetes

/ Cloud Computing. Recitation 5 September 26 th, 2017

Running MarkLogic in Containers (Both Docker and Kubernetes)

Characterising Resource Management Performance in Kubernetes. Appendices.

NGINX: From North/South to East/West

Kubernetes The Path to Cloud Native

OpenShift Dedicated 3 Release Notes

DevOps Workflow. From 0 to kube in 60 min. Christian Kniep, v Technical Account Manager, Docker Inc.

Docker for People. A brief and fairly painless introduction to Docker. Friday, November 17 th 11:00-11:45

Four times Microservices: REST, Kubernetes, UI Integration, Async. Eberhard Fellow

Using MySQL Containers

RED HAT GLUSTER TECHSESSION CONTAINER NATIVE STORAGE OPENSHIFT + RHGS. MARCEL HERGAARDEN SR. SOLUTION ARCHITECT, RED HAT BENELUX April 2017

Building Kubernetes cloud: real world deployment examples, challenges and approaches. Alena Prokharchyk, Rancher Labs

Openshift: Key to modern DevOps

Convergence of VM and containers orchestration using KubeVirt. Chunfu Wen

Midterm Presentation Schedule

GoDocker. A batch scheduling system with Docker containers

Docker und IBM Digital Experience in Docker Container

Microservices. Chaos Kontrolle mit Kubernetes. Robert Kubis - Developer Advocate,

agenda PAE Docker Docker PAE

Transcription:

" m " f o r m e n u, "? " f o r o t h e r s h o r t c u t s DOCKER PATTERNS Dr. Roland Huß, Red Hat, @ro14nd

AGENDA Intro: Docker & Patterns Configuration Service Discovery Image Builder

VM VS. CONTAINER Containers are isolated, but share the kernel and (some) files lighter and faster

Design Patterns Michael Mandiberg, CC BY-SA 2.0,https://flic.kr/p/67Cb6Jm

DESIGN PATTERN A Design Pattern describes a repeatable solution for a software engineering problem.

STRUCTURE Problem Patterns: Name Solution Pro & Contra http://www.martinfowler.com/articles/writingpatterns.html

CONFIGURATION

How to configure containerized applications for different environments? Env-Var Configuration Configuration Container Configuration Service

ENV-VAR CONFIGURATION Standard configuration method for Docker container Specified during build or run time Universal

B U I L D FROM jboss/base-jdk:8 ENV DB_HOST "dev-database.dev.intranet" ENV DB_USER "db-develop" ENV DB_PASSWORD "s3cr3t"... R U N docker run \ -e DB_HOST "prod-db.mycompany.com" \ -e DB_USER "dbuser" -e DB_PASSWORD "3QkgbLXWPZ2sJcQ"... mycompany/cool-app

KUBERNETES --- apiversion: v1 kind: ReplicationController spec: replicas: 1 template: spec: containers: - env: - name: GALERA_CLUSTER value: "true" - name: WSREP_CLUSTER_ADDRESS value: "gcomm:" - name: WSREP_SST_USER value: "sst" - name: WSREP_SST_PASSWORD value: "sst" - name: MYSQL_USER value: "mysql" - name: MYSQL_PASSWORD value: "mysql"

DOCKER COMPOSE --- version: '2' services: web: depends_on: - db environment: DB_USER: "dbuser" DB_PASS: db: image: "orchardup/mysql" environment: MYSQL_DATABASE: "wordpress"

EVALUATION System.getenv() Environment "profiles" Predefined profiles EnvVar selects profile spring: profiles: dev server: port: 9001 --- spring: profiles: prod server: port: 8080 docker run \ -e SPRING_PROFILES_ACTIVE=dev \ my-springboot-app

PRO Simple and Easy Explicit Widely supported CONTRA Static Hard to maintain for complex configuration

CONFIGURATION CONTAINER Configuration in extra Docker container Volume linked during runtime Example of a Sidecar Container

PRO Flexible Explicit CONTRA Static Maintenance overhead Custom file layout

CONFIGURATION SERVICE Active Configuration lookup "Configuration-as-a-Service" Tools: Apache ZooKeeper Consul etcd Redis

PRO Flexible Dynamic CONTRA External Service (Latency) Maintenance overhead Weakens Immutability

SERVICE DISCOVERY

How can an application discover its runtime dependencies? Env-Var Injection Service Lookup Dynamic DNS

ENV-VAR INJECTION Injection of services as Environment Variables Must be set during container start Examples: Docker links / Docker network Kubernetes Custom (e.g. envconsul + gliderlabs/registrator)

KUBERNETES For each active Service sets: svcname_service_host svcname_service_port Also Docker-style link variables link Only when Pod starts

FABRIC8 CDI @Factory @ServiceName public DataSource create(@servicename @Protocol("jdbc:mysql") @Path("db") String url) { MysqlDataSource mysqlds = new MysqlDataSource(); mysqlds.seturl(url); mysqlds.setuser(system.getproperty(username, "root")); mysqlds.setpassword(system.getproperty(password, "pass")); return mysqlds; } @ServiceName("dev-mysql") DataSource mysqld;

PRO Simple No lookup required CONTRA Only services during startup available Supporting platform required (Kubernetes)

SERVICE REST LOOKUP Key-Value Stores REST API for Registration & Query gliderlabs/registrator Automatic registration of Docker containers Backends for Consul, etcd, SkyDNS

PRO Explicit Dynamic CONTRA Support from platform required Vendor lock-in

DYNAMIC DNS Standard Protocol for Service Lookup (SRV records) Tools for DNS service registry: Consul SkyDNS DNS Lookup for Java Clients: JNDI or custom

JNDI DNS Hashtable env = new Hashtable(); env.put("java.naming.factory.initial", "com.sun.jndi.dns.dnscontextfactory"); env.put("java.naming.provider.url", "dns:"); DirContext ctx = new InitialDirContext(this.env); Attributes attrs = ctx.getattributes("redis.myproject.svc.cluster.local", new String[] { "SRV" }); NamingEnumeration e = attrs.getall(); while (e.hasmore()) { Attribute attr = (Attribute) e.next(); System.out.println(attr.get()); } e.close(); 10 33 6379 _redis._tcp.redis.myproject.svc.cluster.local.

SPOTIFY/DNS-JAVA import com.spotify.dns.*; DnsSrvResolver resolver = DnsSrvResolvers.newBuilder().cachingLookups(true).retainingDataOnFailures(true).dnsLookupTimeoutMillis(1000).build(); List<LookupResult> nodes = resolver.resolve( "redis.myproject.svc.cluster.local"); for (LookupResult node : nodes) { System.out.println( node.host() + ":" + node.port()); }

PRO Dynamic Standard Good infrastructure support CONTRA Deep interaction with OS Rusty

IMAGE BUILDING

How to build Docker images? Dockerfile Template Image Factory Self-contained Artifact Container Build Integration

CLASSIC STYLE docker commit docker commit 3e3d3cf39 redis-server:1.0 docker build FROM ubuntu:14.04 RUN apt-get update && \ apt-get install -y redis-server EXPOSE 6379 ENTRYPOINT ["/usr/bin/redis-server"]

DOCKERFILE TEMPLATE Dockerfile generation from templates Build with docker build Simple built-in support (ARG) Engines: fish-pepper, dogen, crane, App::Dockerfile::Template...

DOCKERFILE ARGS Dockerfile variables Since Docker 1.9 Can not be used in FROM Filled in during runtime FROM busybox ARG uid USER ${uid:-jboss} #... docker run --build-arg uid=daemon...

PRO Simple Uses Docker builtin mechanism Good for many similar builds CONTRA Restricted to Dockerfiles Standard solution very limited

IMAGE FACTORY Creating images without Dockerfiles Flow: Start container from a base image Provision stuff to the container Commit container as image Provisioning must be reproducible and automated

ANSIBLE - name: initialize provisioning hosts: docker - name: start up target container docker: image: java:8.0 name: fis-karaf #... command: sleep infinity state: started # dynamically update inventory - name: register new container hostname add_host: name=lab - name: provision container connection: docker hosts: lab tasks: #... - name: finalize build hosts: docker tasks: - name: stop container docker: name: fis-karaf state: stopped

PRO Composition Parametrisation Less image layers CONTRA Extra Tooling No builds by Docker Hub

SELF CONTAINED JEE Server and Application in one Image Server base image FROM fabric8/tomcat-8.0 COPY chat-app.war /opt/tomcat/webapps/chat-app.war

PRO Single deployment unit CONTRA Coupled lifecycle

ARTIFACT CONTAINER Container holding the application artifact Linked to a JEE container JEE Server deploys artifact during startup

PRO Independent lifecycles Separate responsibilities CONTRA Two images to manage

BUILD INTEGRATION Create Docker images from within a build Plugins for Maven & Gradle Maven: https://github.com/fabric8io/shootout-docker-maven

ASSEMBLY <assembly> <dependencysets> <dependencyset> <includes> <include>org.jolokia:jolokia-war</include> </includes> <outputdirectory>.</outputdirectory> <outputfilenamemapping> jolokia.war </outputfilenamemapping> </dependencyset> </dependencysets> </assembly>

CONFIGURATION <image> <name>jolokia/jolokia-itest</name> <build> <from>consol/tomcat-7.0</from> <assemblydescriptor> assembly.xml </assemblydescriptor> </build> <run> <ports> <port>jolokia.port:8080</port> </ports> </run> </image>

PRO Self contained builds No external requirements Reuse of existing build configuration CONTRA Own configuration syntax More than one way

WORMHOLE How can a container access its managing Docker daemon? docker run \ -v /var/run/docker.sock:/var/run/docker.sock \... Alternative: "Docker-in-Docker" https://ro14nd.de/docker-wormhole-pattern

WRAP UP Patterns can help in solving recurring Docker challenges. Multiple patterns exists for Configuration, Service Discovery and Image building which are complementary.

QUESTIONS? Blog Slides https://ro14nd.de firefox $(curl -sl http://bit.ly/docker-patterns sh)