openshift: ease of paas with the flexibility of iaas

37
OPENSHIFT: EASE OF OPENSHIFT: EASE OF PAAS WITH THE FLEXI‐ PAAS WITH THE FLEXI‐ BILITY OF IAAS BILITY OF IAAS Author Evgeniy Khist

Upload: evgeniy-khyst

Post on 14-Jul-2015

632 views

Category:

Software


2 download

TRANSCRIPT

Page 1: OpenShift: Ease of PaaS with the Flexibility of IaaS

OPENSHIFT: EASE OFOPENSHIFT: EASE OFPAAS WITH THE FLEXI‐PAAS WITH THE FLEXI‐

BILITY OF IAASBILITY OF IAASAuthor Evgeniy Khist

Page 2: OpenShift: Ease of PaaS with the Flexibility of IaaS

OPENSHIFT: EASE OF PAAS WITH THE FLEXI‐OPENSHIFT: EASE OF PAAS WITH THE FLEXI‐BILITY OF IAASBILITY OF IAAS

OpenShift is a modern cloud platform which provides all requiredtools for development, hosting and scaling your applications in

public and private clouds.

Flexibility offered by OpenShift makes this platform unique.

OpenShift builds a bridge between ease offered by PaaS layerand flexibility of IaaS.

Page 3: OpenShift: Ease of PaaS with the Flexibility of IaaS

DIFFERENCE BETWEEN VPS AND CLOUDDIFFERENCE BETWEEN VPS AND CLOUDVPS - fixed resources of particular hardware server

Cloud - resources dynamically scalable as needed across a clusterof servers

Page 4: OpenShift: Ease of PaaS with the Flexibility of IaaS

IAAS, PAAS AND SAASIAAS, PAAS AND SAASInfrastructure as a Service (IaaS) - providing hardware resources

on demand with certain predefined virtual hardwareconfigurations (Amazon EC2, Rackspace). Targeted at DevOps and

system administrators.

Platform as a Service (PaaS) - providing a ready to usedevelopment environment with all server staff you need to run

your application. Configuration is made with a few commands ina web console or CLI (OpenShift). Targeted at developers.

Software as a Service (SaaS) - provides functionality with limitedcustomization capabilities. Provides one particular function

(Mailgun, ElephantSQL - PostgreSQL as a service).

Page 5: OpenShift: Ease of PaaS with the Flexibility of IaaS

OPENSHIFT FLEXIBILITYOPENSHIFT FLEXIBILITYOpenShift is infrastructure agnostic. It can be deployed on any

infrastructure where you can host RHEL, CentOS or Fedora.

Open architecture and the cartridge standards allow IT to build aplatform that suits the exact needs of organization. Developers

can have an application environments meeting their exact needsinstead architecting applications to overcome the restrictions

put by PaaS providers.

Page 6: OpenShift: Ease of PaaS with the Flexibility of IaaS

THE 3 VERSIONS OF OPENSHIFTTHE 3 VERSIONS OF OPENSHIFTOpenShift Origin - open source project under Apache Licencev2.0OpenShift Online - public cloud serviceOpenShift Enterprise - on-premise private cloud software

OpenShift covers all the server work. You are focused on yourapplication and its code.

OpenShift Online is hosted on AWS.

Page 7: OpenShift: Ease of PaaS with the Flexibility of IaaS

OPENSHIFT BASIC TERMINOLOGYOPENSHIFT BASIC TERMINOLOGYApplication - typical web application that will run on OpenShift.

Gear - a server, container with a set of resources that allows userto run their application.

Cartridge - plugin that hosts the framework or components thatcan be used to create and run an application. One cartridge can

run on many gears for clustering and scaling.

Standalone cartridge - languages and application servers set up toserve your web application (WildFly, JBoss EAP, Tomcat, DIY).

Embedded cartridge - provides functionality to enhance yourapplication such as DB, cron, but can not be used on its own to

create an application.

Page 8: OpenShift: Ease of PaaS with the Flexibility of IaaS

FOCUS ON WEB APPLICATIONSFOCUS ON WEB APPLICATIONSThe only ports exposed to incoming traffic are

HTTP (80), HTTPS (443)SSH (22)WebSoket HTTP (8000) and HTTPS (8443)

Page 9: OpenShift: Ease of PaaS with the Flexibility of IaaS

GEARS ISOLATIONGEARS ISOLATIONA single server may have multiple gears running at the same time,

each isolated from each other through SELinux protection. Eachgear is given a fair allocation of CPU, memory, disk, and network

bandwidth using Linux control groups.

Page 10: OpenShift: Ease of PaaS with the Flexibility of IaaS

