cloudify workshop at ccceu 2014

69
Cloudify 3 Workshop #ccceu Budapest 2014 Uri Cohen - @uri1803

Upload: uri-cohen

Post on 02-Jul-2015

885 views

Category:

Technology


1 download

DESCRIPTION

Cloudify workshop at CCCEU 2014

TRANSCRIPT

Page 1: Cloudify workshop at CCCEU 2014

Cloudify 3 Workshop

#ccceuBudapest 2014Uri Cohen - @uri1803

Page 2: Cloudify workshop at CCCEU 2014

INTRODUCTION (OR WHY WE NEED THIS AT ALL…)

Page 3: Cloudify workshop at CCCEU 2014

The World Is about

Services & Apps

Page 4: Cloudify workshop at CCCEU 2014

Automation Is Key for:• Testability

• Consistency

• Agility

• Stability

Page 5: Cloudify workshop at CCCEU 2014

The Automation Continuum

EnvironmentCreation

SW Infra. Setup & Config

Code Push Monitoring & Alarming

Repairing Scaling

Page 6: Cloudify workshop at CCCEU 2014

The Automation Continuum

• VMs / Bare Metal Servers

• Network (Firewall, NAT, VPN, etc.)

• LB Groups

• Storage (Block / Blob)

EnvironmentCreation

Page 7: Cloudify workshop at CCCEU 2014

The Automation Continuum

SW Infrastructure Setup & Configuration

• OS Configuration (e.g. ulimit, useradd, permissions, etc.)

• Installation of packages and middleware components

• Startup orchestration

• Update (not very frequent)

Page 8: Cloudify workshop at CCCEU 2014

The Automation Continuum

Code Push

• User code installation on software infrastructure

– e.g. jar, war, rails sources, PHP sources, DB scripts, etc.

– After setup

– On going - can be very frequent• Push policies (canary, red/black, a/b)

Page 9: Cloudify workshop at CCCEU 2014

The Automation Continuum

Monitoring & Alarming

• What should be monitored? – Availability: are my services up or not?

– Performance (OS &services level metrics). How are my services doing?

– State: What’s running where, state of system resources (e.g. quota utilization)

• Alarms upon failure or when reaching certain thresholds– Simple (a-la CloudWatch) or complex (CEP driven)

Page 10: Cloudify workshop at CCCEU 2014

The Automation Continuum

Repairing

• Various types of failures– Service level – service not responding, process failed

– VM / Node failure

– Infrastructure failure (disk, network)

• Automation tools can go a certain way – Resiliency should also be part of the SW stack

Page 11: Cloudify workshop at CCCEU 2014

The Automation Continuum

Scaling

• Manually or Automatically (alarm triggered)

• Scaling by – Adding / removing instances (AKA out / in)

– Adding / removing resources to / from an existing instance (AKA up / down)

• For both, it needs to be supported by the SW stack

Page 12: Cloudify workshop at CCCEU 2014

Let’s Look at Some Tools

Page 13: Cloudify workshop at CCCEU 2014

Orchestration Tools

EnvironmentCreation

SW Infra. Setup & Config

Code Push Monitoring & Alarming

Repairing Scaling

Page 14: Cloudify workshop at CCCEU 2014

CM Tools

EnvironmentCreation

SW Infra. Setup & Config

Code Push Monitoring & Alarming

Repairing Scaling

Page 15: Cloudify workshop at CCCEU 2014

Monitoring

EnvironmentCreation

SW Infra. Setup & Config

Code Push Monitoring & Alarming

Repairing Scaling

Page 16: Cloudify workshop at CCCEU 2014

Tying The Pieces

Together Usually

Looks Like This

Page 17: Cloudify workshop at CCCEU 2014

A Way to tie all the pieces on the Automation Continuum together

• Use what works best, not reinvent each piece from scratch

Page 18: Cloudify workshop at CCCEU 2014

Open Source Platform for Deploying, Managing and Scaling Complex Multi-Tier Applications on the Cloud

Page 19: Cloudify workshop at CCCEU 2014

So You Can Have This

EnvironmentCreation

SW Infra. Setup & Config

Code Push Monitoring & Alarming

Repairing Scaling

Page 20: Cloudify workshop at CCCEU 2014

Main Functions

• Deployment modeling using TOSCA

• Automated resource creation, placement, configuration and startup

• Metric and log collection

• Monitoring

• Auto-repairing

• Auto-scaling

• Deployment updates (infra and app code)

Page 21: Cloudify workshop at CCCEU 2014

Cloudify in the Devops Toolchain

Orchestration

CI

Monitoring & Alarming

CM Infrastructure

API

Page 22: Cloudify workshop at CCCEU 2014

Cloudify in the Devops Toolchain

Orchestration

CI

Monitoring & Alarming

CM Infrastructure

API

TOSCA

Page 23: Cloudify workshop at CCCEU 2014

Architecture

Page 24: Cloudify workshop at CCCEU 2014

