Code Monkey home page Code Monkey logo

rhea-http-app's Introduction

Rhea http app demo

Design

Prerequisites

in the root folder of the project run: docker build -t <name_container> .

Then we need add a connector to communicate with the http api server.

connector {
    host: 127.0.0.1
    port: 10000
    saslMechanisms: ANONYMOUS
    role: normal
}

Here a possible example:

  • create a file called qdrouterd.json
  [
    [
        "router",
        {
            "id": "local-router",
            "mode": "interior"
        }
    ],
    [
        "listener",
        {
            "name": "amqp",
            "host": "0.0.0.0",
            "port": 5672
        }
    ],
    [
        "connector",
        {
            "host": "127.0.0.1", 
            "port": 10000,
            "saslMechanisms": "ANONYMOUS",
            "role": "normal"
        }
    ]
  ]

then add this file when you run your container

docker run --rm --name router -v <path of your config file>/qdrouterd.json:/tmp/qdrouterd.json:Z -e QDROUTERD_CONF_TYPE=json --network host  <name container>

How install

Go into the frontend, api, data-manager folder and run the command:

npm install

How run

Before running the application we need to create a build of the frontend app and move it into the api/src folder

To do that go into the frontend folder and run the command:

npm run build

then you can go into the api and data-manager folder and run the command:

npm run start

then open the browser at http://localhost:3002

Development

Go into the frontend, api, data-manager folder and run the command:

npm run start-dev

then open the browser at http://localhost:3000

Running services from containers

Go into data-manager and api folders and run

docker build -t <name_container> . docker run --rm --network host <name_container>

then open the browser at http://localhost:3002

MAC differences

On the Mac the option --network=host doesn't work: The docker daemon is actually running in a virtual machine, not your actual machine. Thus, it’s not connecting to host ports for your Mac, but rather it’s connecting to host ports for that specific virtual machine.

The connector should be

connector {
    host: "host.docker.internal",
    port: 10000
    saslMechanisms: ANONYMOUS
    role: normal
}

moreover the Skupper-router container should expose the port (by default 5672)

docker run --rm --name router -v <path of your config file>/qdrouterd.json:/tmp/qdrouterd.json:Z -e QDROUTERD_CONF_TYPE=json -p <BROKER_PORT_HOST>:<BROKER_PORT_CONTAINER>  <name container>

then the api server

docker run --rm -p 10000:10000 -p 3002:3002 <name http api server container>

before running the datastore server container we need to pass the right host to connect

RHEA_DATASTORE_HOST="host.docker.internal" docker run --rm <name container>

Running services using Skupper

Environment

The following example uses Openshift to set our kubernetes clusters, but we can work with different cluster configurations

To run this tutorial you will need:

  • The kubectl command-line tool, version 1.15 or later (installation guide)

  • The skupper command-line tool, the latest version (installation guide)

  • Two Kubernetes namespaces, from any providers you choose, on any clusters you choose

  • Two logged-in console terminals, one for each cluster or namespace

Step 1: Configure 2 namespaces and setup skupper

  • Open 2 terminal console tabs and type:

Namespace web-server and be-store:

skupper init

Step 2: Deploy the application

Namespace web-server:

kubectl apply -f <rhea-http-app path>/api/web-server.yaml

Expose the web-server service with Openshift

kubectl expose deployment/web-server --port <web server port> --type LoadBalancer  // default port 3002
oc create route edge --service=web-server -n web-server 

Namespace be-store:

kubectl apply -f <rhea-http-app path>/data_manager/be-store.yaml  

.yaml configurations shoud have the path of your containers

Step 3: Expose the be-store service to the web-server

Namespace web-server:

skupper service create datastore 5672
skupper service bind datastore deployment web-server --target-port 10000

Step 4: Connect namespaces with a Skupper connection

Namespace web-server:

skupper token create <custom path> // ie: /tmp/web-server

Namespace be-store:

skupper link create <path token created in web server namespace>

The console terminals in this demo are run by the same user on the same host.

Check the status

Namespace web-server:

$ skupper status
Skupper is enabled for namespace "web-server" in interior mode. It is connected to 1 other site. It has 1 exposed service.

Namespace be-store:

$ skupper status
Skupper is enabled for namespace "be-store" in interior mode. It is connected to 1 other site. It has 1 exposed service.

Show the application

Namespace web-server:

oc get route -n web-server

then get the public URL to show the app on the browser

Cleaning up

Namespace web-server:

skupper delete
kubectl delete service/web-server
kubectl delete deployment/web-server
kubectl delete namespace web-server 

Namespace be-stpre:

skupper delete
kubectl delete service/be-store
kubectl delete deployment/be-store
kubectl delete namespace be-store 

rhea-http-app's People

Contributors

bartoval avatar ted-ross avatar

Watchers

James Cloos avatar  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.