JAVA CARTRIDGESJAVA CARTRIDGESJBoss Application Server 7 (Java EE 6)JBoss Enterprise Application Platform 6 (Java EE 6)Tomcat 6 (JBoss EWS 1.0)Tomcat 7 (JBoss EWS 2.0)Vert.x 2.1 ( )WildFly Application Server 8.1.0.Final (Java EE 7)CapeDwarf - implementation of the Google App Engine APIJBoss Business Process Management SuiteJBoss Business Rules Management SystemJBoss Fuse 6.1 - ESBDIY

http://vertx.io

Page 11: OpenShift: Ease of PaaS with the Flexibility of IaaS

GEAR SIZESGEAR SIZESSmall: 512 Mb RAM, max. 250 threadsMedium: 1 Gb RAMLarge: 2 Gb RAM

Gears of all sizes have 1 Gb disk space and 6 Gb on Silver plan.

Page 12: OpenShift: Ease of PaaS with the Flexibility of IaaS

CLIENT TOOLSCLIENT TOOLSYou can interact with the OpenShift platform via

RHC client command-line tools you install on your localmachineThe OpenShift Web ConsolePlugin in Eclipse

Client tools should be used for managing the infrastructure orcomponents of your application.

The rest of the work with application will happen through Git orSSH.

Page 13: OpenShift: Ease of PaaS with the Flexibility of IaaS

SCALABLE APPLICATION (1/3)SCALABLE APPLICATION (1/3)Application scaling enables your application to react to changesin traffic and automatically allocate the necessary resources to

handle your increased demand.

The OpenShift infrastructure monitors incoming web traffic andautomatically brings up new gears with the appropriate web

cartridge online to handle more requests.

When traffic decreases the platform retires the extra resources.

Page 14: OpenShift: Ease of PaaS with the Flexibility of IaaS

SCALABLE APPLICATION (2/3)SCALABLE APPLICATION (2/3)OpenShift provides autoscaling at the application tier.

HAProxy software-based load balancer will be added to the samegear as the application server.

All web traffic will be routed through HAProxy.

If number of connections goes above 16 - HAProxy will trigger acreation of another application gear.

OpenShift will:

set up new application server gearrsync code over the new gearplug the gear into HAProxyuse it to serve connections

Page 15: OpenShift: Ease of PaaS with the Flexibility of IaaS

SCALABLE APPLICATION (3/3)SCALABLE APPLICATION (3/3)

Page 16: OpenShift: Ease of PaaS with the Flexibility of IaaS

APPLICATION IDLINGAPPLICATION IDLINGOn Free plan your application will idle if it does not receive anHTTP requests from outside of your gear in 24 hours. Entire

application will be serialized on disk.

Application will be start up again when it receives its first HTTPrequest thereafter.

Application idling does not occur at the Bronze and Silver plan.

Page 17: OpenShift: Ease of PaaS with the Flexibility of IaaS

OPENSHIFT ARCHITECTURE (1/2)OPENSHIFT ARCHITECTURE (1/2)

Page 18: OpenShift: Ease of PaaS with the Flexibility of IaaS

OPENSHIFT ARCHITECTURE (2/2)OPENSHIFT ARCHITECTURE (2/2)When you push code changes to your application a build iscreated and deployed to all of the web gears.Each application has a set of environment variables that areshared across gears.WildFly gears serve incoming HTTP requests with the codeyou push.PostgreSQL sets environment variables so your applicationcode can easily connect.Jenkins detects incoming code pushes, runs your build andthen deploys your code to your web gears.

Page 19: OpenShift: Ease of PaaS with the Flexibility of IaaS

ACTION HOOKS (1/3)ACTION HOOKS (1/3)OpenShift provides developers entry points into various

application and platform lifecycle operations - action hooks, thathave special location within the application Git repository:

<repository>/.openshift/action_hooks

Page 20: OpenShift: Ease of PaaS with the Flexibility of IaaS

ACTION HOOKS (2/3)ACTION HOOKS (2/3)Cartridge action hooks:

pre_startpre_start_{cartridge_name}post_startpost_start_{cartridge_name}stopreloadrestarttidy

Page 21: OpenShift: Ease of PaaS with the Flexibility of IaaS

ACTION HOOKS (3/3)ACTION HOOKS (3/3)Build action hooks:

pre_buildbuilddeploypost_deploy

Page 22: OpenShift: Ease of PaaS with the Flexibility of IaaS

MARKERSMARKERSThe markers directory will allow the user to specify settings such

as enabling hot deployments or or which version of Java to use.

Page 23: OpenShift: Ease of PaaS with the Flexibility of IaaS

HOT DEPLOYHOT DEPLOYWhen JBoss AS, JBoss EAP, Tomcat 6 and Tomcat 7 applications

are hot deployed, the Maven build will be executed (either withJenkins or without), but the server does not restart.

Following the build, the JBoss HDScanner notices anymodifications and redeploys them.

If previously deployed artifacts are removed as part of the updatethey undeployed automatically.

Page 24: OpenShift: Ease of PaaS with the Flexibility of IaaS

