Bug 1154167 - Document port-forwarding to other gears (as part of your scaled application).
Summary: Document port-forwarding to other gears (as part of your scaled application).
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Documentation
Version: 2.x
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Timothy
QA Contact: Bilhar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-17 17:46 UTC by Eric Rich
Modified: 2018-12-09 18:53 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Build Name: 22503, User Guide-null-1.0 Build Date: 29-09-2014 11:16:34 Topic ID: 26309-621713 [Latest]
Last Closed: 2014-11-07 00:36:05 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Eric Rich 2014-10-17 17:46:49 UTC
Title: Application Port Forwarding

Describe the issue:

If you want to enable port-forwarding to a gear, the default examples shown in the current documentation only show you how to get forwarded to the Head gear, and any attached Databased. 

However if you run:

   # rhc port-forward eap -g 54401bb67f116a704e000169

You can get forwarded to any gear in your environment. 


Suggestions for improvement:

Explain / update the documentation to explain this -g option. 

Additional information:

Currently Portforarding for a gear does the following: 

# Collect locally bound ports
declare -A $(/usr/sbin/lsof -iTCP -sTCP:LISTEN -P 2> /dev/null | /bin/awk '/LISTEN/{ print "local_bindings["$9"]="$1 }')

# Extract database ports out of the environment
declare -A remote_bindings

for host_var in $(env | grep _DB_HOST | awk -F '=' '{print $1}'); do
    db_name=$(echo $host_var |sed -e 's/.*OPENSHIFT_\(.*\)_DB_HOST/\1/' |tr '[A-Z]' '[a-z]')
    port_var=$(echo $host_var |sed 's/_DB_HOST/_DB_PORT/')
    port_val=$(echo ${!port_var})
    host_val=$(echo ${!host_var})
    db_binding="${host_val}:${port_val}"
    remote_bindings[$db_binding]=${db_name}
done
    
# Merge the database ports into the local binding list; if the databases are
# local, the keys will simply be overwritten in the array
if ! $exclude_remote ; then
  for remote_binding in "${!remote_bindings[@]}"; do
    local_bindings[$remote_binding]="${remote_bindings[$remote_binding]}"
  done
fi

In short:

- you get a listing of ports seen by the gear
- Find out if you have a database mapping
  - Determine if its scaled
- Merge duplicates
- Report on the ports for rhc to setup mappings.

Comment 1 Eric Rich 2014-10-17 17:47:24 UTC
https://blog.openshift.com/getting-started-with-port-forwarding-on-openshift/ should also be updated as it coves the same content.

Comment 5 Timothy 2014-11-07 00:36:05 UTC
Already documented.

Closing.


Note You need to log in before you can comment on or make changes to this bug.