Skip to content

Instantly share code, notes, and snippets.

@nota-ja
Last active August 18, 2022 15:37
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save nota-ja/ef56ea0584ae2b37d6d3a535efe2d4ee to your computer and use it in GitHub Desktop.
Save nota-ja/ef56ea0584ae2b37d6d3a535efe2d4ee to your computer and use it in GitHub Desktop.
Multiple App Ports Demo on Cloud Foundry

"Multiple App Ports" Demo Operations for HTTP Routing

  1. Cloning demo app
    Using cf-acceptance-tests/assets/multi-port-app
    • git clone https://github.com/cloudfoundry/cf-acceptance-tests.git
  2. Creating routes
    • (confirmation before operations) cf routes
    • cf create-route demo-spc bosh-lite.com --hostname mpg2
    • (confirmation after operations) cf routes
  3. Pushing app with listening multiple ports
    • cf push mpg -c 'go-online --ports=7777,8888,8080'
    • (checking current status)
      • curl -k https://mpg.bosh-lite.com/ports
      • curl -k https://mpg2.bosh-lite.com/ports -> should fail
  4. Updating external ports of app
    • (confirmation before operations) cf curl /v2/apps/$(cf app mpg --guid)
    • cf curl /v2/apps/$(cf app mpg --guid) -X PUT -d '\{"ports": \[7777, 8888, 8080\]\}'
  5. Adding route mappings
    • (confirmation before operations) cf curl /v2/route_mappings
    • (checking <ROUTE-GUID>s) cf curl /v2/routes?q=host:mpg2
    • cf curl /v2/route_mappings -X POST -d "\{\"app_guid\": \"$(cf app mpg --guid)\", \"route_guid\": \"<ROUTE-GUID>\", \"app_port\": 7777\}"
    • (confirmation after operations) cf curl /v2/route_mappings
  6. Validating behavior
    • curl -k https://mpg.bosh-lite.com/ports
    • curl -k https://mpg2.bosh-lite.com/ports

"Multiple App Ports" Demo Operations for TCP Routing

  1. Cloning demo app
    Using cf-acceptance-tests/assets/multi-port-app
    • git clone https://github.com/cloudfoundry/cf-acceptance-tests.git
  2. Creating routes
    • (confirmation before operations) cf routes
    • cf create-route demo-spc tcp.bosh-lite.com --port 1077
    • cf create-route demo-spc tcp.bosh-lite.com --port 1080
    • cf create-route demo-spc tcp.bosh-lite.com --port 1088
    • (confirmation after operations) cf routes
  3. Pushing app with listening multiple ports, not-started, no-routes
    • cf push mpg-tcp -c 'go-online --ports=7777,8888,8080' --no-route --no-start
  4. Updating external ports of app
    • (confirmation before operations) cf curl /v2/apps/$(cf app mpg-tcp --guid)
    • cf curl /v2/apps/$(cf app mpg-tcp --guid) -X PUT -d '\{"ports": \[7777, 8888, 8080\]\}'
  5. Adding route mappings
    • (confirmation before operations) cf curl /v2/route_mappings
    • (checking <ROUTE-GUID>s) cf curl /v2/routes and check each guid for routes tcp.bosh-lite.com:1080, tcp.bosh-lite.com:1077, tcp.bosh-lite.com:1088
    • cf curl /v2/route_mappings -X POST -d "\{\"app_guid\": \"$(cf app mpg-tcp --guid)\", \"route_guid\": \"<ROUTE-GUID>\", \"app_port\": 8080\}"
    • cf curl /v2/route_mappings -X POST -d "\{\"app_guid\": \"$(cf app mpg-tcp --guid)\", \"route_guid\": \"<ROUTE-GUID>\", \"app_port\": 7777\}"
    • cf curl /v2/route_mappings -X POST -d "\{\"app_guid\": \"$(cf app mpg-tcp --guid)\", \"route_guid\": \"<ROUTE-GUID>\", \"app_port\": 8888\}"
    • (confirmation after operations) cf curl /v2/route_mappings
  6. Validating behavior
    • curl -k http://tcp.bosh-lite.com:1077
    • curl -k http://tcp.bosh-lite.com:1080
    • curl -k http://tcp.bosh-lite.com:1088
@shalako
Copy link

shalako commented Jun 1, 2018

The APIs mentioned in this demo are incomplete, experimental, unsupported and may be removed at any time. We abandoned this implementation after determining the design was unnecessarily complex, and haven't prioritized removing or replacing it. Please send use cases for application receiving requests on multiple ports to me, as this helps us prioritize delivering a supported solution.

Thank you.

@ciberkleid
Copy link

Use Case:
For contract testing, it is useful for a "stub runner" application to load multiple stubs and expose them on different ports. In fact, Spring Cloud Pipelines uses this approach for the pipeline job that validates an app against contract stubs. Specifically, Spring Cloud Pipelines deploys a stub runner boot app and opens a separate port per stub:
https://github.com/spring-cloud/spring-cloud-pipelines/blob/master/common/src/main/bash/pipeline-cf.sh#L398
@mgrzejszczak

@marcingrzejszczak
Copy link

Is this feature disabled? I understand that the API is experimental or sth but IMO this feature is absolutely crucial

@shubhaat
Copy link

@ciberklied @mgrzejszczak - are you all actively using this feature currently?

@jim-mclean
Copy link

Is there a way to get HTTP and TCP traffic to the same app without this feature?

@shalako
Copy link

shalako commented Apr 24, 2019

The APIs described in these docs are now supported and stable.

HTTP and TCP traffic can be routed to the same app using this feature.

@ksantos
Copy link

ksantos commented Dec 26, 2019

The APIs mentioned in this demo are incomplete, experimental, unsupported and may be removed at any time. We abandoned this implementation after determining the design was unnecessarily complex, and haven't prioritized removing or replacing it. Please send use cases for application receiving requests on multiple ports to me, as this helps us prioritize delivering a supported solution.

Thank you.

Hello!

I have a mongo docker image, I push it to SAP Cloud Foundry, how can I expose 27017 port to access from outside? Any idea?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment