a tour of from the ccoommmmaanndd lliinnee€¦ · application options-----namespace: shifter...

45
A tour of from the COMMAND LINE COMMAND LINE featuring: ssh, git, and rhc bit.ly/1mq7s5h Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/ 1 of 45 02/23/2014 02:18 PM

Upload: others

Post on 08-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

A tour of

from the

COMMAND LINECOMMAND LINEfeaturing:

ssh, git, and rhc

bit.ly/1mq7s5h

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

1 of 45 02/23/2014 02:18 PM

Page 2: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

socuteurl.com/widdlepuppytail

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

2 of 45 02/23/2014 02:18 PM

Page 3: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

presented by

/ @ryanjryan jarvinen

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

3 of 45 02/23/2014 02:18 PM

Page 4: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Open Source Evangelistat

Red Hat

[email protected]

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

4 of 45 02/23/2014 02:18 PM

Page 5: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

AGENDAAGENDA1.2.3.4.5.6.

State of the Open CloudrhcsshgitRelease ManagementScaling

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

5 of 45 02/23/2014 02:18 PM

Page 6: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

STATE OF THE OPEN CLOUDSTATE OF THE OPEN CLOUD

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

6 of 45 02/23/2014 02:18 PM

Page 7: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

HAS IT BEENHAS IT BEEN

LIBERATED?LIBERATED?The OS ✓1.The Cloud ?2.Infrastructure as a service ✓3.Platform as a service ✓4.Software as a service ×5.

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

7 of 45 02/23/2014 02:18 PM

Page 8: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

CLOUD AUTOPSYCLOUD AUTOPSY

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

8 of 45 02/23/2014 02:18 PM

Page 9: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

9 of 45 02/23/2014 02:18 PM

Page 10: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

OPENSHIFT IS…OPENSHIFT IS…

OPEN SOURCEOPEN SOURCEHOSTING,HOSTING,

BUILD,BUILD,and

AUTO-SCALINGAUTO-SCALINGfor applications

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

10 of 45 02/23/2014 02:18 PM

Page 11: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

providing instant access to all of this, and more:

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

11 of 45 02/23/2014 02:18 PM

Page 12: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

12 of 45 02/23/2014 02:18 PM

Page 13: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

these technolgies are bundled / made available as

CARTRIDGESCARTRIDGES

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

13 of 45 02/23/2014 02:18 PM

Page 14: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

rhc cartridge list

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

14 of 45 02/23/2014 02:18 PM

Page 15: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

On OpenShift, your application environment issecurely incapsulated within a 'Gear', providing

guaranteed access to system resources

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

15 of 45 02/23/2014 02:18 PM

Page 16: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

using , and CgroupsSELinux

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

16 of 45 02/23/2014 02:18 PM

Page 17: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

OPENSHIFT PROVIDES A PEACEFUL ENVIRONMENT FOR DEVS AND SYSADMINS TOOPENSHIFT PROVIDES A PEACEFUL ENVIRONMENT FOR DEVS AND SYSADMINS TOWORK TOGETHER INWORK TOGETHER IN

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

17 of 45 02/23/2014 02:18 PM

Page 18: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Operations care about stability and performanceDevelopers just want environments withoutwaitingAnd neither one wants to have to fight the other toget their work done

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

18 of 45 02/23/2014 02:18 PM

Page 19: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

RHCRHCCommand Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

19 of 45 02/23/2014 02:18 PM

Page 20: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

rhc makes it easy for developers to talk to yourOpenShift REST API

PRE-REQUISITES:PRE-REQUISITES:

rubygems, gitsudo gem install rhc

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

20 of 45 02/23/2014 02:18 PM

Page 21: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Will automatically:

authenticate your OpenShift accountverify your local ssh key configurationconfigure your host url identifier

rhc setup

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

21 of 45 02/23/2014 02:18 PM

Page 22: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

CREATE AN APPLICATIONCREATE AN APPLICATIONStart by provisioning your application environment

and database in a single step:

for a basic Nodejs and MongoDB application, run:

rhc app create APP_NAME CARTRIDGE CART2 CART3

rhc app create scale12x nodejs-0.10 mongodb-2.2

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

22 of 45 02/23/2014 02:18 PM

Page 23: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

<command-line output>Application Options------------------- Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling: no

Creating application 'scale12x' ... done

Waiting for your DNS name to be available ... done

Downloading the application Git repository ...Cloning into 'scale12x'...

Your application code is now in 'scale12x'

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

23 of 45 02/23/2014 02:18 PM

Page 24: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

scale12x @ http://scale12x-shifter.rhcloud.com/ (uuid: 5175981a5973ca7a69000501------------------------------------------------------------- Created: 1:05 PM Gears: 1 (defaults to small) Git URL: ssh://[email protected]/~/git/scale SSH: [email protected]

nodejs-0.10 (Node.js 0.10) ------------------------ Gears: Located with mongodb-2.2

mongodb-2.2 (MongoDB NoSQL Database 2.2) ---------------------------------------- Gears: Located with nodejs-0.10 Connection URL:mongodb://$OPENSHIFT_MONGODB_DB_HOST:$OPENSHIFT_MONGODB_DB_PORT/ Database Name: scale12x Password: PTk4cCetTj2w Username: admin

RESULT:Application scale12x was created.

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

24 of 45 02/23/2014 02:18 PM

Page 25: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

SUCCESS!SUCCESS!You now have a basic node.js and MongoDB skeleton

application live on the Internet!

Your gear is now configured with:

it's own git repoit's own web serverssh accesslogginga databasepublicly accessible hostnames, automatic DNS

http://scale12x-shifter.rhcloud.com/

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

25 of 45 02/23/2014 02:18 PM

Page 26: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Application details are always available via:

