85
Deploying WSO2 Middleware on Containers Lakmal Warusawithana Director Cloud Architecture, WSO2 VP, Apache Stratos Imesh Gunaratne Software Architect, WSO2

Deploying WSO2 Middleware on Containers

Embed Size (px)

Citation preview

Page 1: Deploying WSO2 Middleware on Containers

Deploying WSO2 Middleware on ContainersLakmal WarusawithanaDirector Cloud Architecture, WSO2VP, Apache Stratos

Imesh GunaratneSoftware Architect, WSO2

Page 2: Deploying WSO2 Middleware on Containers

Agenda• An Introduction to Docker and Docker Compose• Building WSO2 Docker Images• Deploying WSO2 Middleware on Docker with Docker Compose• An Introduction to Kubernetes• Deploying WSO2 middleware on Kubernetes• Kubernetes Vs OpenShift• Using Puppet and Hiera for Configuration Management• Automated WSO2 Carbon Cluster Discovery• An Introduction to Mesos DC/OS• Deploying WSO2 Middleware on Mesos DC/OS• CloudFoundry Current Limitations and the Future

Page 3: Deploying WSO2 Middleware on Containers

An Introduction to Docker

Page 4: Deploying WSO2 Middleware on Containers

What are containers?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 5: Deploying WSO2 Middleware on Containers

What are containers?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 6: Deploying WSO2 Middleware on Containers

What are containers?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 7: Deploying WSO2 Middleware on Containers

What are containers?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 8: Deploying WSO2 Middleware on Containers

What are containers?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 9: Deploying WSO2 Middleware on Containers

What are containers?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 10: Deploying WSO2 Middleware on Containers

What are containers?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 11: Deploying WSO2 Middleware on Containers

What are containers?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 12: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 13: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 14: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 15: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 16: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 17: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 18: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 19: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 20: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 21: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 22: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 23: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 24: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 25: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 26: Deploying WSO2 Middleware on Containers

What is Docker?

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 27: Deploying WSO2 Middleware on Containers

Docker File System

https://sysadmincasts.com/episodes/31-introduction-to-docker

Page 28: Deploying WSO2 Middleware on Containers

How to Install Docker?• For Linux

– wget -qO- https://get.docker.com/ | sh• For Mac

– https://docs.docker.com/engine/installation/mac/• For Windows

– https://docs.docker.com/engine/installation/windows/

Page 29: Deploying WSO2 Middleware on Containers

Demo: Docker Basics

Cinema clapperboard icon source: http://www.flaticon.com/free-icon/graph_102534

Page 30: Deploying WSO2 Middleware on Containers

Building WSO2 Docker Images

Page 31: Deploying WSO2 Middleware on Containers

Building WSO2 Docker Images• Clone https://github.com/wso2/dockerfiles• Let's build WSO2 APIM Docker image.

– Navigate wso2am folder and follow the ReadMe.

Page 32: Deploying WSO2 Middleware on Containers

An Introduction to Docker Compose

Page 33: Deploying WSO2 Middleware on Containers

An Introduction to Docker Compose• Compose is a tool for defining and running

multi-container Docker applications

• In compose yaml can define your application’s services

• Using a single command, you create and start all the services from your configuration

• To Install Docker Compose– https://docs.docker.com/compose/install/

Page 34: Deploying WSO2 Middleware on Containers

Deploying WSO2 Middleware on Docker with Docker Compose

Page 35: Deploying WSO2 Middleware on Containers

Deploying WSO2 Middleware on Docker with Docker Compose

• Clone https://github.com/lakwarus/wso2am-deployment-patterns

• Navigate to your patten• Follow the ReadMe

– docker-compose up

Page 36: Deploying WSO2 Middleware on Containers

Demo: Deploying WSO2 API-M on Docker with Docker Compose

Cinema clapperboard icon source: http://www.flaticon.com/free-icon/graph_102534

Page 37: Deploying WSO2 Middleware on Containers

An Introduction to Kubernetes

Page 38: Deploying WSO2 Middleware on Containers

An Introduction to Kubernetes• An open source container cluster management system• Started by Google with decade and half experience on