Architecture

Page 25: Cloudify workshop at CCCEU 2014

Architecture

Page 26: Cloudify workshop at CCCEU 2014

Demo 1Setup up a Manager on CloudStack

Page 27: Cloudify workshop at CCCEU 2014

CLOUDIFY 3 BLUEPRINTS –DOING IT THE TOSCA WAY

Page 28: Cloudify workshop at CCCEU 2014

Cloudify 3 Blueprints

• A Blueprint is an Orchestration Plan for a single* application

• It has 3 parts:• Topology: Declarative written in YAML DSL

• Workflows: Imperative written in Python*

• Policies: Declarative, written mostly in YAML

• Conforms to TOSCA (next slide)

Page 29: Cloudify workshop at CCCEU 2014

What is TOSCA?

• Topology & Orchestration Specification of Cloud Application

• By OASIS – Sponsored by IBM, CA, RH, Huawei and others

• The goal is to allow for a cross cloud, cross tools orchestration of applications on the Cloud

• Status: • Version 1 approved (XML). • Version 2 (also YAML) – in design

Page 30: Cloudify workshop at CCCEU 2014

TOSCA-Inspired Application Blueprints

Application Topologies

Workflows

Policies

Page 31: Cloudify workshop at CCCEU 2014

Why TOSCA?

• Standard

• Can Describe• Any Topology

• Any Automation Process

• Portable between Clouds and Tools

Page 32: Cloudify workshop at CCCEU 2014

So here’s an application

Page 33: Cloudify workshop at CCCEU 2014

What do we see here?

Host

Middleware

App module

connection

Page 34: Cloudify workshop at CCCEU 2014

What Have We Seen?

• An application topology

• 3 levels of components:• Infrastructure (Cloud or DC objects)

• Platform or Middleware (App containers)

• Application modules, schemas and configurations

• Relationships between components (dependencies):• What’s hosted on what or installed on what

• What’s connected to what

Page 35: Cloudify workshop at CCCEU 2014

What’s in TOSCA Topology?

• Inputs and outputs

• Types and nodes

• Relationships

• Requirements and capabilities

Page 36: Cloudify workshop at CCCEU 2014

Input and Outputs

• A way to parameterize blueprints and let them declare runtime computed values (URLs, passwords, etc.)

Page 37: Cloudify workshop at CCCEU 2014

Inputs and Outputsinputs:

cloudstack_api_url:

default: ''

type: string

cloudstack_key:

default: ''

type: string

cloudstack_secret:

default: ''

type: string

...

outputs:

endpoint:

description: Web application endpoint

value:

ip_address: { get_attribute: [ nodejs_vm, ip ] }

port: { get_property: [ nodecellar_app, base_port ] }

Page 38: Cloudify workshop at CCCEU 2014

Types & Nodes

• Each component in the topology is a node:• For example, a VM is a node, a Webserver is a Node• The node holds the configuration (properties) and the relationships to

other nodes

• A node has a type• The type is where the lifecycle interface operations are defined• The type specified the properties schema

• Default lifecycle operations are:• create

• configure

• start

• stop

• delete

38

Page 39: Cloudify workshop at CCCEU 2014

Type Example

39

Can be scripts or references to Python

functions implemented by plugins

Page 40: Cloudify workshop at CCCEU 2014

Relationships

• There are 3 types of relationships:• depends_on – which is the base type• conataind_in – a component is hosted / contained / deployed

within nother• connected_to – a component needs to establish a connection to

another and therefore this needs to be configured

• The relationship can define operation to be applied on the source of the target instances

• Possible operations on each:• preconfigure – before node configure is called• postconfigure – after node configure is called but before start• establish – after start when connection needs to be established• unlink – remove the connection

40

Page 41: Cloudify workshop at CCCEU 2014

Relationship Example

41

Can be scripts or references to Python

functions implemented by plugins

Page 42: Cloudify workshop at CCCEU 2014

Requirements and Capabilities

Page 43: Cloudify workshop at CCCEU 2014

One Way of Putting This

Nodecellar_appIS CONNECTED to

mongod

Page 44: Cloudify workshop at CCCEU 2014

Another Way of Putting This

Nodecellar_appNEEDS a database of type

‘MongoDB’

Page 45: Cloudify workshop at CCCEU 2014

Requirements and Capabilities

• Relationships will soon be replaced by a more declarative model created by the latest TOSCA work draft

• “This type needs a database connection”instead of “This node is connected to a node that happens to be a database”

• Cloudify to follow once spec approved

Page 46: Cloudify workshop at CCCEU 2014

Requirements and Capabilities

• A node type declares a certain capability

• Another type in a blueprint declares that it requires this capability

• A node in a blueprint can also declare that it needs a capability

Page 47: Cloudify workshop at CCCEU 2014

Requirements and Capabilities

node_templates:

wordpress:

type: tosca.nodes.WebApplication.WordPress

requirements:

