• Save
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
Upcoming SlideShare
Loading in...5
×
 

OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce

on

  • 561 views

Presenters: Jhon Honce ...

Presenters: Jhon Honce

Cartridges allow developers to provide services running on top of the Red Hat OpenShift Platform-as-a-Service (PaaS). OpenShift already provides cartridges for numerous web application frameworks and databases. Writing your own cartridges allows you to customize or enhance an existing service, or provide new services. In this session, the presenter will discuss best practices for cartridge development and the latest changes in the OpenShift cartridge support.

* Latest changes made in the platform to ease cartridge development
* OpenShift Cartridges vs. plugins
* Outline for development of a new cartridge
* Customization of existing cartridges
* Quickstarts: leveraging a cartridge or cartridges to provide a complete application

Statistics

Views

Total Views
561
Views on SlideShare
545
Embed Views
16

Actions

Likes
0
Downloads
0
Comments
0

2 Embeds 16

https://twitter.com 15
http://moderation.local 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce Presentation Transcript

  • Writing Cartridges for OpenShiftJhon HoncePr Software Engineer, Red Hat IncOpenShift Origin Community Day (Boston)June 13, 2013http://openshift.github.io
  • The OpenShift Ecosystem: GUI/CLI, Broker, NodeGUIrhc (CLI)BrokerNode(Cartridges)REST APIssh|git MCollectivesnapshot.tgzgitrepository
  • Where does my code fit?● Application – application developer● Gears – PaaS developer● Cartridges – Cartridge authors● Web Frameworks, Databases, Daemons● Encapsulates some piece software for use withinthe PaaS View slide
  • The Cartridge API● Low overhead● Named executable files● stdout/stderr● Environment variables● Configuration files:manifest.yml, managed_files.yml● You can use any language● source $OPENSHIFT_CARTRIDGE_SDK_BASH● The software you are packaging must either be on thesystem or included in your cartridge View slide
  • Minimal Cartridge – identify cartridge+- bin| +- setup| +- control+- env+- metadata| +- manifest.yml● Assumes packaged softwarealready installed on system● Most cartridges will havemore files● manifest.ymlName: dogCartridge-Short-Name: DOG.:Version: ‘1.0’Cartridge-Version: 0.0.1Cartridge-Vendor: honce
  • Minimal Cartridge – required files+- bin| +- setup| +- control+- env+- metadata| +- manifest.yml● Assumes packaged softwarealready installed on system● Most cartridges will havemore files● manifest.ymlName: dogCartridge-Short-Name: DOG.:Version: ‘1.0’Cartridge-Version: 0.0.1Cartridge-Vendor: honce
  • Minimal Cartridge+- bin| +- setup| +- control+- env+- metadata| +- manifest.yml● Assumes packaged softwarealready installed on system● Most cartridges will havemore files● manifest.ymlName: dogCartridge-Short-Name: DOG.:Version: ‘1.0’Cartridge-Version: 0.0.1Cartridge-Vendor: honce
  • My Cartridge needs to be seen!+- bin| +- …| +- control+…● control Arguments● start● stop● manifest.yml.:Endpoints:- Private-IP-Name: IPPrivate-Port-Name: PORTPrivate-Port: 8080Public-Port-Name: PROXY_PORTMappings:- Frontend: ""Backend: ""● Environment VariablesOPENSHIFT_<SHORT_NAME>_IPOPENSHIFT_<SHORT_NAME>_PORTOPENSHIFT_…_PROXY_PORT
  • My Cartridge needs to be invoked+- bin| +- …| +- control+…● Basic control arguments● start● stop● manifest.yml.:Endpoints:- Private-IP-Name: IPPrivate-Port-Name: PORTPrivate-Port: 8080Public-Port-Name: PROXY_PORTMappings:- Frontend: ""Backend: ""
  • My Cartridge needs to be seen!+- bin| +- …| +- control+…● Basic control arguments● start● stop● manifest.yml.:Endpoints:- Private-IP-Name: IPPrivate-Port-Name: PORTPrivate-Port: 8080Public-Port-Name: PROXY_PORTMappings:- Frontend: ""Backend: ""
  • Tip: control script can be trivial.:case “$1” instart)/usr/sbin/httpd -C "Include $OPENSHIFT_DOG_CONF_DIR/*.conf" -f $HTTPD_CFG_FILE -k start ;;stop)… -k stop ;;restart)… -k restart ;;esac
  • My Cartridge needs help, a database cartridge+- hooks| +- …| +- publish-db-connection-info+…● manifest.yml.:Publishes:publish-db-connection-info:Type: "ENV:NET_TCP:db:connection-info"● Pub/Sub Protocol● publish-db-connection-info is a scriptecho OPENSHIFT_MYSQL_DB_HOST=$OPENSHIFT_GEAR_DNSecho OPENSHIFT_MYSQL_DB_PORT=$OPENSHIFT_MYSQL_DB_PROXY_PORTecho OPENSHIFT_MYSQL_DB_URL=”mysql://…/”
  • My Cartridge needs help, a database cartridge!● manifest.yml.:Publishes:publish-db-connection-info:Type: "ENV:NET_TCP:db:connection-info"● Publish/Subscribe Protocol● publish-db-connection-info is a scriptecho OPENSHIFT_MYSQL_DB_HOST=$OPENSHIFT_GEAR_DNSecho OPENSHIFT_MYSQL_DB_PORT=$OPENSHIFT_MYSQL_DB_PROXY_PORTecho OPENSHIFT_MYSQL_DB_URL=”mysql://…/”
  • My Cartridge needs needs to be listening● Pub/Sub Protocol● The Type: element determines both the message format andwhether the subscribe hook may be implemented in thePlatform● A provided hook script will be run in place of Platform code● manifest.yml.:Subscribes:set-db-connection-info:Type: “ENV:NET_TCP:db:connection-info”Required: false
  • Let the Platform the cartridge can use a database● Pub/Sub Protocol● The Type: element determines both the message format andwhether the subscribe hook may be implemented in thePlatform● A provided hook script will be run in place of Platform code● manifest.yml.:Subscribes:set-db-connection-info:Type: “ENV:NET_TCP:db:connection-info”Required: false
  • Let the Platform the cartridge can use a database● Pub/Sub Protocol● The Type: element determines both the message format andwhether the subscribe hook may be implemented in thePlatform● A provided hook script will be run in place of Platform code● manifest.yml.:Subscribes:set-db-connection-info:Type: “ENV:NET_TCP:db:connection-info”Required: false
  • My Cartridge needs to be listening for databases● Pub/Sub Protocol● The Type: element determines both the message format andwhether the subscribe hook may be implemented in thePlatform● A provided hook script will be run in place of Platform code● manifest.yml.:Subscribes:set-db-connection-info:Type: “ENV:NET_TCP:db:connection-info”Required: false
  • My Cartridge needs to be listening for databases● Pub/Sub Protocol● The Type: element determines both the message format andwhether the subscribe hook may be implemented in thePlatform● A provided hook script will be run in place of Platform code● manifest.yml.:Subscribes:set-db-connection-info:Type: “ENV:NET_TCP:db:connection-info”Required: false
  • Customize Work Flows● Cartridge Authors● Implement additional control actions● Provide optional scrips● Application Developers● .openshift/action_hooks● .openshift/markers● git pushed from developers repository
  • For Language Frameworks: A sample application● template directory● Checked in as the gears initial git repository● A “complete” application demonstrating that yourcartridge is ready for business● If you should add the manifest element:● Install-Build-Required: false● Speeds up the installation of your cartridge● You need to do work for the application developer
  • Environment VariablesThe Node/Application/Gear/Cartridge all have sharedenvironment variables in their scope● Node Scope variables● /etc/openshift/env● Gear Scope● .../<gear uuid>/.env● Application Scope● .../<gear uuid>/.env/<cartridge name>● Cartridge Scope● .../<gear uuid>/<cartridge name>/env
  • Example Platform Environment Variables● OPENSHIFT_APP_NAME● OPENSHIFT_APP_DNS● OPENSHIFT_DATA_DIR● OPENSHIFT_HOMEDIR● OPENSHIFT_TMP_DIR● OPENSHIFT_<SHORT NAME>_DIR● OPENSHIFT_<SHORT NAME>_IP● OPENSHIFT_<SHORT NAME>_PORT● You and application developer use these to tie into the software youare packaging● System tracks them and builds the correct process environment foryou
  • Creating An Application With Your Cartridge● rhc create-app dog001 http://…/metadata/manifest.yml● Tip: use raw URL from github● manifest.yml contains Source-Url element● Source-Url addresses root of your cartridge● Tip: use download zip file from github repository
  • Tip: Origin VM as a development platform● http://openshift.github.io/● Broker-Node communication● /var/log/mcollective.log● Node logging● /var/log/openshift/node/platform.log● Node detailed logging● /var/log/openshift/node/platform-trace.log● Warning: Origin – Fedora 18Online – RHEL 6
  • Tip: Examples – Online Cartridges● http://tinyurl.com/online-cartridges● JBoss EWS: multiple versions of packaged softwareand support for multiple java versions● MySQL: pub/sub database connections● PHP My Admin: one cartridge dependent on another
  • Tip: Using bash for scripts● -e and -u options are your friends● -e exit on error● -u using unset variable is an error● -x for debugging● Bash “SDK” (Library of functions)● source $OPENSHIFT_CARTRIDGE_SDK_BASH
  • ERB File Rendering● Unified method of doing value substitutions inconfiguration files● httpd.conf, php.ini, etc● metadata/managed_files.yml● processed_templates:- **/*.erb● All environment variables available● No code can be executed
  • Title hereText with no bullets● Bullets layer one● Bullets layer two● Bullets layer three
  • Additional Resources!● Cartridge Writing Guide:http://tinyurl.com/writing-cartridges● IRC Freenode● #openshift (application developers)● #openshift-dev (PaaS development)● #openshift-dev-node (cartridge/node development)● Email● dev@lists.openshift.redhat.com
  • For more information:http://openshift.github.ioFollow us on twitter:@openshiftJoin us on irc (freenode):openshift