OpenShift Cartridges and Ports

I’ve been writing an OpenShift cartridge for deploying Tungsten in OpenShift and below are some of my notes on using ports between cartridges

The following ports are available between Cartridges


POP: 106, 109, 110, 995, 1109
IMAP: 143, 220, 993
DNS: 53
SSH: 22
Kerberos: 88, 750, 4444
SMTP: 25, 465, 587
FTP: 21, 990
GIT: 9418
MySQLd: 1186, 3306, 63132-63164
Mongod: 27017
PostgreSQL: 5432
MS SQL: 1433-1434
Oracle: 1521, 2483, 2484 ?????
HTTP/HTTPS: 80, 8008, 8009, 8443
HTTP Cache: 8080, 8118, 8123, 10001-10010
memcache: 11211
jacorb: 3528, 3529
JBoss Debug: 8787
JBoss Management: 4712, 4447, 7600, 9123, 9990, 9999, 18001
AMQP: 5671-5672
PulseAudio: 4713
Flash: 843, 1935
Munin: 4949
Virt Migration: 49152-49216
OCSP: 9080
Other ports: 3128, 5445, 5455, 8255, 8389, 9352, 9353, 9374, 9472 9923, 9926, 9949, 9950, 9996, 9999, 10715, 10716, 10717, 14170, 14171, 14248, 60417

15000 – 35530 (which aren’t externally addressable)

Enabling Inter-Cartridge Communication


Note: the 2 ruby scripts are in

Define a port in manifest.yml

  – Private-IP-Name:   IP
    Private-Port-Name: MESSAGING_PORT
    Private-Port:      5445
    Public-Port-Name:  MESSAGING_PROXY_PORT

When a cart is launched the following variables are available


[51dbb0b84382ec73810000ff-narmitag.rhcloud.com bin]> env|grep MESSAGING
OPENSHIFT_TUNGSTEN_MESSAGING_PROXY_PORT=51191
OPENSHIFT_TUNGSTEN_MESSAGING_PORT=5445                 



To start a server on the local cart – use the local port in this case 5445


ruby port_check.rb 127.7.24.1 5445 Y

Scale the cart to add another one


Connect to the server on the other cart using the proxy port

[51dbb2c25973ca7bc800008b-narmitag.rhcloud.com tungsten]> ruby port_check_client.rb 51dbb0b84382ec73810000ff-narmitag.rhcloud.com 51191
Tue Jul  9 03:35:07 2013
Connected to 127.7.24.1 on 5445
Closing the connection. Bye!

Passing the port and host details to another cartridge at start up.



Add the following to the manifest.yml

Publishes:
  publish-tungsten-messaging:
    Type: “NET_TCP:tungsten-messaging-info”
Subscribes:
  set-tungsten-messaging:
    Type: “NET_TCP:tungsten-messaging-info”

Create the following 2 hooks in ~/hooks  

(Note:Make sure the execute attribute is on for the 2 hook scripts)

set-tungsten-messaging


#!/bin/bash

# Exit on any errors
set -e

source $OPENSHIFT_CARTRIDGE_SDK_BASH

list=
kvargs=$(echo “${@:4}” | tr -d “n” )
for arg in $kvargs; do
    ip=$(echo “$arg” | cut -f 2 -d ‘=’ | tr -d “‘”)
    ip=$(echo “$ip” | sed “s/:/[/g”)
    if [ -z “$list” ]; then
        list=”$ip]”
    else
        list=”$list,$ip]”
    fi
done


echo $list > $OPENSHIFT_TUNGSTEN_DIR/env/OPENSHIFT_TUNGSTEN_MESSAGING


publish-tungsten-messaging
#!/bin/bash

# Start the application httpd instance

# Exit on any errors
set -e

function print_help {
    echo “Usage: $0 app-name namespace uuid”
    echo “Start a running application”

    echo “$0 $@” | logger -p local0.notice -t openshift_origin_httpd_start
    exit 1
}

while getopts ‘d’ OPTION
do
    case $OPTION in
        d) set -x
        ;;
        ?) print_help
        ;;
    esac
done

[ $# -eq 3 ] || print_help

echo ${OPENSHIFT_GEAR_DNS}:${OPENSHIFT_TUNGSTEN_MESSAGING_PROXY_PORT}


Start up first Cart – cartA

[51dbc6c24382ec13550001b3-narmitag.rhcloud.com tungsten]> env | grep MESSAGING
OPENSHIFT_TUNGSTEN_MESSAGING=51dbc6c24382ec13550001b3-narmitag.rhcloud.com[57346]
OPENSHIFT_TUNGSTEN_MESSAGING_PROXY_PORT=57346
OPENSHIFT_TUNGSTEN_MESSAGING_PORT=5445



[51dbc6c24382ec13550001b3-narmitag.rhcloud.com tungsten]> cat env/OPENSHIFT_TUNGSTEN_MESSAGING
51dbc6c24382ec13550001b3-narmitag.rhcloud.com[57346]

2nd cart added – cartB 

output from cartA

[51dbc6c24382ec13550001b3-narmitag.rhcloud.com tungsten]> cat env/OPENSHIFT_TUNGSTEN_MESSAGING
51dbc6c24382ec13550001b3-narmitag.rhcloud.com[57346],51dbc8e0e0b8cd63e8000099-narmitag.rhcloud.com[54581]


output from cartB

[51dbc8e0e0b8cd63e8000099-narmitag.rhcloud.com tungsten]> env | grep MESSAGING
OPENSHIFT_TUNGSTEN_MESSAGING=51dbc6c24382ec13550001b3-narmitag.rhcloud.com[57346],51dbc8e0e0b8cd63e8000099-narmitag.rhcloud.com[54581]
OPENSHIFT_TUNGSTEN_MESSAGING_PROXY_PORT=54581
OPENSHIFT_TUNGSTEN_MESSAGING_PORT=5445



[51dbc8e0e0b8cd63e8000099-narmitag.rhcloud.com tungsten]> cat env/OPENSHIFT_TUNGSTEN_MESSAGING
51dbc6c24382ec13550001b3-narmitag.rhcloud.com[57346],51dbc8e0e0b8cd63e8000099-narmitag.rhcloud.com[54581]











Advertisements
OpenShift Cartridges and Ports

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s