SlideShare a Scribd company logo
Writing Cartridges for OpenShift
Jhon Honce
Pr Software Engineer, Red Hat Inc
OpenShift Origin Community Day (Boston)
June 13, 2013
http://openshift.github.io
The OpenShift Ecosystem: GUI/CLI, Broker, Node
GUI
rhc (CLI)
Broker
Node
(Cartridges)
REST API
ssh|git MCollective
snapshot.tgz
gitrepository
Where does my code fit?
● Application – application developer
● Gears – PaaS developer
● Cartridges – Cartridge authors
● Web Frameworks, Databases, Daemons
● Encapsulates some piece software for use within
the PaaS
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 the
system or included in your cartridge
Minimal Cartridge – identify cartridge
+- bin
| +- setup
| +- control
+- env
+- metadata
| +- manifest.yml
● Assumes packaged software
already installed on system
● Most cartridges will have
more files
● manifest.yml
Name: dog
Cartridge-Short-Name: DOG
.
:
Version: ‘1.0’
Cartridge-Version: 0.0.1
Cartridge-Vendor: honce
Minimal Cartridge – required files
+- bin
| +- setup
| +- control
+- env
+- metadata
| +- manifest.yml
● Assumes packaged software
already installed on system
● Most cartridges will have
more files
● manifest.yml
Name: dog
Cartridge-Short-Name: DOG
.
:
Version: ‘1.0’
Cartridge-Version: 0.0.1
Cartridge-Vendor: honce
Minimal Cartridge
+- bin
| +- setup
| +- control
+- env
+- metadata
| +- manifest.yml
● Assumes packaged software
already installed on system
● Most cartridges will have
more files
● manifest.yml
Name: dog
Cartridge-Short-Name: DOG
.
:
Version: ‘1.0’
Cartridge-Version: 0.0.1
Cartridge-Vendor: honce
My Cartridge needs to be seen!
+- bin
| +- …
| +- control
+…
● control Arguments
● start
● stop
● manifest.yml
.
:
Endpoints:
- Private-IP-Name: IP
Private-Port-Name: PORT
Private-Port: 8080
Public-Port-Name: PROXY_PORT
Mappings:
- Frontend: ""
Backend: ""
● Environment Variables
OPENSHIFT_<SHORT_NAME>_IP
OPENSHIFT_<SHORT_NAME>_PORT
OPENSHIFT_…_PROXY_PORT
My Cartridge needs to be invoked
+- bin
| +- …
| +- control
+…
● Basic control arguments
● start
● stop
● manifest.yml
.
:
Endpoints:
- Private-IP-Name: IP
Private-Port-Name: PORT
Private-Port: 8080
Public-Port-Name: PROXY_PORT
Mappings:
- Frontend: ""
Backend: ""
My Cartridge needs to be seen!
+- bin
| +- …
| +- control
+…
● Basic control arguments
● start
● stop
● manifest.yml
.
:
Endpoints:
- Private-IP-Name: IP
Private-Port-Name: PORT
Private-Port: 8080
Public-Port-Name: PROXY_PORT
Mappings:
- Frontend: ""
Backend: ""
Tip: control script can be trivial
.
:
case “$1” in
start)
/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 script
echo OPENSHIFT_MYSQL_DB_HOST=$OPENSHIFT_GEAR_DNS
echo OPENSHIFT_MYSQL_DB_PORT=$OPENSHIFT_MYSQL_DB_PROXY_PORT
echo 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 script
echo OPENSHIFT_MYSQL_DB_HOST=$OPENSHIFT_GEAR_DNS
echo OPENSHIFT_MYSQL_DB_PORT=$OPENSHIFT_MYSQL_DB_PROXY_PORT
echo OPENSHIFT_MYSQL_DB_URL=”mysql://…/”
My Cartridge needs needs to be listening
● Pub/Sub Protocol
● The Type: element determines both the message format and
whether the subscribe hook may be implemented in the
Platform
● 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 and
whether the subscribe hook may be implemented in the
Platform
● 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 and
whether the subscribe hook may be implemented in the
Platform
● 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 and
whether the subscribe hook may be implemented in the
Platform
● 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 and
whether the subscribe hook may be implemented in the
Platform
● 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 gear's initial git repository
● A “complete” application demonstrating that your
cartridge 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 Variables
The Node/Application/Gear/Cartridge all have shared
environment 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 you
are packaging
● System tracks them and builds the correct process environment for
you
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 18
Online – RHEL 6
Tip: Examples – Online Cartridges
● http://tinyurl.com/online-cartridges
● JBoss EWS: multiple versions of packaged software
and 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 in
configuration files
● httpd.conf, php.ini, etc
● metadata/managed_files.yml
● processed_templates:
- '**/*.erb'
● All environment variables available
● No code can be executed
Title here
Text 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.io
Follow us on twitter:
@openshift
Join us on irc (freenode):
openshift

