Este contenido no está disponible en el idioma seleccionado.
8.6.3. Configuring a Routing Daemon or Listener
Prerequisites:
The following procedure assumes that you have already set up nginx, Nginx Plus®, or LTM® as a routing back end as described in Section 8.6.1, “Selecting an External Routing Solution”.
Procedure 8.19. To Install and Configure the Sample Routing Daemon:
- The sample routing daemon is provided by the rubygem-openshift-origin-routing-daemon package. The host you are installing the routing daemon on must have the
Red Hat OpenShift Enterprise 2.2 Infrastructurechannel enabled to access the package. See Section 7.1, “Configuring Broker Host Entitlements” for more information.For nginx or Nginx Plus® usage, because the routing daemon directly manages the nginx configuration files, you must install the package on the same host where nginx or Nginx Plus® is running. Nginx Plus® offers features such as a REST API and clustering, but the current version of the routing daemon must still be run on the same host.For LTM® usage, you must install the package on a Red Hat Enterprise Linux 6 host that is separate from the host where LTM® is running. This is because the daemon manages LTM® using a SOAP or REST interface.Install the rubygem-openshift-origin-routing-daemon package on the appropriate host:yum install rubygem-openshift-origin-routing-daemon
# yum install rubygem-openshift-origin-routing-daemonCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Edit the
/etc/openshift/routing-daemon.conffile and set theACTIVEMQ_*parameters to the appropriate host address, credentials, and ActiveMQ topic or queue destination:ACTIVEMQ_HOST=broker.example.com ACTIVEMQ_USER=routinginfo ACTIVEMQ_PASSWORD=routinginfopasswd ACTIVEMQ_PORT=61613 ACTIVEMQ_DESTINATION=/topic/routinginfo
ACTIVEMQ_HOST=broker.example.com ACTIVEMQ_USER=routinginfo ACTIVEMQ_PASSWORD=routinginfopasswd ACTIVEMQ_PORT=61613 ACTIVEMQ_DESTINATION=/topic/routinginfoCopy to Clipboard Copied! Toggle word wrap Toggle overflow In OpenShift Enterprise 2.1.2 and later, you can set theACTIVEMQ_HOSTparameter as a comma-separated list of host:port pairs if you are using multiple ActiveMQ brokers:ACTIVEMQ_HOST='192.168.59.163:61613,192.168.59.147:61613'
ACTIVEMQ_HOST='192.168.59.163:61613,192.168.59.147:61613'Copy to Clipboard Copied! Toggle word wrap Toggle overflow - If you optionally enabled SSL connections per ActiveMQ host in the routing plug-in, set the
plugin.activemq*parameters in this file to the same values used in the/opt/rh/ruby193/root/etc/mcollective/client.cfgfile on the broker:Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you have multiple pools, ensure thatplugin.activemq.pool.sizeis set appropriately and create unique blocks for each pool:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The files set in the*ssl.ca,*ssl.key, and*ssl.certparameters must be copied from the ActiveMQ broker or brokers and placed locally for the routing daemon to use.Note that while setting theplugin.activemq*parameters overrides theACTIVEMQ_HOSTandACTIVEMQ_PORTparameters in this file, theACTIVEMQ_USERNAMEandACTIVEMQ_PASSWORDparameters in this file are still used by the routing daemon and must be set. - Set the
CLOUD_DOMAINparameter to the domain you are using:CLOUD_DOMAIN=example.com
CLOUD_DOMAIN=example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow - To use a different prefix in URLs for high-availability applications, you can modify the
HA_DNS_PREFIXparameter:HA_DNS_PREFIX="ha-"
HA_DNS_PREFIX="ha-"Copy to Clipboard Copied! Toggle word wrap Toggle overflow This parameter and theHA_DNS_PREFIXparameter in the/etc/openshift/broker.conffile, covered in Section 8.6.4, “Enabling Support for High-Availability Applications” , must be set to the same value. - If you are using nginx or Nginx Plus®, set the
LOAD_BALANCERparameter to thenginxmodule:LOAD_BALANCER=nginx
LOAD_BALANCER=nginxCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you are using LTM®, set theLOAD_BALANCERparameter to thef5module:LOAD_BALANCER=f5
LOAD_BALANCER=f5Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that only oneLOAD_BALANCERline is uncommented and enabled in the file. - If you are using nginx or Nginx Plus®, set the appropriate values for the following
nginxmodule parameters if they differ from the defaults:NGINX_CONFDIR=/opt/rh/nginx16/root/etc/nginx/conf.d NGINX_SERVICE=nginx16-nginx
NGINX_CONFDIR=/opt/rh/nginx16/root/etc/nginx/conf.d NGINX_SERVICE=nginx16-nginxCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you are using Nginx Plus®, you can uncomment and set the following parameters to enable health checking. This enables active health checking and takes servers out of the upstream pool without having a client request initiate the check.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - If you are using LTM®, set the appropriate values for the following parameters to match your LTM® configuration:
BIGIP_HOST=127.0.0.1 BIGIP_USERNAME=admin BIGIP_PASSWORD=passwd BIGIP_SSHKEY=/etc/openshift/bigip.key
BIGIP_HOST=127.0.0.1 BIGIP_USERNAME=admin BIGIP_PASSWORD=passwd BIGIP_SSHKEY=/etc/openshift/bigip.keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the following parameters to match the LTM® virtual server names you created:VIRTUAL_SERVER=ose-vserver VIRTUAL_HTTPS_SERVER=https-ose-vserver
VIRTUAL_SERVER=ose-vserver VIRTUAL_HTTPS_SERVER=https-ose-vserverCopy to Clipboard Copied! Toggle word wrap Toggle overflow Also set theMONITOR_NAMEparameter to match your LTM® configuration:MONITOR_NAME=monitor_name
MONITOR_NAME=monitor_nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow For thelbaasmodule, set the appropriate values for the following parameters to match your LBaaS configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - By default, new pools are created and named with the form
pool_ose_{appname}_{namespace}_80. You can optionally override this defaults by setting appropriate value for thePOOL_NAMEparameter:POOL_NAME=pool_ose_%a_%n_80
POOL_NAME=pool_ose_%a_%n_80Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you change this value, set it to contain the following format so each application gets its own uniquely named pool:%ais expanded to the name of the application.%nis expanded to the application's namespace (domain).
- The BIG-IP LTM back end can add an existing monitor to newly created pools. The following settings control how these monitors are created:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set theMONITOR_NAMEparameter to the name of the monitor to use, and set theMONITOR_PATHparameter to the path name to use for the monitor. Alternatively, leave either parameter unspecified to disable the monitor functionality.As with thePOOL_NAMEandROUTE_NAMEparameters, theMONITOR_NAMEandMONITOR_PATHparameters both can contain%aand%nformats, which are expanded the same way. Unlike thePOOL_NAMEandROUTE_NAMEparameters, however, you may or may not want to reuse the same monitor for different applications. The routing daemon automatically creates a new monitor when the format used from theMONITOR_NAMEparameter expands a string that does not match the name of any existing monitor.Set theMONITOR_UP_CODEparameter to the code that indicates that a pool member is up, or leave it unspecified to use the default value of1.MONITOR_TYPEspecifies the type of probe that the external load-balancer should use to check the health status of applications. The only other recognized value forMONITOR_TYPEishttps-ecv, which defines the protocol to be HTTPS. All other values forMONITOR_TYPEtranslate to HTTP.Note that ECV stands for “extended content verification", referring to the fact that the monitor makes an HTTP request and looks at the reply to verify that it is the expected response (meaning the application server is responding), as opposed to merely pinging the server to ensure it is returning an ICMP ping reply (meaning the operating system is responding).Set theMONITOR_INTERVALparameter to the interval at which the monitor sends requests, or leave it unspecified to use the default value of10.Set theMONITOR_TIMEOUTparameter to the monitor's timeout for its requests, or leave it unset to use the default value of5.It is expected that for each pool member, the routing solution sends aGETrequest to the resource identified on that host by the value of theMONITOR_PATHparameter for the associated monitor, and that the host responds with the value of theMONITOR_UP_CODEparameter if the host is up or some other response if the host is not up. - You can change the port that nginx or Nginx Plus® listens on for HTTP or HTTPS, if required, by setting the following parameters:
SSL_PORT=443 HTTP_PORT=80
SSL_PORT=443 HTTP_PORT=80Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Nginx Plus®, setting the above parameters is all that is required. For nginx 1.6 (from Red Hat Software Collections), however, you must also modify the/opt/rh/nginx16/root/etc/nginx/nginx.conffile to listen on different ports. For example for HTTP, change80on the following line to another port:listen 80;
listen 80;Copy to Clipboard Copied! Toggle word wrap Toggle overflow In both cases (nginx 1.6 and Nginx Plus®), ensure theSSL_PORTandHTTP_PORTparameters are set to the ports you intend nginx or Nginx Plus® to listen to, and ensure your host firewall configuration allows ingress traffic on these ports. - Start the routing daemon:
chkconfig openshift-routing-daemon on service openshift-routing-daemon start
# chkconfig openshift-routing-daemon on # service openshift-routing-daemon startCopy to Clipboard Copied! Toggle word wrap Toggle overflow
If you are not using the sample routing daemon, you can develop your own listener to listen to the event notifications published on ActiveMQ by the sample routing plug-in. The plug-in creates notification messages for the following events:
| Event | Message Format | Additional Details |
|---|---|---|
| Application created |
:action => :create_application,
:app_name => app.name,
:namespace => app.domain.namespace,
:scalable => app.scalable,
:ha => app.ha,
| |
| Application deleted |
:action => :delete_application,
:app_name => app.name,
:namespace => app.domain.namespace
:scalable => app.scalable,
:ha => app.ha,
| |
| Public endpoint created |
:action => :add_public_endpoint,
:app_name => app.name,
:namespace => app.domain.namespace,
:gear_id => gear._id.to_s,
:public_port_name => endpoint_name,
:public_address => public_ip,
:public_port => public_port.to_i,
:protocols => protocols,
:types => types,
:mappings => mappings
|
Values for the
protocols variable include:
Values for the
types variable include:
These variables depend on values set in the cartridge manifest.
|
| Public endpoint deleted |
:action => :remove_public_endpoint,
:app_name => app.name,
:namespace => app.domain.namespace,
:gear_id => gear._id.to_s,
:public_address => public_ip,
:public_port => public_port.to_i
| |
| SSL certificate added |
:action => :add_ssl,
:app_name => app.name,
:namespace => app.domain.namespace,
:alias => fqdn,
:ssl => ssl_cert,
:private_key => pvt_key,
:pass_phrase => passphrase
| |
| SSL certificate removed |
:action => :remove_ssl,
:app_name => app.name,
:namespace => app.domain.namespace,
:alias => fqdn
| |
| Alias added |
:action => :add_alias,
:app_name => app.name,
:namespace => app.domain.namespace,
:alias => alias_str
| |
| Alias removed |
:action => :remove_alias,
:app_name => app.name,
:namespace => app.domain.namespace,
:alias => alias_str
|
Note
add_gear and delete_gear actions have been deprecated. Use add_public_endpoint for add_gear and remove_public_endpoint for delete_gear instead.
Routing Listener Guidelines
- Listen to the ActiveMQ topic
routinginfo. Verify that the user credentials match those configured in the/etc/openshift/plugins.d/openshift-origin-routing-activemq.conffile of the sample routing plug-in. - For each gear event, reload the routing table of the router.
- Use the
protocolsvalue provided with theadd_public_endpointaction to tailor your routing methods. - Use the
typesvalue to identify the type of endpoint. - Use the
mappingsvalue to identify URL routes. Routes that are not root may require source IP or SSL certificate verifications. A common use case involves administrative consoles such as phpMyAdmin.
- Look for actions involving SSL certificates, such as
add_sslandremove_ssl, and decide whether to configure the router accordingly for incoming requests. - Look for actions involving aliases, such as
add_aliasandremove_alias. Aliases must always be accommodated for during the application's life cycle.
Note
add_public_endpoint and remove_public_endpoint actions do not correspond to the actual addition and removal of gears, but rather to the exposure and concealment of ports. One gear added to an application may result in several exposed ports, which will all result in respective add_public_endpoint notifications at the router level.
Example 8.18. Simple Routing Listener
listener.rb script file is an example model for a simple routing listener. This Ruby script uses Nginx as the external routing solution, and the pseudo code provided is an example only. The example handles the following tasks:
- Look for messages with an
add_public_endpointaction and aload_balancertype, then edit the router configuration file for the application. - Look for messages with a
remove_public_endpointaction and aload_balancertype, then edit the router configuration file for the application. - Look for messages with a
delete_applicationaction and remove the router configuration file for the application.