이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 4. Exposing Services


Most cartridges provide services by binding to ports. Cartridges must declare to which ports they bind, and provide variable names to describe:
  • 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

TCP endpoints are services that are exposed by a cartridge, and are accessible by other cartridges or gears in an application. They may be any protocol which uses TCP, such as http or mysql. These services may also be exposed to application users through mappings. OpenShift Enterprise only creates endpoint ports for scalable applications.
The endpoints can be defined in the Endpoints section of the $cartridge_name/metadata/manifest.yml file.

Example 4.1. Endpoints Entry

Endpoints:
  - Private-IP-Name:   <name of IP variable>
    Private-Port-Name: <name of port variable>
    Private-Port:      <port number>
    Public-Port-Name:  <name of public port variable>
    Protocols:         [<protocol type 1>,<protocol type 2>]
    Mappings:
      - Frontend:      '<frontend path>'
        Backend:       '<backend path>'
        Options:       { ... }
      - <...>
  - <...>
Copy to Clipboard Toggle word wrap
When a cartridge is installed on a gear, it automatically assigns IP addresses to each IP variable name ensuring that assigned addresses can bind to the specified port.
If an endpoint specifies a public port variable, a public port proxy mapping is created using a random external port accessible through the gear's DNS entry.
Endpoint Environment Variables

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>
Copy to Clipboard Toggle word wrap
Endpoint Protocols

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:

Expand
Table 4.1. Endpoint Protocols
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
If the 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.
Endpoint Mappings

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.

Expand
Table 4.2. Endpoint Mapping 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)
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat