Code Monkey home page Code Monkey logo

heroku-docker-flex-gateway-example's Introduction

heroku-docker-flex-gateway-example

Barebones example of deploying the official Flex Gateway Docker image to Heroku.

DISCLAIMER

The author of this article makes any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information of this website is strictly at your own risk, and the author will not be liable for any losses and damages in connection with the use of the website and the information provided.

Prerequisites

  • A Heroku Account
  • A MuleSoft CloudHub Account
  • Docker desktop

How to install and run Flex Gateway (Connected mode) on Heroku

  1. Login to MuleSoft Anypoint and “Add a Flex Gateway” from here
  2. Select Container > Docker (under Select your OS or environment) and run the command shown under “Register your gateway” replacing the <gateway-name> with a name of your choice
  3. If the above command is executed without errors a registration.yaml file should have been created - the content of this file shall be added later as a Heroku configuration environment variable of your Heroku Flex Gateway app
  4. The Flex Gateway created will appear under MuleSoft Anypoint > Runtime Manager > Flex Gateways and its status will be displayed as Disconnected.
  5. Click the Heroku button below to deploy Flex Gateway on Heroku and fill in the required variables Deploy to Heroku
  6. The Flex Gateway created will appear under MuleSoft Anypoint > Runtime Manager > Flex Gateways and its status will be displayed as Connected. Clicking on it, under the APIs item on the left menu, it will be possible to create the APIs to be associated with it (“Add API” button).
  7. As the Downstream Port of the API enter 2020 - it should match the value used for the FLEX_DYNAMIC_PORT_VALUE environment variable of your Heroku Flex Gateway app
  8. Go under your Heroku app Settings tab and copy your app domain name (close to “Your app can be found at”), append to this URL your API Base path (if configured) and open the resulting link (e.g. with curl) - you should be redirected to the configured Upstream URL

Implementation Notes

  • a sidecar envoy TCP proxy is used to forward the Heroku connections on $PORT to the Flex Gateway envoy proxy listening on $FLEX_DYNAMIC_PORT_VALUE
  • to avoid ports clashing between $PORT and the Flex Gateway internal services using 127.0.0.1 interface and several ports (4000,9998,9999,15001,15002,15100), the interface used by the sidecar envoy proxy to listen on $PORT is not 0.0.0.0

Additional Notes

  • Tested with an API having an "IP Allowlist" policy
  • Tested with an API having a "Rate Limiting" policy - this requires Heroku Data for Redis add-on and a specifc YAML configuration file under the /config directory (e.g. shared-storage-redis.configuration.yaml)
apiVersion: gateway.mulesoft.com/v1alpha1
kind: Configuration
metadata:
 name: shared-storage-redis
spec:
 sharedStorage:
   redis:
     address: <hostname>:<port>
     password: <password>
     tls:
        skipValidation: true
        minVersion: "1.1"
        maxVersion: "1.3"

Tested on

This package has been tested using the following:

Platform/Tool Version
Heroku Common Runtime -
Heroku Private Space -
MuleSoft CloudHub Anypoint -
Flex Gateway Docker image 1.6.0
Docker desktop 4.21.1

Credits

Credits to the owner of the original project I've exchanged with to make it work on Heroku Common Runtime and Private Spaces

Manual deployment

You will need to create a Heroku account and install the Heroku CLI, eg. brew install heroku.

git clone [email protected]:garciarodrigor/heroku-docker-flex-gateway-example.git
cd heroku-docker-flex-gateway-example
heroku container:login
heroku create
heroku config:set FLEX_REGISTRATION=<registration-content> FLEX_SERVICE_ENVOY_CONCURRENCY=1 FLEX_DYNAMIC_PORT_VALUE=8081
heroku container:push web
heroku container:release web
heroku open

heroku-docker-flex-gateway-example's People

Contributors

garciarodrigor avatar mulepasfug avatar rt-heroku avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.