|
| 1 | += Deploy an App with TCP using the Application Manager API |
| 2 | + |
| 3 | +To configure protocols other than HTTP or HTTPS, first set up TCP inbound firewall rules to allow TCP traffic for your private space. You can then use the https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/amc-application-manager/minor/4.0/console/method/%231158/[Application Manager API] to deploy an app using TCP. |
| 4 | + |
| 5 | +To configure firewall rules using TCP, follow the steps in xref:ps-config-fw-rules.adoc#configure-firewall-rules[Configure Firewall Rules] and select TCP. |
| 6 | + |
| 7 | +== Find Available Ports for Your App |
| 8 | + |
| 9 | +The port range for TCP is between 30500 to 32500. To confirm port availability, use the https://anypoint.mulesoft.com/exchange/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/cloudhub-20-api/minor/1.0/console/method/%232327/[CloudHub 2.0 API] that returns a list of available ports. |
| 10 | + |
| 11 | +The following examples show the API request and response when you use it to find available ports: |
| 12 | + |
| 13 | +Request: |
| 14 | + |
| 15 | +[source,json] |
| 16 | +---- |
| 17 | +GET |
| 18 | +https:/anypoint.mulesoft.com/runtimefabric/api/organizations/{organizationId}/privatespaces/{privatespaceId}/ports?available=true&count=10 |
| 19 | +---- |
| 20 | + |
| 21 | +In the request, the `available` parameter enables you to alternate between used and unused ports. |
| 22 | +The `count` parameter lets you specify the number of ports, between 1 and 10. The actual availability of ports limits the end result. |
| 23 | + |
| 24 | +Response: |
| 25 | + |
| 26 | +[source,json] |
| 27 | +---- |
| 28 | +{ |
| 29 | + "ports": [ |
| 30 | + 30500, |
| 31 | + 30501, |
| 32 | + 30502, |
| 33 | + 30503, |
| 34 | + 30504, |
| 35 | + 30511, |
| 36 | + 30512, |
| 37 | + 30513, |
| 38 | + 30514, |
| 39 | + 30515 |
| 40 | + ] |
| 41 | +} |
| 42 | +---- |
| 43 | + |
| 44 | + |
| 45 | +== Deploy an App Using the Application Manager API |
| 46 | + |
| 47 | +In the https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/amc-application-manager/minor/4.0/console/method/%231158/[Application Manager API], use the `tcp` section under `deploymentSettings` to map your TCP port and deploy your app. The mapping uses the external port to expose `portNumber` and the app level-defined port `applicationPortNumber`. You can configure up to 10 ports per application. |
| 48 | + |
| 49 | +The following example shows the request to deploy a new app using a TCP port mapping: |
| 50 | + |
| 51 | +[source,json] |
| 52 | +---- |
| 53 | +POST https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/{organizationId}/environments/{environmentId}/deployments |
| 54 | +
|
| 55 | +{ |
| 56 | + "name": "logs-app-uc01", |
| 57 | + "labels": [ |
| 58 | + "beta" |
| 59 | + ], |
| 60 | + "target": { |
| 61 | + "provider": "MC", |
| 62 | + "targetId": "cfe2157f-438b-4fb8-81fe-13ec89c55545", |
| 63 | + "deploymentSettings": { |
| 64 | + "clustered": false, |
| 65 | + "enforceDeployingReplicasAcrossNodes": false, |
| 66 | +//------------------------------------NEW------------------------------------- |
| 67 | + "tcp": { |
| 68 | + "inbound": { |
| 69 | + "ports": [ |
| 70 | + { |
| 71 | + "portNumber": 30500, |
| 72 | + "applicationPortNumber": 9000 |
| 73 | + }, |
| 74 | + { |
| 75 | + "portNumber": 30501, |
| 76 | + "applicationPortNumber": 9001 |
| 77 | + }, |
| 78 | + { |
| 79 | + "portNumber": 30502, |
| 80 | + "applicationPortNumber": 9002 |
| 81 | + }, |
| 82 | + ] |
| 83 | + } |
| 84 | + }, |
| 85 | +//------------------------------------NEW------------------------------------- |
| 86 | + "jvm": {}, |
| 87 | + "runtimeVersion": "4.4.0:20220523-1", |
| 88 | + "updateStrategy": "rolling", |
| 89 | + "disableAmLogForwarding": false, |
| 90 | + "generateDefaultPublicUrl": true |
| 91 | + }, |
| 92 | + "replicas": 1 |
| 93 | + }, |
| 94 | + "application": { |
| 95 | + "ref": { |
| 96 | + "groupId": "66310c16-bce5-43c4-b978-5945ed2f99c5", |
| 97 | + "artifactId": "app-with-40-schedulers", |
| 98 | + "version": "1.0.5", |
| 99 | + "packaging": "jar" |
| 100 | + }, |
| 101 | + "assets": [], |
| 102 | + "desiredState": "STARTED", |
| 103 | + "configuration": { |
| 104 | + "mule.agent.application.properties.service": { |
| 105 | + "applicationName": "logs-app-uc01", |
| 106 | + "properties": {}, |
| 107 | + "secureProperties": {} |
| 108 | + }, |
| 109 | + "mule.agent.logging.service": { |
| 110 | + "artifactName": "logs-app-uc01", |
| 111 | + "scopeLoggingConfigurations": [] |
| 112 | + } |
| 113 | + }, |
| 114 | + "integrations": { |
| 115 | + "services": { |
| 116 | + "objectStoreV2": { |
| 117 | + "enabled": false |
| 118 | + } |
| 119 | + } |
| 120 | + }, |
| 121 | + "vCores": "0.05" |
| 122 | + } |
| 123 | +} |
| 124 | +---- |
| 125 | + |
| 126 | +Deployments that include unavailable ports fail. Successful deployments use the newly mapped ports, and those ports become unavailable. If the app is deleted, the ports become available again. |
| 127 | + |
| 128 | + |
| 129 | +== Update an App Using the Application Manager API |
| 130 | + |
| 131 | +Using the https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/amc-application-manager/minor/4.0/console/method/%231158/[Application Manager API], change the `tcp` mapping in the `deploymentSettings` section to update the TCP port, and then redeploy the app. |
| 132 | + |
| 133 | +The following example shows a request to update an existing app and its body with a new TCP mapping: |
| 134 | + |
| 135 | +[source,json] |
| 136 | +---- |
| 137 | +PATCH |
| 138 | +https://anypoint.mulesoft.com/amc/adam/api/organizations/{organizationId}/environments/{environmentId}/deployments/{deploymentId} |
| 139 | +
|
| 140 | +{ |
| 141 | + "id": "id", |
| 142 | + "target": { |
| 143 | + "provider": "MC", |
| 144 | + "targetId": "873a9879-cca7-4211-b90e-826e98123929", |
| 145 | + "deploymentSettings": { |
| 146 | + "tcp": { |
| 147 | + "inbound": { |
| 148 | + "ports": [ |
| 149 | + { |
| 150 | + "portNumber": 30507, |
| 151 | + "applicationPortNumber": 9007 |
| 152 | + }, |
| 153 | + { |
| 154 | + "portNumber": 30508, |
| 155 | + "applicationPortNumber": 9008 |
| 156 | + }, |
| 157 | + { |
| 158 | + "portNumber": 30509, |
| 159 | + "applicationPortNumber": 9009 |
| 160 | + } |
| 161 | + ] |
| 162 | + } |
| 163 | + } |
| 164 | + } |
| 165 | + } |
| 166 | + } |
| 167 | +---- |
| 168 | + |
| 169 | +Updates that include unavailable ports fail. Successful deployments occupy the newly mapped ports, and those ports become unavailable. The ports that you replaced with new mappings become available. |
| 170 | + |
| 171 | +== Access Your TCP App |
| 172 | + |
| 173 | +You can access the app using VPN or a transit gateway and within the private space. Because the apps run on worker nodes, they cannot be accessed directly over the internet. The URL to access a TCP app has this structure: `{application-url}.tcp.{environment}.cloudhub.io:{port}` |
| 174 | + |
| 175 | +A sample URL is `mllp-app-2-mpskt5.q8b5lv.usa-e1.tcp.stgx.cloudhub.io:30500`. |
0 commit comments