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

Post on 08-Oct-2020

2 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

socuteurl.com/widdlepuppytail

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

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

presented by

/ @ryanjryan jarvinen

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

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

Open Source Evangelistat

Red Hat

ryanj@redhat.com

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

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

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

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

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

CLOUD AUTOPSYCLOUD AUTOPSY

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

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

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

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

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

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

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

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

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

rhc cartridge list

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

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

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

using , and CgroupsSELinux

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

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

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

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

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

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

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

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

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

<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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

RELEASE MANAGEMENTRELEASE MANAGEMENT

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

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

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

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

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

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

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

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

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

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

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

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

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

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

top related