running containers at scale (Borg)• Written in Go• Can be deployed on any Infrastructure/IaaS• Over 600 contributors

http://kubernetes.io/v1.0/docs/whatisk8s.html

Page 39: Deploying WSO2 Middleware on Containers

Kubernetes High Level Architecture

Page 40: Deploying WSO2 Middleware on Containers

Kubernetes Pods

● A group of containers which can share resources and context

● Shared namespaces:○ PID namespace (processes visible globally)○ network namespace (same IP and port

space)○ IPC namespace (SystemV IPC or POSIX)○ UTS namespace (share a hostname)

http://kubernetes.io/v1.0/docs/user-guide/pods.html

Pod

C1 C2 C3

Page 41: Deploying WSO2 Middleware on Containers

Kubernetes Replication Controllers

● Provides features for replicating pods:○ Auto-healing○ Manual scaling○ Rolling updates○ Multiple release tracks

http://kubernetes.io/v1.0/docs/user-guide/replication-controller.html

Pod TemplateReplicas = n

Pod 1 Pod 2 Pod n

Replication Controller

Page 42: Deploying WSO2 Middleware on Containers

Kubernetes Horizontal Pod Autoscaler

● Provides features for horizontally autoscaling pods○ CPU consumption based

http://kubernetes.io/v1.1/docs/user-guide/horizontal-pod-autoscaler.html

Pod TemplateReplicas = n

Pod 1 Pod 2 Pod n

Replication Controller

Horizontal Pod Autoscaler

Page 43: Deploying WSO2 Middleware on Containers

Kubernetes Services

● Service types:○ ClusterIP (default)○ NodePort○ LoadBalancer

● Service discovery:○ DNS○ Environment variables

● Client IP based Session Affinity

http://kubernetes.io/v1.0/docs/user-guide/services.html

Node IP: 172.17.8.102

Port: 9443

Domain Name: service1IP: 10.2.10.20

Port: 9443NodePort: 32001

Protocol: TCP

Pod 1 Pod 2 Pod n

Service

L1

L1 L1 L1

Node

Page 44: Deploying WSO2 Middleware on Containers

Overlay Network

● Unique IP addresses● Provides pod to pod networking● Options available:

○ Flannel (default)○ OpenVSwitch○ Weave○ Calico

http://kubernetes.io/v1.1/docs/admin/networking.html

Page 45: Deploying WSO2 Middleware on Containers

WSO2 Carbon Reference Architecture 1

Pod 1 Pod 2

Manager Cluster Services

Pod 3 Pod 4 Pod n

Worker Cluster Services

Manager Replication Controller

Worker Replication Controller

Client

Gov Reg

Conf Reg

User Store

Page 46: Deploying WSO2 Middleware on Containers

WSO2 Carbon Reference Architecture 2

Pod 1

Gateway Mgr Services

Pod 2 Pod 3

Gateway Worker Services

Client

Pod 4 Pod 5

Key Manager Services

Pod 6 Pod 7

Store Services

Gateway Mgr RC

Gateway Worker RC

Key Manager RC

Store RCGov Reg

Conf Reg

User Store

API-M DB

Pod 8 Pod 9

Publisher Services

Publisher RC

Page 47: Deploying WSO2 Middleware on Containers

Setting Up Kubernetes

Page 48: Deploying WSO2 Middleware on Containers

How to Setup Kubernetes• git clone https://github.com/imesh/kubernetes-vagrant-

setup• Follow the ReadMe

Page 49: Deploying WSO2 Middleware on Containers

Deploying WSO2 Middleware on Kubernetes

Page 50: Deploying WSO2 Middleware on Containers

Deploying WSO2 Middleware on Kubernetes

● WSO2 Kubernetes Artifacts Git Repository○ Kubernetes Membership Scheme○ Kubernetes Services○ Kubernetes Replication Controllers

https://github.com/wso2/kubernetes-artifacts

Page 51: Deploying WSO2 Middleware on Containers

Demo: Deploying WSO2 API-M on Kubernetes

Cinema clapperboard icon source: http://www.flaticon.com/free-icon/graph_102534

