Slide 1

Slide 1 text

OPENSHIFT Workshop PRESENTED BY Shekhar Gulati

Slide 2

Slide 2 text

AGENDA Introductions Installation Usage Overview

Slide 3

Slide 3 text

WHO AM I? • Shekhar Gulati • OpenShift Developer Evangelist • 8 years of software development experience • Learning JavaScript these days :) • Java / NoSQL/ Cloud • Loves to learn and try new technologies • Twitter Handle : shekhargulati • Github https://github.com/shekhargulati • Slides https://speakerdeck.com/shekhargulati

Slide 4

Slide 4 text

WHO ARE YOU?

Slide 5

Slide 5 text

In how many days/months/years JavaScript was written?

Slide 6

Slide 6 text

WHAT WILL YOU LEARN? • What is PaaS • What is OpenShift • What is MongoDB • How to use OpenShift for deployment https://localjobs-t20.rhcloud.com/

Slide 7

Slide 7 text

ASSUMPTIONS • You want to learn how to use OpenShift • You can write or read Java • You have your own laptop • You will ask questions

Slide 8

Slide 8 text

There are no stupid questions only stupid answers. So ask questions ASK QUESTIONS

Slide 9

Slide 9 text

OpenShift CLOUD OVERVIEW

Slide 10

Slide 10 text

Cloud Computing http://www.katescomment.com/definition-of-cloud-computing-nist-g-cloud/

Slide 11

Slide 11 text

“How do I use this?” Servers in the Cloud You must build and manage everything (OS, App Servers, DB, App, etc.) IaaS

Slide 12

Slide 12 text

“I’m not sure this does what I need.” You are restricted to the features of the 3rd Party application Someone else’s app in the Cloud (CRM, etc.) SaaS

Slide 13

Slide 13 text

• Quickly build the Application that YOU need for • Your Group, your Enterprise, your next great idea! • Big data, mobile, social • You code the application, We run it for you • Leverage the ease, scale and power of the Cloud Code Deploy Enjoy PaaS

Slide 14

Slide 14 text

14 Cloud Service Models STORAGE (RHS) HARDWARE (x86, Power, S/390) VIRTUALIZATION (RHEV) OPERATING SYSTEM (RHEL) APPLICATION PLATFORM (JBOSS, PHP, RUBY, ETC) APPLICATION Automated and Managed by the Public or Private Cloud Offering Managed and Controlled by Customer (IT, Dev, or User) IaaS PaaS SaaS Increased Control Increased Automation

Slide 15

Slide 15 text

EVERYONE GETS ALONG • Operations care about stability and performance • Developers just want environments without waiting OpenShift creates a peaceful environment for both parties

Slide 16

Slide 16 text

16 15/03/13 Lowers Cost Improves Developer Efficiency Scales WHY CHOOSE PAAS

Slide 17

Slide 17 text

OpenShift OPENSHIFT OVERVIEW

Slide 18

Slide 18 text

18 OpenShift is PaaS by Red Hat Multi-language, Auto-Scaling, Self-service, Elastic, Cloud Application Platform

Slide 19

Slide 19 text

19  A free auto-scaling, cloud-based application platform from Red Hat.  Multi Language, Multi Frameworks, Multi Cartridges.  No proprietary software.  No Lock-in.  Open source – OpenShift Origin. INTRODUCING OPENSHIFT

Slide 20

Slide 20 text

origin Public Cloud Service On- premise or Private Cloud Software Open Source Project FLAVORS OF OPENSHIFT

Slide 21

Slide 21 text

Developer IDE Integrations Web Browser Console Command Line Tooling REST APIs INTERACTIONS

Slide 22

Slide 22 text

22 ● Strength. OpenShift is built on proven Red Hat technologies. ● Freedom. In OpenShift, work the way you want. ● Choice of Interface: Web Console, Command-line, or IDE ● Choice of Middleware: Java(EE6), Ruby, Node.js, PHP, Python, and Perl ● Choice of Cloud: Public, Private, or Hybrid Cloud ● Choice of Elasticity: Automatic application scaling when needed ● Openness. OpenShift’s open source software stack ensures application portability and No Lock-In. WHY OPENSHIFT

Slide 23

Slide 23 text

23 WHAT's IN THE BOX

Slide 24

Slide 24 text

24 OpenShift is the BEST PaaS for Java Developers

Slide 25

Slide 25 text

25 ● Can run any thing that's Java – Java EE or Spring does not matter. ● Supports both Java 6 and Java 7 ● Supports JBoss AS7, JBoss EAP 6.0, Tomcat 6 , and Tomcat 7 ● Ability to write to persistent file system ● Debugging support ● Hot deployment ● Eclipse support WHY OPENSHIFT IS BEST JAVA PAAS

Slide 26

Slide 26 text

26  OpenShift is free-as-in-beer & free-as-in-freedom  You get three free gears, each with 512MB memory and 1GB of disk space.  Need more resources, just ask!  The catch is we are in developer preview right now WHAT I GET

Slide 27

Slide 27 text

27 Let's get our hands dirty

Slide 28

Slide 28 text

28 https://openshift.redhat.com/app/account/new Promo code is COLOMBO CREATING OPENSHIFT ACCOUNT

Slide 29

Slide 29 text

