||
Skip to end of metadata
Go to start of metadata

In PPaaS, the backend members in the instances, such as in a Virtual Machine (VM) setup the VM instances and in a Kubernetes setup the Docker instances, are fronted by a Load Balancer. The proxyPort property is used to define the port of the Load Balancer. When the Load Balancer receives traffic, it will route the traffic to the members (worker nodes) in the respective clusters, based on their resource availability.

PPaaS uses a Proxy Service for Kubernetes as there are different service port types with different port ranges. Therefore, when using Kubernetes, you need to set the proxyPort to zero in the Cartridge definition and define the Kubernetes proxy service port range as 30000 - 32767 using the portRange property in the Kubernetes cluster definition.

Follow the instructions below to access the WSO2 service:

The URL to access a service depends on the port mapping (VM) and port range (Docker) that you defined in the cartridge definition and the Kubernetes cluster definition respectively.

 Click here for more information...

When creating the dependent artifacts that are needed to deploy an application, you need to define port mapping in the cartridge definition JSON for each port that is being used with the WSO2 product cartridge. 
The following examples illustrate how to set unique proxy ports for each port that is used with the cartridge.

Example for defining proxy ports in the cartridge definition
 "portMapping": [
        {
            "name": "mgt-http",
            "protocol": "http",
            "port": 9763,
            "proxyPort": 80
        },
        {
            "name": "mgt-https",
            "protocol": "https",
            "port": 9443,
            "proxyPort": 443
        }
    ],
Example for defining proxy ports in the Cartridge definition
 "portMapping": [
        {
            "name": "mgt-http",
            "protocol": "http",
            "port": 9763,
            "proxyPort": 0,
            "kubernetesPortType": "NodePort"
        },
        {
            "name": "mgt-https",
            "protocol": "https",
            "port": 9443,
            "proxyPort": 0,
            "kubernetesPortType": "NodePort"
        }
    ],
  • kubernetesPortType - The Kubernetes port type to which the cartridge is mapped.

    The following can be assigned for the Kubernetes port type:

    • NodePort -  If this value is used, it will create a service which can be accessed from the outside with port range of 30,000 to 32,767.
    • ClusterIP - If this value is used, the service that gets created will not be exposed to the outside. This is useful if you don't want to expose a service to outside, but need to maintain internal communication within Docker containers.

    Access URLs are generated only for the NodePort service type.

     