More Related Content

PDF
Last 2 Months in PHP - July & August 2016
PPTX
Autotools pratical training
PDF
[COSCUP 2021] A trip about how I contribute to LLVM
PDF
PSR7 - interoperabilità HTTP
ODP
30 Minutes To CPAN
PDF
Debugging PHP with Xdebug - PHPUK 2018
PDF
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
PDF
Phing: Building with PHP
Last 2 Months in PHP - July & August 2016
Autotools pratical training
[COSCUP 2021] A trip about how I contribute to LLVM
PSR7 - interoperabilità HTTP
30 Minutes To CPAN
Debugging PHP with Xdebug - PHPUK 2018
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Phing: Building with PHP

What's hot (20)

PPTX
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
PDF
Golang execution modes
PDF
Writing an Ostinato Protocol Builder [FOSDEM 2021]
ODP
Phing - A PHP Build Tool (An Introduction)
PDF
[COSCUP 2020] How to use llvm frontend library-libtooling
PDF
Fluentd Hacking Guide at RubyKaigi 2014
ODP
Vagrant move over, here is Docker
ODP
LSA2 - 03 Http apache nginx
PDF
Putting Phing to Work for You
PDF
Phing
PDF
Laravel 4 package development
PDF
Centralized Logging with syslog
PDF
DevOps in PHP environment
PDF
Deploying PHP applications with Phing
PDF
Apache Dispatch
PDF
GNU Compiler Collection - August 2005
PDF
zebra & openconfigd Introduction
PPT
Composer - Package Management for PHP. Silver Bullet?
PPTX
PSR-7 - Middleware - Zend Expressive
PDF
Writing multi-language documentation using Sphinx
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
Golang execution modes
Writing an Ostinato Protocol Builder [FOSDEM 2021]
Phing - A PHP Build Tool (An Introduction)
[COSCUP 2020] How to use llvm frontend library-libtooling
Fluentd Hacking Guide at RubyKaigi 2014
Vagrant move over, here is Docker
LSA2 - 03 Http apache nginx
Putting Phing to Work for You
Phing
Laravel 4 package development
Centralized Logging with syslog
DevOps in PHP environment
Deploying PHP applications with Phing
Apache Dispatch
GNU Compiler Collection - August 2005
zebra & openconfigd Introduction
Composer - Package Management for PHP. Silver Bullet?
PSR-7 - Middleware - Zend Expressive
Writing multi-language documentation using Sphinx
Ad

Similar to OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build Your Own Cartridge V2 by Jhon Honce (20)