29 ➢ Login to OpenShift web console ➢ Click on “My Account” ➢ Namespace – colombomeetup – Unique per user CREATING NAMESPACE

Slide 30

Slide 30 text

30 DEMO : WORDPRESS IN CLOUD

Slide 31

Slide 31 text

31 Some terminology for today 1. Application – your web code and any data store. Has to be on 1 or more gears 2. Gear – is like a server. It can have only 1 language for the web programming. 3. Cartridge – it adds a language, a data store, or other functionality 4. Git – used for version control and managing code between server and your development machine 5. Ssh – command line tool to connect to your gear

Slide 32

Slide 32 text

WORKFLOW RHEL RHEL Brokers Node Node Web Console Eclipse IDE Cmd Line OpenShift Gear

Slide 33

Slide 33 text

CARTRIDGES RHEL RHEL Brokers Node Node Web Console Eclipse IDE Cmd Line JBOSS MYSQL

Slide 34

Slide 34 text

CARTRIDGES CUSTOM Etc. Etc. Ruby Python PHP Java Postgres MySQL OpenShift Default Cartridges

Slide 35

Slide 35 text

RHEL RHEL Developer pushes application code via GIT source code management system Git Protocol / ssh Broker Node Node Node RHEL Push JBoss Code Git Repo MySQL WORKFLOW

Slide 36

Slide 36 text

36 Install Ruby 1.8.7 or greater Install Git Install rhc OpenShift gem Refer to documentation INSTALLING CLIENT TOOLS

Slide 37

Slide 37 text

37 rhc setup -l -> creates namespace -> upload ssh keys SETUP OPENSHIFT ENVIRONMENT

Slide 38

Slide 38 text

38 Let's see it in action

Slide 39

Slide 39 text

39 BUILDING APPLICATION

Slide 40

Slide 40 text

40  MongoDB 2.2  OpenShift  Java 7 – Spring Framework – Spring MongoDB  GIT  SSH TECHNOLOGY CHOICES

Slide 41

Slide 41 text

41  Open Source NoSQL document datastore  Active community  Rich documents  Easy to get running  Geospatial indexing  Writes are very fast. You can customize it using WriteConcern WHAT IS MONGODB

Slide 42

Slide 42 text

42 RICH DOCUMENTS

Slide 43

Slide 43 text

43  What is it for?  Find all the MongoDB jobs near me – Proximity Queries  Find all the MongoDB jobs within Colombo – Bounded Queries  Find all the MongoDB job at this location – Exact Queries ● Supports only two dimensional indexes.  You can only have one geospatial index per collection.  By default, 2d geospatial indexes assume longitude and latitude have boundaries of -180 inclusive and 180 non-inclusive (i.e. [-180, 180)) GEOSPATIAL INDEXING BASICS

Slide 44

Slide 44 text

44 1) Put your coordinates into an array { loc : [ 50 , 30 ] } //SUGGESTED OPTION { loc : { x : 50 , y : 30 } } { loc : { foo : 50 , y : 30 } } 1) { loc : { lon : 40.739037, lat: 73.992964 } } 2) Make a 2d index db.places.ensureIndex( { loc : "2d" } ) 3) If you use latitude and longitude as your coordinate system, always store longitude first. MongoDB’s 2d spherical index operators only recognize [ longitude, latitude] ordering. HOW TO MAKE IT WORK

Slide 45

Slide 45 text

45 ● When you create the index, MongoDB converts location data to binary geohash values and calculates these values using the location data and the index’s location range ● Geohashes have a precision that is determined by the number of bits in the hash. Default value 26 ● More bits allow the index to provide results with greater precision ● You can configure number of bits at index creation db.collection.ensureIndex( {: "2d"} , { bits: } ) GEOHASHES

Slide 46

Slide 46 text

46 ● MongoDB supports compound geospatial indexes. ● the field with location data is the first field db.jobs.ensureIndex( { location: "2d", skills: 1 } ) COMPOUND GEOSPATIAL INDEXES

Slide 47

Slide 47 text

47 Distributed Version control A local repository – on your laptop A remote repository – on some other machine, usually a server LET's LOOK AT GIT

Slide 48

Slide 48 text

48 1. Git add . (means add all new files as being tracked in the local repository) 2. Git commit –am “your message” (means commit all my changes to the local repository with this message) 3. Git push (means push from your local repository to the repository on your OpenShift gear) 3 COMMANDS YOU SHOULD KNOW

Slide 49

Slide 49 text

49 $ rhc app create localjobs jbosseap mongodb-2.2 –from- code=git://github.com/shekhargulati/localjobs.git $ rhc app show -a localjobs $ scp jobs-data.json :app-root/data $ rhc app ssh -a localjobs $ cd app-root/data $ mongoimport -d localjobs -c jobs --file jobs-data.json -u $OPENSHIFT_MONGODB_DB_USERNAME -p $OPENSHIFT_MONGODB_DB_PASSWORD -h $OPENSHIFT_MONGODB_DB_HOST -port $OPENSHIFT_MONGODB_DB_PORT Instructions at https://github.com/shekhargulati/localjobs/blob/master/README.md DEMO : LOCALJOBS APP

Slide 50

Slide 50 text

50 Look at the generated code

Slide 51

Slide 51 text

QUESTIONS?

Slide 52

Slide 52 text

DONE!