Page 52: Deploying WSO2 Middleware on Containers

An Introduction to OpenShift

Page 53: Deploying WSO2 Middleware on Containers

Introduction to OpenShift• Based on top of Docker containers and the

Kubernetes container cluster manager• OpenShift 3 adds

– Developer and operational centric tools to enable rapid application development

– Easy deployment and scaling– Long-term lifecycle maintenance for small and

large teams and applications.

https://www.openshift.com

Page 54: Deploying WSO2 Middleware on Containers

An Introduction to Puppet + Hiera

Page 55: Deploying WSO2 Middleware on Containers

An Introduction to Puppet

Prerequisites

Desired Server Runtime

Execute Puppet

Server Distribution

Configuration Data

Artifacts

Pupp

et M

odul

e

Page 56: Deploying WSO2 Middleware on Containers

Puppet Master

How does it work?

Puppet Modules

http://www.slideshare.net/pk.habi/introduction-to-puppet-16586463

Puppet Agent (Server 1)

Puppet Agent (Server 2)

Puppet Agent (Server 3)

Puppet Agent (Server n)

1. Master-agent modePuppet Master

Page 57: Deploying WSO2 Middleware on Containers

How does it work?

http://www.slideshare.net/pk.habi/introduction-to-puppet-16586463

2. Standalone mode

Puppet (Server 1)

puppet apply

Puppet Modules

Puppet (Server 2)

puppet apply

Puppet Modules

Puppet (Server n)

puppet apply

Puppet Modules

Page 58: Deploying WSO2 Middleware on Containers

What is Hiera?• Hiera is a key/value lookup tool for configuration data.• It makes Puppet better by keeping site-specific data

out of the manifests.• Configuration data is stored in YAML files.• Avoids repetition by introducing common YAML files.

https://docs.puppet.com/hiera/

Page 59: Deploying WSO2 Middleware on Containers

A Sample Hiera YAML File

https://github.com/wso2/puppet-modules

Page 60: Deploying WSO2 Middleware on Containers

Deployment Automation Overview

WSO2 Server

ProfilesProfilesProfiles

Deployment Patterns

Deployment Patterns

Deployment Patterns

Puppet Module

Templates

Hiera Config Data

TemplatesTemplates

Hiera Config Data

Hiera Config Data

Hiera Config Hierarchy: Environments -> Products -> Versions -> Platforms -> PatternsDev | Test | Pre-

Prod | ProdVM | K8S | Mesos

Page 61: Deploying WSO2 Middleware on Containers

WSO2 Hiera Config Data Hierarchy

https://github.com/wso2/puppet-modules/blob/master/hiera.yaml

Page 62: Deploying WSO2 Middleware on Containers

Build WSO2 Docker Images Using Puppet

Page 63: Deploying WSO2 Middleware on Containers

Build WSO2 Docker Images Using Puppet

• Download & extract latest WSO2 Puppet Modules:– https://github.com/wso2/puppet-modules/releases

• Export env variable PUPPET_HOME pointing to above folder• Copy JDK 1.7_80 distribution to:

– <PUPPET_HOME>/modules/wso2base/files

• Copy product distribution to:– <PUPPET_HOME>/modules/<product>/files

• Download & extract WSO2 Dockerfiles:– https://github.com/wso2/dockerfiles/releases

• Execute build.sh:– ./dockerfiles/wso2esb/build.sh -v 4.9.0 -r puppet

https://docs.puppet.com/hiera/

Page 64: Deploying WSO2 Middleware on Containers

Demo: Building WSO2 ESB Docker Images with Puppet

Cinema clapperboard icon source: http://www.flaticon.com/free-icon/graph_102534

Page 65: Deploying WSO2 Middleware on Containers

Automated WSO2 Carbon Cluster Discovery

Page 66: Deploying WSO2 Middleware on Containers

What does WSO2 Carbon Clustering Provides?

• Distributed Caching• Coordinator Election (Using distributed locks)• Cluster Communication• Implemented using Hazelcast

https://docs.wso2.com/display/CLUSTER44x/Overview

