Code Monkey home page Code Monkey logo

todos-edge's Introduction

Todos Edge

An edge for sample Todo Spring Boot apps.

First things first

This application is 1 of 3. The other 2 (UI & API) stand on their own as samples, but this one depends on at least those. The API is swappable with any HTTP todos CRUD API. See todos-api for a reference.

First clone and run the UI and API before running this app.

Run on PCF

  1. Consider forking this project then clone to dev machine
  2. cd into project
  3. mvnw clean package
  4. modify manifest.yml for your cloudfoundry tastes (custom route perhaps?)
  5. Configure todos.api.endpoint and todos.ui.endpoint in manifest.yml, note PCF will hydrate the container with the envars and Spring Boot will apply to exposed properties where the naming conventions match (snake_case to property.case).
    ---
    applications:
    - name: todos-edge
      memory: 1G
      routes:
      - route: todos-edge.apps.retro.io
      - route: todos.apps.retro.io  
      path: target/todos-edge-1.0.0.SNAP.jar
      env:
        TODOS_UI_ENDPOINT: https://todos-webui.apps.retro.io
        TODOS_API_ENDPOINT: https://todos-api.apps.retro.io
  6. login to PCF (or PWS)
  7. cf push (awwwweee yeah)

Once the app is running access with the route provided in the manifest. If the UI and API are configured you should see the api enabled app.

Internal Routes on PCF

We can restrict access to the Backend API and UI by removing public routes for those apps and then mapping them to an internal domain (apps.internal). Once the apps have an internal route we can add a network policy that allows the Edge to call them.

Push the Edge, API and UI with the manifest-internal.yml from each project and the result will be a deployment where the Edge is the access point for the Todo app and the API and UI apps aren't over-exposed on the network.

  1. Push todos-api and todos-webui with the manifest-internal.yml in each project
  2. Push the todos-edge (this project) and configure the API and UI internal routes in manifest-internal.yml
  3. Configure todos.api.endpoint and todos.ui.endpoint in manifest-internal.yml
    ---
    applications:
    - name: todos-edge
      memory: 1G
      routes:
      - route: todos-edge.apps.retro.io
      - route: todos.apps.retro.io  
      path: target/todos-edge-1.0.0.SNAP.jar
      env: # internal routes
        TODOS_UI_ENDPOINT: http://todos-ui.apps.internal:8080
        TODOS_API_ENDPOINT: http://todos-api.apps.internal:8080
  4. Add network policy to allow access to API and UI from Edge
    $ cf add-network-policy todos-edge --destination-app todos-api
    $ cf add-network-policy todos-edge --destination-app todos-webui
    $ cf network-policies
    Listing network policies in org retro / space arcade as corbs...
    source       destination   protocol   ports
    todos-edge   todos-api     tcp        8080
    todos-edge   todos-webui   tcp        8080    
  5. login to PCF (or PWS)
  6. cf push -f manifest-internal.yml (awwwweee yeah)

Local

You can clone, build, run then access localhost:9999 or change the port. But first clone and run the UI and API.

java -jar ./target/todos-edge-1.0.0.SNAP.jar \
  --todos.api.endpoint=http://localhost:8080 \
  --todos.ui.endpoint=http://localhost:4040 \  
  --server.port=whatever

todos-edge's People

Contributors

corbsmartin avatar corbtastik avatar

Watchers

 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.