- host: webserver

- database_endpoint: mysql_database

tosca.nodes.Database:

derived_from: tosca.nodes.Root

properties:

db_user:

type: string

db_password:

type: string

db_port:

type: integer

db_name:

type: string

description: the logical name of the database

capabilities:

- database_endpoint: tosca.capabilities.DatabaseEndpoint

Page 48: Cloudify workshop at CCCEU 2014

A Word About Blueprint Portability

• Cloudify blueprint support the notion of abstract types – Kind of like abstract classes in OOD

• Blueprints can be composed of multiple files

• To achieve portability: – Topologies should be defined using portable types – Concrete types are then wired at blueprint creation

time • Kind of like dependency injection

Page 49: Cloudify workshop at CCCEU 2014

Workflows

• TOSCA 1.0 – Workflows (Plans) are in any WF language. – Strong preference for BPMN 2.0

• TOSCA 2.0 – No change

• Cloudify 3 take – Workflows are currently python based– Tinkering with a more declarative approach

(OpenStack Mistral?)

Page 50: Cloudify workshop at CCCEU 2014

Policies

• Still not defined by TOSCA, under discussion

• Cloudify 3 – YAML mostly, uses Riemann.io under the hood – You can create very sophisticated custom policies,

in Clojure…

Page 51: Cloudify workshop at CCCEU 2014

Putting it all together

• TOSCA Template (Blueprint in Cloudify) contains:– Application Topology

• Nodes– Interfaces and operations

– Properties

– Relationships

– Workflows (install, uninstall, scale out, CD)

– Policies (scale trigger, recovery trigger)

Page 52: Cloudify workshop at CCCEU 2014

Demo 2Upload a blueprint and install it

Page 53: Cloudify workshop at CCCEU 2014

WHAT REALLY HAPPENED HERE?

Page 54: Cloudify workshop at CCCEU 2014

We Triggered a Few Processes

• Blueprint and deployment creation

• Workflow execution

• Availability reporting

• Log and metric collection

Page 55: Cloudify workshop at CCCEU 2014

BLUEPRINT AND DEPLOYMENT CREATION

Page 56: Cloudify workshop at CCCEU 2014

Blueprint Upload

59

Gunicorn

Node

ElasticSearch

Cloudify Manager

Nginx

Blueprint saved in ElasticSearch

Page 57: Cloudify workshop at CCCEU 2014

Deployment Creation

60

Gunicorn

Node

ElasticSearch

Cloudify Manager

NginxCelery Worker

Dedicated deployment workers created

Celery Workers

RabbitMQ

Page 58: Cloudify workshop at CCCEU 2014

WORKFLOW EXECUTION

Page 59: Cloudify workshop at CCCEU 2014

The Bigger Picture

CeleryD

Agent

WorkerWorker

WorkerPlugin

RabbitMQ

Tasks

Logs

WorkflowWorker

Logstash

Elastic Search Runtime

Properties

RiemannCreated

Page 60: Cloudify workshop at CCCEU 2014

Workflow Execution

Page 61: Cloudify workshop at CCCEU 2014

LOGS & EVENTS

Page 62: Cloudify workshop at CCCEU 2014

Logs & Events Functionality

• Cloudify components logs are gathered, indexed and persisted

• Events give the user a simple and clear way to trace the progress of a workflow execution

• Available from API, CLI and web GUI

Page 63: Cloudify workshop at CCCEU 2014

Logs & Events Mechanism

Source Component

RabbitMQ Log Stash Elastic Search

REST API

QueuedFormatted

+ PipedIndexed + Persisted

Queries

Page 64: Cloudify workshop at CCCEU 2014

Closing the Feedback Loop

CeleryCollectd / Diamond

ApplicationStack

NagiosZabbix

…Riemann

Cloudify Manager

Third party monitoring tool

InfluxDB

Metrics VM

Logstash

App VM

RabbitMQ

Page 65: Cloudify workshop at CCCEU 2014

Policy Engine Work Model

1. User can define a selector to create a stream 2. Apply rules for stream to decide about the output

When handler function detects policy violation it

emits an event that triggers a workflow

Monitoring tools send events to

Riemann

Page 66: Cloudify workshop at CCCEU 2014

Demo 3 Monitoring

Page 67: Cloudify workshop at CCCEU 2014

If You Want to Dive Deeper

• Plugins – IaaS: CloudStack,

OpenStack, AWS (libcloud), vSphere, vCloud, SoftLayer

– Chef, Puppet, Salt, Fabric, Docker

– Role your own

• Workflows

• Policies

Page 68: Cloudify workshop at CCCEU 2014

References

• Cloudify home: getcloudify.org

• Github: github.com/cloudify-cosmo

• CloudStack integration (in the works):github.com/cloudify-cosmo/?query=cloudstack

• TOSCA:https://www.oasis-open.org/committees/tosca/

Page 69: Cloudify workshop at CCCEU 2014

Thank You!