Chapter 4. Exposing Services
- The IP addresses provided to the cartridge for binding.
- The local gear ports to which the cartridge services bind.
- (Optional) The public proxy ports that expose local gear ports for communication between related gears in an application, such as the TCP proxy public endpoint.
- (Optional) TCP endpoint mappings that establish a front end for application users.
4.1. TCP Endpoints Copy linkLink copied to clipboard!
http or mysql. These services may also be exposed to application users through mappings. OpenShift Enterprise only creates endpoint ports for scalable applications.
Endpoints section of the $cartridge_name/metadata/manifest.yml file.
Example 4.1. Endpoints Entry
Endpoint values are exposed to cartridge scripts and application code through environment variables. These environment variables are formed from the Cartridge-Short-Name element and from the endpoint variable names specified in the manifest.yml file.
Example 4.2. Environment Variable Format
OPENSHIFT_{Cartridge-Short-Name}_{name of IP variable} => <assigned internal IP>
OPENSHIFT_{Cartridge-Short-Name}_{name of port variable} => <endpoint specified port>
OPENSHIFT_{Cartridge-Short-Name}_{name of public port variable} => <assigned external port>
OPENSHIFT_{Cartridge-Short-Name}_{name of IP variable} => <assigned internal IP>
OPENSHIFT_{Cartridge-Short-Name}_{name of port variable} => <endpoint specified port>
OPENSHIFT_{Cartridge-Short-Name}_{name of public port variable} => <assigned external port>
You can define the protocols for services using the Protocols variable. Protocols takes a comma-separated list of protocol types from the following available options:
| Protocol | Description |
|---|---|
| tcp | TCP |
| http | HTTP |
| https | HTTP Secure (HTTP over SSL/TLS) |
| ws | WebSocket |
| wss | WebSocket Secure (WebSocket over SSL/TLS) |
| tls | SNI Proxy |
| mongodb | MongoDB |
| mysql | MySQL |
| postgresql | PostgreSQL |
Protocols list is not set, the default behavior matches the pre-Protocols behavior. For example, if an endpoint has Mappings, assume HTTP; otherwise, assume TCP. The front-end modules also translate Mappings options. For example, if a Mappings entry has websocket set in its Options, then ws is added to the Protocols list.
If an endpoint specifies Mappings, a front-end httpd route to the cartridge is created for each mapping entry using the provided options. The Frontend key is a front-end path element connected to a back-end URI specified by the Backend key. The Options hash enables additional route configuration options.
| Option | Description |
|---|---|
| websocket | Enable WebSocket on a particular path |
| gone | Mark the path as gone (URI is ignored) |
| forbidden | Mark the path as forbidden (URI is ignored) |
| noproxy | Mark the path as not proxied (URI is ignored) |
| redirect | Use redirection to URI instead of proxy (URI must be a path) |
| file | Ignore request and load file path contained in URI (must be a path) |
| tohttps | Redirect request to HTTPS and use the path contained in the URI (must be a path) |