You can tail your remote logs with:

or, connect directly to your app via ssh:

rhc app show scale12x

rhc tail scale12x

rhc ssh scale12x

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

26 of 45 02/23/2014 02:18 PM

Page 27: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

SSHSSHCommand Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

27 of 45 02/23/2014 02:18 PM

Page 28: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

ENVIRONMENT VARIABLESENVIRONMENT VARIABLESAllow you to write code that will run anywhere

//provide a sensible default for local developmentmongodb_connection_string = 'mongodb://127.0.0.1:27017/' + db_name;//take advantage of openshift env vars when available:if(process.env.OPENSHIFT_MONGODB_DB_URL){ mongodb_connection_string = process.env.OPENSHIFT_MONGODB_DB_URL + db_name;}

//same advice applies for your webserver's PORT and IP addressvar port = process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT || var ip = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

28 of 45 02/23/2014 02:18 PM

Page 29: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Application passwords, keys, and secrets can beabstracted using the same technique:

rhc env set SECRET_KEY=0P3N_S0URC3

rhc env list

rhc env help

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

29 of 45 02/23/2014 02:18 PM

Page 30: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Team members can supply their own keys during appcreation, for a single step clone+deploy:

rhc app create scale12x nodejs-0.10 mongodb-2.2 \--from-code=http://github.com/USER/TEAM_REPO.git \--env SECRET_KEY=0P3N_S0URC3

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

30 of 45 02/23/2014 02:18 PM

Page 31: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

TEAM COLLABORATIONTEAM COLLABORATIONThere are several ways to collaborate:

using 1.using 2.or, using 3.

github or bitbucketssh keys

OpenShift's new team collaboration tools

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

31 of 45 02/23/2014 02:18 PM

Page 32: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

GITGITCommand Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

32 of 45 02/23/2014 02:18 PM

Page 33: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

DEPLOYING UPDATESDEPLOYING UPDATESA standard git development workflow can be used to

rebuild and update your remote application:

Add your changes to a changeset1.

Mark the changeset as a Commit2.

Push the Commit to OpenShift3.

git add index.html

git commit -m 'updating H1'

git push

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

33 of 45 02/23/2014 02:18 PM

Page 34: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Adding cartridges to existing apps is easy:

adds jenkins CI to your application's build cycle

rhc cartridge add jenkins-1

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

34 of 45 02/23/2014 02:18 PM

Page 35: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

RELEASE MANAGEMENTRELEASE MANAGEMENT

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

35 of 45 02/23/2014 02:18 PM

Page 36: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

RELEASE TRACKING & ROLLBACKSRELEASE TRACKING & ROLLBACKS

Want to deploy a different branch (not 'master')?

rhc deployment show

rhc deployment list

rhc deployment activate CHECKSUM

rhc app configure --deployment-branch MY_BRANCH

https://www.openshift.com/blogs/introduction-to-deployments-and-rollbacks-on-openshift

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

36 of 45 02/23/2014 02:18 PM

Page 37: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

TIPS FOR LOCAL DEVELOPMENTTIPS FOR LOCAL DEVELOPMENTUse port-forwarding to create a local connection to

your remote database instance:

Starting a local webserver is different in each language.For nodejs, you can start a local server with:

rhc port-forward scale12

npm install

npm start

https://www.openshift.com/blogs/set-up-local-access-to-openshift-hosted-services-with-port-

forwarding

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

37 of 45 02/23/2014 02:18 PM

Page 38: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

SCALINGSCALINGCommand Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

38 of 45 02/23/2014 02:18 PM

Page 39: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Spinning up an auto-scaling Linux environment:

just add "-s" to your app create command

rhc app create scale12 -s nodejs-0.10 mongodb-2.2

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

39 of 45 02/23/2014 02:18 PM

Page 40: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

Set a min and max scale

or, manually scale an application

rhc cartridge scale nodejs-0.10 -a scale12 --min 2 --max 12

rhc app scale-up

rhc app scale-down

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

40 of 45 02/23/2014 02:18 PM

Page 41: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

From inside a hosted environment:

HAProxy on / off switches

haproxy_ctld --up

haproxy_ctld --down

haproxy_ctld_daemon start

haproxy_ctld_daemon stop

haproxy_ctld_daemon restart

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

41 of 45 02/23/2014 02:18 PM

Page 42: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

GENERATING LOADGENERATING LOADFor scalable applications, generate load from thecommand line to see automatic scaling in action:while true ; do ab -n 1000 -c 50 https://scale12-shifter.rhcloud.com/ ; done

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

42 of 45 02/23/2014 02:18 PM

Page 43: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

HAPROXY WEB UIHAPROXY WEB UIhttp://$YOUR_APP_DNS/haproxy-status/

HAPROXY RAW DATAHAPROXY RAW DATAhttp://$YOUR_APP_DNS/haproxy-status/;csv

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

43 of 45 02/23/2014 02:18 PM

Page 44: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

QUESTIONS?QUESTIONS?Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

44 of 45 02/23/2014 02:18 PM

Page 45: A tour of from the CCOOMMMMAANNDD LLIINNEE€¦ ·  Application Options-----Namespace: shifter Cartridges: nodejs-0.10, mongodb-2.2 Gear Size: default Scaling:

WANT TO LEARN MORE?WANT TO LEARN MORE?Come hang out with us on IRC:

Link to these slides:

Free hosting on OpenShift: OpenShift source code: Red Hat Enterprise Support:

presented by:

/ @ryanjryan jarvinen

http://socuteurl.com/widdlepuppytailOpenShift Online

OpenShift OriginOpenShift Enterprise

#openshift on Freenode

Command Line OpenShift http://ryanjarvinen.com/presentations/openshift-cli/

45 of 45 02/23/2014 02:18 PM