Defining the portRange in the Kubernetes cluster definition
 "portRange": {
        "upper": "32767",
        "lower": "30000"
    },
  1. Identify the Load Balancer IP and the hostname of the each of the clusters that are available in the deployed application.
    For more information, see Getting the Runtime Topology of an Application.

  2. Map the cluster hostname with one of the Load Balancer IPs.
    Each Load Balancer IP refers to the IP of a node. 

    1. Open the /etc/hosts/ file.
      Example:
      If you are using Vim, which is a text editor, you can open the file in the terminal as follows:

      vim /etc/hosts/
    2. Map all the hostnames against the available LB IPs in the /etc/hosts/ file and save the file.
      <LB_IP> <HOSTNAME> 
      Example:

      172.17.8.103 wso2as-521-application.mgt.as.wso2.org

      Each LB IP can have more than one hostname mappings. However, these mappings need to be defined separately in the /etc/hosts/ file.

  3. Optionally, add domain mapping if required.

     Click here for instructions...

    You can add domain mappings using the CLI tool or REST API as shown below:

    As the signup process takes place automatically when a single tenant application is deployed, domain mapping can be added straight after the application is deployed. However, if domain mapping is being added to a multi-tenant application, after the application is deployed, ensure to first carryout the application sign up process before adding the domain mappings.

    Adding domain mappings via the CLI

    Overview
    CLI commandadd-domain-mapping
    DescriptionAdd domain mappings for the subscribed cartridge.
    Command format
    add-domain-mappings <APPLICATION-ID> -p <JSON_FILE_PATH>

    The path to the JSON file that defines the domain mapping needs to be defined as the  <JSON_FILE_PATH>  value.

    Parameter definition
    Short optionLong optionDescriptionRequiredExample value
    N/AN/AID of the application.Yes

    single-cartridge-app

    -p

    --resource-path

    Folder path where the JSON file that defines the domain mappings is stored.Yes
    <ANY_PATH>/domainmappings.json
    Example

    Add the domain mappings defined in the <TEST>/domainmappings.json file to the application with the ID: wso2am-190-application

    add-domain-mappings wso2am-190-application -p <TEST_PATH>/domainmappings.json
    Sample output
     

    Adding domain mappings via the REST API

    Overview
    DescriptionAdd one or more domain mappings for a cluster.
    Resource Path

    /applications/{applicationId}/domainMappings

    HTTP MethodPOST
    Request/Response Format

    application/json

    Command format
    curl -X POST -H "Content-Type: application/json" -d @'<JSON_PAYLOAD>' -k -v -u <USERNAME>:<PASSWORD> https://<PRIVATE_PAAS_HOST>:<PRIVATE_PAAS_HTTPS_PORT>/api/applications/{applicationId}/domainMappings
    • The path to the JSON file that defines the application needs to be defined as the <JSON_PAYLOAD> value.
    • By default, <USERNAME>:<PASSWORD> is admin:admin.
    • By default, <PRIVATE_PAAS_HOST> is localhost. However, if you are using a public IP, the respective IP address or domain needs to be specified.
    • By default, <PRIVATE_PAAS_HTTPS_PORT> has been set to 9443. However, if the port offset has been incremented by n, the default port value needs to be incremented by n.
    Example

    Add the domain mappings in the <TEST_PATH>/domainmappings.json file and add this domain mapping to the application with the ID: wso2am-190-application. 

    cd <TEST_PATH>
    curl -X POST -H "Content-Type: application/json" -d @'domain-mappings.json' -k -v -u admin:admin https://localhost:9443/api/applications/wso2am-190-application/domainMappings
    Sample output
     

    You will come across the following HTTP status codes while adding an application:

    HTTP status code

    200, 500

    See the descriptions of the HTTP status codes here.

    Location header URL

    https://<STRATOS_HOST>:<STRATOS_HTTPS_PORT>/api/applications/<APPLICATION_ID>/domainMappings

     


    Sample domain mapping JSON

    {
      "domainMappings": [
        {
          "cartridgeAlias": "tomcat",
          "domainName": "abc.com",
          "contextPath": "/abc/app"
        }
      ]
    }

    For more information, see Working with Domain Mappings.

  4. Use the following URL format to access the WSO2 service (e.g., the ESB service):

    http://<INSTANCE_HOSTNAME>:<LB_PROXY_PORT>/<CONTEXT_PATH>
    • <INSTANCE_HOSTNAME> The hostname of the cluster.
    • <LB_PROXY_PORT> - The LB proxy port to which the port was mapped to as explained in Prerequisites.


    Example:

     http://wso2as-521-application.mgt.as.wso2.org:80/index.php
    http://<INSTANCE_HOSTNAME>:<PROXY_SERVICE_PORT>/<CONTEXT_PATH>
    • <INSTANCE_HOSTNAME> - The hostname of the cluster.

    • <PROXY_SERVICE_PORT> - When using Kubernetes, you need to define the Kubernetes proxy service port range as 30000 - 32767 in the Kubernetes cluster definition, as there are different service port types with different port ranges in Kubernetes. Therefore, when using Kubernetes, the first proxy service that gets created will be assigned to port 30000, and the subsequent proxy services that get created will be assigned port values in order incrementally. Port ranges are not applicable when using PPaaS on Virtual Machines.

    Example:

    http://wso2as-521-application.mgt.as.wso2.org:30000/index.php

    Currently, it is not possible to query auto generated Kubernetes proxy service ports via the Stratos API. However, they can be found on the PPaaS server log.

  • No labels