Skip to content

Latest commit

 

History

History
87 lines (64 loc) · 2.97 KB

3.5.deploy-orion.md

File metadata and controls

87 lines (64 loc) · 2.97 KB

Deploying Orion

Well, how about we do this with Orion instead of httpbin? Why the heck not. Start by deploying MongoDB:

$ kubectl apply -f deployment/mongodb_service.yaml

This is a simple MongoDB service with no replication and ephemeral storage—i.e. your DB won't survive a pod restart—but will do for testing. You should wait until MongoDB is up and running before deploying Orion—in a prod scenario, you'd want to automate this with e.g. init containers, but hey we're just testing here :-) Instead of waiting around just twiddling your thumbs, edit your load balancer config to add an external port for Orion:

$ EDITOR=emacs kubectl -n istio-system edit svc istio-ingressgateway
#        ^ replace with your fave or don't set the variable to use default

Then add the below port to the ports section:

ports:
...
  - name: orion
    nodePort: 31026
    port: 1026
    protocol: TCP
    targetPort: 1026

This makes mesh gateway port 1026 reachable from outside the cluster through port 31026. Next deploy Orion

$ kubectl apply -f deployment/orion_service.yaml

and you're ready to play around! Here's how to get your feet wet:

$ source scripts/cluster-url.sh
$ curl -v "$ORION_BASE_URL/v2"
# you should get back a 403/permission denied.

$ curl -v "$ORION_BASE_URL/v2" -H "header:${HEADER_VALUE}"
# set HEADER_VALUE as we did earlier; you should get back some
# JSON with Orion's API entry points.

You can try adding entities, subscriptions and trigger notifications. It should all go without a hitch. Here's a smoke test.

$ sh scripts/orion.post-entity.sh

creates a brand new Orion entity of type Room with an ID of Room1, pressure and temperature attributes, whereas

$ sh scripts/orion.sub.sh

tells Orion to notify our trustworthy friend at httpbin.org (we owe you big time my china!) whenever that entity changes. To see it while it's happening, start tcpdump in a separate terminal

$ sudo tcpdump -i any -s 4096 -A host httpbin.org

then switch back to your current terminal and send a Room1 update with

$ sh scripts/orion.update-entity.sh

Your tcpdump should've spewed out a giant cloud of text but if your eyes can manage to separate the wheat from the chaff, you should be able to catch the Orion notification coming out of the mesh towards httpbin.org. It should look something like

POST /post HTTP/1.1
host: httpbin.org:80
fiware-servicepath: /
fiware-correlator: 449ec094-82fe-11ea-a8d6-0242ac110013
ngsiv2-attrsformat: normalized
header: eyJAdHlwZSI6ImlkczpSZXN1bH...(Orion's DAPS identity)...
...

{"subscriptionId":"5e9d82045bfa0aeb50e8e21e",
 "data":[{
     "id":"Room1",
     "type":"Room",
     "temperature":{"type":"Float","value":21.5,"metadata":{}}}]}

Smoking can badly damage your health, so I won't encourage you to try any more smoke tests but surely we've set the scene for your own, hopefully smoke-free, tests.