Skip to content

Latest commit

 

History

History

todos-edge

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

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)

UI running

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