ODP
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
ODP
OpenShift Anywhere given at Infrastructure.Next Talk at #Scale12X
PDF
Open shift
PPTX
Server deployment
ODP
Build a PaaS with OpenShift Origin
PDF
OpenShift Overview
ODP
OpenShift PaaS Anywhere (Infrastructure.Next Ghent 2014-02-24) Diane Mueller
PPT
OpenShift Origin: Build a PaaS Just Like Red Hats
PDF
Openshift Enterprise
PPTX
Accelerating Application Delivery with OpenShift
PDF
Ose mod march11
ODP
Putting The PaaS in OpenStack with Diane Mueller @RedHat
PDF
Build Your Own PaaS, Just like Red Hat's OpenShift from LinuxCon 2013 New Orl...
PDF
Openshift cheat rhce_r3v1 rhce
PPTX
Free Mongo on OpenShift
PDF
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...
ODP
OpenShift Origin Internals
ODP
OpenShift Enterprise
PDF
Break down IT productivity barriers
PDF
The Path to a Programmable Network
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
OpenShift Anywhere given at Infrastructure.Next Talk at #Scale12X
Open shift
Server deployment
Build a PaaS with OpenShift Origin
OpenShift Overview
OpenShift PaaS Anywhere (Infrastructure.Next Ghent 2014-02-24) Diane Mueller
OpenShift Origin: Build a PaaS Just Like Red Hats
Openshift Enterprise
Accelerating Application Delivery with OpenShift
Ose mod march11
Putting The PaaS in OpenStack with Diane Mueller @RedHat
Build Your Own PaaS, Just like Red Hat's OpenShift from LinuxCon 2013 New Orl...
Openshift cheat rhce_r3v1 rhce
Free Mongo on OpenShift
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...
OpenShift Origin Internals
OpenShift Enterprise
Break down IT productivity barriers
The Path to a Programmable Network
Ad

More from OpenShift Origin (20)

ODP
From Zero to Cloud: Revolutionize your Application Life Cycle with OpenShift ...
ODP
DevOps, PaaS and the Modern Enterprise CloudExpo Europe presentation by Diane...
ODP
5 ways to install @OpenShift in 5 minutes (Lightening Talk given at #DevConfC...
ODP
Deploying & Scaling OpenShift on OpenStack using Heat - OpenStack Seattle Mee...
PDF
Human Face of Cloud Computing Cyber Summit 2013 Diane Mueller Red Hat OpenShi...
PDF
LatinoWare 2013 An OpenSource Blueprint for Cloud presented by Diane Mueller,...
PDF
Putting Drupal in the Cloud with Red Hat's OpenShift PaaS #DrupalCon/Prague
PDF
OpenShift PaaS Overviewi by Marek Jelen 03-2013 CodeMotion Roma
PDF
OpenShift Overview Presentation by Marek Jelen for Zurich Geeks Event
PDF
Bringing Some Spatial Love to your Application with OpenShift - Mongo Berlin ...
PDF
Social IRC bots in the Cloud with OpenShift - Mongo London presentation by Ma...
PDF
LinuxCon 2013 Steven Dake on Using Heat for autoscaling OpenShift on Openstack
PDF
Building Domain-specific PaaS with OpenShift Origin: The TRESOR Healthcare P...
PDF
How to Launch a Public PaaS with OpenSource: The GetUpCloud & OpenShift Orgin...
PDF
OpenShift Origin Community Day (Boston) Welcome & Resources by Diane Mueller
PDF
Putting Private Clouds to Work with PaaS Interop 2013 Vegas Diane Mueller
ODP
Welcome to the @OpenShift Origin Community by Diane Mueller @pythondj @redhat
ODP
OpenShift & SELinux with Dan Walsh @rhatdan
ODP
DevOps @ OpenShift Online
ODP
Introduction to OpenShift Origin- Private, Public and Community
From Zero to Cloud: Revolutionize your Application Life Cycle with OpenShift ...
DevOps, PaaS and the Modern Enterprise CloudExpo Europe presentation by Diane...
5 ways to install @OpenShift in 5 minutes (Lightening Talk given at #DevConfC...
Deploying & Scaling OpenShift on OpenStack using Heat - OpenStack Seattle Mee...
Human Face of Cloud Computing Cyber Summit 2013 Diane Mueller Red Hat OpenShi...
LatinoWare 2013 An OpenSource Blueprint for Cloud presented by Diane Mueller,...
Putting Drupal in the Cloud with Red Hat's OpenShift PaaS #DrupalCon/Prague
OpenShift PaaS Overviewi by Marek Jelen 03-2013 CodeMotion Roma
OpenShift Overview Presentation by Marek Jelen for Zurich Geeks Event
Bringing Some Spatial Love to your Application with OpenShift - Mongo Berlin ...
Social IRC bots in the Cloud with OpenShift - Mongo London presentation by Ma...
LinuxCon 2013 Steven Dake on Using Heat for autoscaling OpenShift on Openstack
Building Domain-specific PaaS with OpenShift Origin: The TRESOR Healthcare P...
How to Launch a Public PaaS with OpenSource: The GetUpCloud & OpenShift Orgin...
OpenShift Origin Community Day (Boston) Welcome & Resources by Diane Mueller
Putting Private Clouds to Work with PaaS Interop 2013 Vegas Diane Mueller
Welcome to the @OpenShift Origin Community by Diane Mueller @pythondj @redhat
OpenShift & SELinux with Dan Walsh @rhatdan
DevOps @ OpenShift Online
Introduction to OpenShift Origin- Private, Public and Community

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
cuic standard and advanced reporting.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Big Data Technologies - Introduction.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Approach and Philosophy of On baking technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25 Week I
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
cuic standard and advanced reporting.pdf
Machine learning based COVID-19 study performance prediction
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Dropbox Q2 2025 Financial Results & Investor Presentation
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation_ Review paper, used for researhc scholars
Big Data Technologies - Introduction.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Approach and Philosophy of On baking technology
The AUB Centre for AI in Media Proposal.docx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build Your Own Cartridge V2 by Jhon Honce

  • 1. Writing Cartridges for OpenShift Jhon Honce Pr Software Engineer, Red Hat Inc OpenShift Origin Community Day (Boston) June 13, 2013 http://openshift.github.io
  • 2. The OpenShift Ecosystem: GUI/CLI, Broker, Node GUI rhc (CLI) Broker Node (Cartridges) REST API ssh|git MCollective snapshot.tgz gitrepository
  • 3. Where does my code fit? ● Application – application developer ● Gears – PaaS developer ● Cartridges – Cartridge authors ● Web Frameworks, Databases, Daemons ● Encapsulates some piece software for use within the PaaS
  • 4. 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 the system or included in your cartridge
  • 5. Minimal Cartridge – identify cartridge +- bin | +- setup | +- control +- env +- metadata | +- manifest.yml ● Assumes packaged software already installed on system ● Most cartridges will have more files ● manifest.yml Name: dog Cartridge-Short-Name: DOG . : Version: ‘1.0’ Cartridge-Version: 0.0.1 Cartridge-Vendor: honce
  • 6. Minimal Cartridge – required files +- bin | +- setup | +- control +- env +- metadata | +- manifest.yml ● Assumes packaged software already installed on system ● Most cartridges will have more files ● manifest.yml Name: dog Cartridge-Short-Name: DOG . : Version: ‘1.0’ Cartridge-Version: 0.0.1 Cartridge-Vendor: honce
  • 7. Minimal Cartridge +- bin | +- setup | +- control +- env +- metadata | +- manifest.yml ● Assumes packaged software already installed on system ● Most cartridges will have more files ● manifest.yml Name: dog Cartridge-Short-Name: DOG . : Version: ‘1.0’ Cartridge-Version: 0.0.1 Cartridge-Vendor: honce
  • 8. My Cartridge needs to be seen! +- bin | +- … | +- control +… ● control Arguments ● start ● stop ● manifest.yml . : Endpoints: - Private-IP-Name: IP Private-Port-Name: PORT Private-Port: 8080 Public-Port-Name: PROXY_PORT Mappings: - Frontend: "" Backend: "" ● Environment Variables OPENSHIFT_<SHORT_NAME>_IP OPENSHIFT_<SHORT_NAME>_PORT OPENSHIFT_…_PROXY_PORT
  • 9. My Cartridge needs to be invoked +- bin | +- … | +- control +… ● Basic control arguments ● start ● stop ● manifest.yml . : Endpoints: - Private-IP-Name: IP Private-Port-Name: PORT Private-Port: 8080 Public-Port-Name: PROXY_PORT Mappings: - Frontend: "" Backend: ""
  • 10. My Cartridge needs to be seen! +- bin | +- … | +- control +… ● Basic control arguments ● start ● stop ● manifest.yml . : Endpoints: - Private-IP-Name: IP Private-Port-Name: PORT Private-Port: 8080 Public-Port-Name: PROXY_PORT Mappings: - Frontend: "" Backend: ""
  • 11. Tip: control script can be trivial . : case “$1” in start) /usr/sbin/httpd -C "Include $OPENSHIFT_DOG_CONF_DIR/*.conf" -f $HTTPD_CFG_FILE -k start ;; stop) … -k stop ;; restart) … -k restart ;; esac
  • 12. 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 script echo OPENSHIFT_MYSQL_DB_HOST=$OPENSHIFT_GEAR_DNS echo OPENSHIFT_MYSQL_DB_PORT=$OPENSHIFT_MYSQL_DB_PROXY_PORT echo OPENSHIFT_MYSQL_DB_URL=”mysql://…/”
  • 13. 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 script echo OPENSHIFT_MYSQL_DB_HOST=$OPENSHIFT_GEAR_DNS echo OPENSHIFT_MYSQL_DB_PORT=$OPENSHIFT_MYSQL_DB_PROXY_PORT echo OPENSHIFT_MYSQL_DB_URL=”mysql://…/”
  • 14. My Cartridge needs needs to be listening ● Pub/Sub Protocol ● The Type: element determines both the message format and whether the subscribe hook may be implemented in the Platform ● 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
  • 15. Let the Platform the cartridge can use a database ● Pub/Sub Protocol ● The Type: element determines both the message format and whether the subscribe hook may be implemented in the Platform ● 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
  • 16. Let the Platform the cartridge can use a database ● Pub/Sub Protocol ● The Type: element determines both the message format and whether the subscribe hook may be implemented in the Platform ● 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
  • 17. My Cartridge needs to be listening for databases ● Pub/Sub Protocol ● The Type: element determines both the message format and whether the subscribe hook may be implemented in the Platform ● 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
  • 18. My Cartridge needs to be listening for databases ● Pub/Sub Protocol ● The Type: element determines both the message format and whether the subscribe hook may be implemented in the Platform ● 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
  • 19. Customize Work Flows ● Cartridge Authors ● Implement additional control actions ● Provide optional scrips ● Application Developers ● .openshift/action_hooks ● .openshift/markers ● git pushed from developers repository
  • 20. For Language Frameworks: A sample application ● template directory ● Checked in as the gear's initial git repository ● A “complete” application demonstrating that your cartridge 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
  • 21. Environment Variables The Node/Application/Gear/Cartridge all have shared environment 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
  • 22. 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 you are packaging ● System tracks them and builds the correct process environment for you
  • 23. 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
  • 24. 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 18 Online – RHEL 6
  • 25. Tip: Examples – Online Cartridges ● http://tinyurl.com/online-cartridges ● JBoss EWS: multiple versions of packaged software and support for multiple java versions ● MySQL: pub/sub database connections ● PHP My Admin: one cartridge dependent on another
  • 26. 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
  • 27. ERB File Rendering ● Unified method of doing value substitutions in configuration files ● httpd.conf, php.ini, etc ● metadata/managed_files.yml ● processed_templates: - '**/*.erb' ● All environment variables available ● No code can be executed
  • 28. Title here Text with no bullets ● Bullets layer one ● Bullets layer two ● Bullets layer three
  • 29. 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
  • 30. For more information: http://openshift.github.io Follow us on twitter: @openshift Join us on irc (freenode): openshift