Page 67: Deploying WSO2 Middleware on Containers

How Carbon Cluster Discovery Works?

Pod 1 Pod 2 Pod n

Service

Server 1 Server 2 Server n

Pod 1

Service

Server 1

Pod 1 Pod 2

Service

Server 1 Server 2

Hazelcast member initialization

Hazelcast member initialization

Hazelcast member initialization

1 2 n

Page 68: Deploying WSO2 Middleware on Containers

Deploying WSO2 Middleware on Mesos DC/OS

Page 69: Deploying WSO2 Middleware on Containers

An Introduction to Apache Mesos

Image source: Anton Kirillov, Data processing platforms architectures [1]

Mesos is an open-source cluster manager that was initially developed at the University of California, Berkeley in year 2009.

Page 70: Deploying WSO2 Middleware on Containers

An Introduction to Mesos DC/OS

Cluster Manager

PaaS UI | CLI | Package RepositoryBatch Job Scheduler

Page 71: Deploying WSO2 Middleware on Containers

Reference Architecture for Mesos DC/OS

C 1 C 2

Manager Marathon Applicatio

C 3 C 4 C n

Worker Marathon Application

Marathon Load Balancer

Gov Reg

Conf Reg

User Store

Client

Manager Marathon Application

Worker Marathon Application

Page 72: Deploying WSO2 Middleware on Containers

Steps for Deploying WSO2 Middleware on Mesos DC/OS

1. Build Docker images for Mesos using Puppet:– git clone -b mesos-platform-dev https://github.com/wso2/puppet-modules.git– Copy prerequisites to [puppet-modules]:

• Oracle JDK• WSO2 product distributions• Mesos membership scheme (optional)

– git clone https://github.com/wso2/dockerfiles.git– bash [dockerfiles]/<product>/build.sh -v [version] -r puppet -s mesos -l [profiles]

Page 73: Deploying WSO2 Middleware on Containers

Steps for Deploying WSO2 Middleware on Mesos DC/OS

2. Deploy Marathon applications:– git clone https://github.com/wso2-incubator/mesos-artifacts

– bash [mesos-artifacts]/<product>/deploy.sh

Page 74: Deploying WSO2 Middleware on Containers

Demo: Deploying WSO2 ESB on Mesos DC/OS

Cinema clapperboard icon source: http://www.flaticon.com/free-icon/graph_102534

Page 75: Deploying WSO2 Middleware on Containers

Deploying WSO2 Middleware on Cloud Foundry

Page 76: Deploying WSO2 Middleware on Containers

An Introduction to Cloud Foundry

Page 77: Deploying WSO2 Middleware on Containers

An Introduction to Cloud Foundry

Page 78: Deploying WSO2 Middleware on Containers

Limitations in the Current Architecture

• A container can only expose one transport/port. • Only HTTP traffic can be routed via the router.• SSL get terminated at the router.• Internal routing rules cannot be defined.• Autoscaling can only be done based on CPU usage.

Warning icon source: http://www.flaticon.com/free-icon/warning-triangle_10190

Page 79: Deploying WSO2 Middleware on Containers

Reference Architecture for Cloud Foundry

C 1 C 2

Manager Marathon Applicatio

C 3 C 4 C n

Worker Marathon Application

CF Router

Gov Reg

Conf Reg

User Store

Client

Manager CF Application

Worker CF Application

Page 80: Deploying WSO2 Middleware on Containers

Deployment Architecture

Page 81: Deploying WSO2 Middleware on Containers

Demo: Deploying WSO2 ESB on Cloud Foundry

Cinema clapperboard icon source: http://www.flaticon.com/free-icon/graph_102534

Page 82: Deploying WSO2 Middleware on Containers

Summary

Page 83: Deploying WSO2 Middleware on Containers

Deploying WSO2 Middleware on Containers

Container Cluster ManagersContainer Runtime Composite

Deployments

Development Production

Page 84: Deploying WSO2 Middleware on Containers

Questions/Feedback?

Page 85: Deploying WSO2 Middleware on Containers

Thank You!

#WSO2ConEU

Share your feedback for this session

wso2con.com/app