Combining the power of ACE and NodeRED

#!/bin/bash## Change the project and credentials as needed
PROJECT=”ace-nodered”
#### Create a new project namespace
echo “Create Project”
oc new-project ${PROJECT} \
— display-name=”ACE NodeRed” \
— description=”Add a Node-RED sidecard that can be called from ACE”
## Set up Serice Account to allow ACE to run as any UID
oc create serviceaccount ace-runasanyuid
oc adm policy add-scc-to-user anyuid -z ace-runasanyuid — as system:admin
#### Create the secret that will allow the builder to access github
echo “Create secret”
oc create secret generic tonyhickman-github \
— from-file=ssh-privatekey=ocp-access \
— type=kubernetes.io/ssh-auth
#### Build the new Node-RED component
echo “Create NodeRED new build”
ssh-agent bash -c ‘ssh-add ocp-access; /
oc new-build git@us-south.git.cloud.ibm.com:tony_hickman/ace-nodered.git \
— source-secret=tonyhickman-github \
— env=NODE_RED_CREDENTIAL_SECRET=”acenrpoc” \
— name ace-nr’
echo “Sleep for a while”
sleep 120
#### build the app as a POD with TWO containers in it
# NB: No builder needed for ACE as pulling Image from Docker Hub. This may change going forward if want to insert BAR’s
echo “Create App”
oc new-app ibmcom/ace:latest+ace-nr:latest \
— env=NODE_RED_CREDENTIAL_SECRET=”acenrpoc” \
— env=LICENSE=”accept” \
— env=MESSAGESIGHT_CONTAINER_NAME=”ace-server” \
— env=ACE_SERVER_NAME=”ACESERVER”
— name ace-app
# Stop OCP from restarting the pod
oc set triggers dc ace — manual
## Patch app to run as any
echo “Patch”
oc patch dc/ace — patch ‘{“spec”:{“template”:{“spec”:{“serviceAccountName”: “ace-runasanyuid”}}}}’
# Allow OCP to restart the pod when changes are made
oc set triggers dc ace — auto
echo “Expose LoadBalancer Ingress”
oc expose dc ace — type=LoadBalancer — name ace-loadbalancer
### create a secure route
echo “Create Routes….”
echo “Expose NodeRED on HTTPS”
oc create route edge ace-node-red — service=ace — port=1880 — insecure-policy=Redirect
echo “Expose svc”
oc expose svc ace — name=ace-admin — port=7600 — protocol=”TCP”
exit 0
OpenShift configuration

Calling NodeRED from ACE Flow

REST API wizard
Empty REST API
Add resource
API with new resource
Model Creation
New Model
Update body schema
Create sub flow
postCall sub flow
Route node properties
$Root/JSON/Data/service
ESQL Code
http://localhost:1880/ACECall2/Tester
http://localhost:1880/ACECall/Tester1
Set Compute Mode
ACE management interface
ACE Management console
NodeRED flow
ACETest Template
ACETest2 Templace
{
“name”: “Some”,
“surname” : “OneElse”
}
{
“name”: “Tony”,
“surname” : “Hickman”
}

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store