CRONCRONOpenShift allows to schedule jobs.

Any scripts or jobs added to the minutely, hourly, daily, weekly,monthly directories will be ran on a scheduled basis.

Page 25: OpenShift: Ease of PaaS with the Flexibility of IaaS

JENKINSJENKINSCommit and push new code to your repo1. Jenkins waits for this commit, runs tests2. With OpenShift, if the tests and build are successful, the newcode gets deployed. If it fails, the old code continues to runwith no downtime related to the push.

3.

Users can review the persistent build history maintained byJenkins.

4.

Jenkins slave and builder application will consume 1 gear and willbe automatically freed after 15 idle minutes.

Page 26: OpenShift: Ease of PaaS with the Flexibility of IaaS

ENVIRONMENT VARIABLES (1/4)ENVIRONMENT VARIABLES (1/4)OPENSHIFT_<cart-name>_IP - The IP address theapplication listens on.OPENSHIFT_<cart-name>_PORT - The port the applicationreceives requests from.

Page 27: OpenShift: Ease of PaaS with the Flexibility of IaaS

ENVIRONMENT VARIABLES (2/4)ENVIRONMENT VARIABLES (2/4)OPENSHIFT_HOMEDIR - The home directory of the application.OPENSHIFT_DATA_DIR - A persistent data directory.OPENSHIFT_REPO_DIR - Repository containing the currentlydeployed version of the application.OPENSHIFT_TMP_DIR - A temporary directory you can use;SELinux protects data in this directory from other users.OPENSHIFT_LOG_DIR - Where all cartridge logs are stored.

Page 28: OpenShift: Ease of PaaS with the Flexibility of IaaS

ENVIRONMENT VARIABLES (3/4)ENVIRONMENT VARIABLES (3/4)OPENSHIFT_<database>_DB_HOST - The host name or IPaddress used to connect to the database.OPENSHIFT_<database>_DB_PORT - The port the databaseserver is listening on.OPENSHIFT_<database>_DB_USERNAME - The databaseadministrative user name.OPENSHIFT_<database>_DB_PASSWORD - The databaseadministrative user’s password.OPENSHIFT_<database>_DB_URL - Database connectionURL.

Page 29: OpenShift: Ease of PaaS with the Flexibility of IaaS

ENVIRONMENT VARIABLES (4/4)ENVIRONMENT VARIABLES (4/4)String envVar = System.getenv("OPENSHIFT_ENV_VAR");

rhc env set <variable1=value1> <variable2>=<value2> -a AppNamerhc env list -a AppName

Page 30: OpenShift: Ease of PaaS with the Flexibility of IaaS

EXAMPLE (1/7)EXAMPLE (1/7)gem install rhcrhc app create example -s jboss-wildfly-8rhc cartridge add postgresql-9.2 -a example

Page 31: OpenShift: Ease of PaaS with the Flexibility of IaaS

EXAMPLE (2/7)EXAMPLE (2/7)rhc git-clone examplegit add .git commit -m "Initial commit"git push

Page 32: OpenShift: Ease of PaaS with the Flexibility of IaaS

EXAMPLE (3/7)EXAMPLE (3/7)rhc port-forward -a example

Checking available ports ... doneForwarding ports ...

To connect to a service running on OpenShift, use the Local address

Service Local OpenShift---------- --------------- ---- ----------------------------------------------haproxy 127.0.0.1:8080 => 127.10.106.2:8080haproxy 127.0.0.1:8081 => 127.10.106.3:8080java 127.0.0.1:3528 => 127.10.106.1:3528java 127.0.0.1:8082 => 127.10.106.1:8080java 127.0.0.1:9990 => 127.10.106.1:9990postgresql 127.0.0.1:63101 => 546e5a994382ec9a4b00003e-evgeniykhist.rhcloud.

Press CTRL-C to terminate port forwarding

Page 33: OpenShift: Ease of PaaS with the Flexibility of IaaS

EXAMPLE (4/7)EXAMPLE (4/7)rhc ssh example

Connecting to [email protected] ...

...

[example-evgeniykhist.rhcloud.com 546dedc2e0b8cdef00000008]\>

Page 34: OpenShift: Ease of PaaS with the Flexibility of IaaS

EXAMPLE (5/7)EXAMPLE (5/7)rhc tail -a example

Page 35: OpenShift: Ease of PaaS with the Flexibility of IaaS

EXAMPLE (6/7)EXAMPLE (6/7)

Page 36: OpenShift: Ease of PaaS with the Flexibility of IaaS

EXAMPLE (7/7)EXAMPLE (7/7)http://jbosswildfly-evgeniykhist.rhcloud.com/

https://github.com/evgeniy-khist/examples/tree/master/url-shortener-example

Page 37: OpenShift: Ease of PaaS with the Flexibility of IaaS

More slides