This is provided as a very simple application that can be used to demonstrate the concepts behind a cloud native application that can be deployed onto Cisco Mantl. Though designed with Mantl in mind, there is nothing specific to the application and underlying services that require Mantl to function. Any platform for deploying container based microservices should be acceptable.
The application provides a simple interface for gathering and reporting votes about the best movie superheros.
The application is built in a microservice style wrapping each service in a docker container that can be deployed and run in Mantl. In its initial form the applicaiton has three services.
- myhero/data - This service stores all the data about candidates and votes cast.
- myhero/app - This service provides the basic logic layer for accessing and recording votes.
- myhero/web - This is the main user interface for casting votes.
There is an optional deployment mode where votes are processed through an MQTT Server by being published by the myhero/app service, and processed by myhero/ernst service that subscribes to the queue. In this mode, these additional services are deployed.
- myhero/mosca - MQTT Server based on Mosca
- myhero/ernst - Vote processing services
All of the demo details here make use of the Mantl or Marathon APIs to build and manage applciations. If you prefer to use the different GUIs to execute the demos, you can use the JSON files to find the details needed to configure manually.
A great application today allows users to interact with the service in whichever way the end user prefers. No longer should we be satisfied with simply a web interface on a desktop or laptop. Users are looking for options such as:
- Mobile - smartphones and tablets
- Wearables - smartwatches
- Realtime Chat
- Voice Interaction
- Gesture Based
- and more
So with this in mind, MyHero offers some optional additional services for a fuller experienece. Check back often as the list of optional services will grow overtime.
Realtime Chat is becoming very popular with consumer as well as professional world. Cisco Spark is an enterprise collaboration platform offering text, voice, and video options for group and one on one communciations. MyHero now can leverage Cisco Spark to allow users to Chat with a Spark Bot to learn about the voting service, find out current results, and cast votes.
To setup the Spark Bot visit Spark Bot Setup
NOTE: To leverage the Spark Bot Service, your Mantl Cluster MUST be configured for deployed applications to be accessible from the public Internet. This is because it relies on the Spark Cloud to be able to send a WebHook to the myhero_spark application you run in Mantl*
Mobile phones are everywhere, and SMS/TXT continues to be a method for interacting with services. Cisco Tropo is a SaaS solution that provides Voice and SMS services that can be integrated to any applciation through a very easy to use API. MyHero has an optional Tropo service that allows users to send SMS messages to the MyHero applciation to learn abou the voting service, find out current results, and cast votes.
To setup the Tropo Service visit Tropo Service Setup
NOTE: To leverage the Tropo Service, your Mantl Cluster MUST be configured for deployed applications to be accessible from the public Internet. This is because it relies on the Tropo Cloud to be able to send a REST call to the myhero_tropo application you run in Mantl*
In order to leverage this demonstration, you will need to have a Mantl cluster up and functional already. For help with this visit the Docs site available at http://mantl.io. You will need to have the address for the control nodes and a username and password for an active account.
Run source myhero_setup
to enter and record the deployment name, address, application domain, username, and password for your Mantl instance as non-persistent Environment Variables. This means you will need to run this command everytime you open an new terminal session.
Run ./myhero-install.sh
to deploy all three services (data, app, web) to your Mantl cluster.
After running the install it will take a 2-5 minutes for all three services to fully deploy and become "healthy". You can monitor this in the Marathon Web GUI.
You should be able to reach the web interface for the application at http://DEPLOYMENTNAME-web.YOUR-DOMAIN
where DEPLOYMENTNAME
refers to the deployment name provided at setup and YOUR-DOMAIN
refers to the wildcard domain configured for Traefik.
Run ./myhero-uninstall.sh
to remove all three services from Marathon.
If you'd like to work with an application leveraging more services and components, there is an optional mode deployment that adds a MQTT server to the vote processing functions. This will reduce the potential load on the Data service by logging new votes into a queue that can be addressed one at a time. This image shows the full application architecture with all the optional elements deployed.
Run ./myhero-install-queue.sh
to deploy the standard three services (data, app, web) along with an MQTT Server (based on Mosca) and a vote processing service (ernst) to your Mantl cluster.
After running the install it will take a 2-5 minutes for all three services to fully deploy and become "healthy". You can monitor this in the Marathon Web GUI.
You should be able to reach the web interface for the application at http://DEPLOYMENTNAME-web.YOUR-DOMAIN
where DEPLOYMENTNAME
refers to the deployment name provided at setup and YOUR-DOMAIN
refers to the wildcard domain configured for Traefik.
Run ./myhero-uninstall-queue.sh
to remove all services from Marathon.
A script is included to show how you can easily scale services with Mantl.
Run ./myhero-scaleweb.sh
to have options to change the number of web and app instances deployed. You can scale up or down with this script.
If you would rather demo deploying each service independently you can use these sample curl commands. These commands assume that you've run source myhero_setup
to store environment variables for key details. This also uses the default of "myhero" as the deployment name.
- Deploy the data service
curl -k -X POST -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps -H "Content-type: application/json" -d @myhero-data.json| python -m json.tool
- Deploy the app service
curl -k -X POST -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps -H "Content-type: application/json" -d @myhero-app.json | python -m json.tool
curl -k -X PUT -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps/myhero/app?force=true -H "Content-type: application/json" -d "{\"env\": {\"myhero_data_server\": \"http://myhero-data.$MANTL_DOMAIN\", \"myhero_data_key\": \"SecureData\", \"myhero_app_key\": \"SecureApp\"}}" | python -m json.tool
- Deploy the web service
curl -k -X POST -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps -H "Content-type: application/json" -d @myhero-web.json | python -m json.tool
curl -k -X PUT -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps/myhero/web?force=true -H "Content-type: application/json" -d "{\"env\": {\"myhero_app_server\": \"http://myhero-app.$MANTL_DOMAIN\", \"myhero_app_key\": \"SecureApp\"}}" | python -m json.tool
- To scale up the web service
curl -k -X PUT -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps/myhero/web -H "Content-type: application/json" -d '{"instances":5}' | python -m json.tool
- To get the details on one of the services
curl -k -X GET -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps/DEPLOYMENTNAME/web -H "Content-type: application/json" | python -m json.tool
A strength of Modern Applications are that you can interact with any of the services directly through APIs if the native interface isn't desireable. Here are some examples interacting with the app service directly.
- View the list of potential Superheros to vote for.
curl -H "key: SecureApp" http://DEPLOYMENTNAME-app.$MANTL_DOMAIN/options
- View the current standings.
curl -H "key: SecureApp" http://DEPLOYMENTNAME-app.$MANTL_DOMAIN/results
- Place a vote for a hero
curl -H "key: SecureApp" -X POST http://DEPLOYMENTNAME-app.$MANTL_DOMAIN/vote/Batman
Other services are:
- Data - hpreston/myhero_data
- App - hpreston/myhero_app
- Web - hpreston/myhero_web
- Ernst - hpreston/myhero_ernst
- Optional Service used along with an MQTT server when App is in "queue" mode
- Spark Bot - hpreston/myhero_spark
- Optional Service that allows voting through IM/Chat with a Cisco Spark Bot
- Tropo App - hpreston/myhero_tropo
- Optional Service that allows voting through TXT/SMS messaging
The docker containers are available at
- Data - hpreston/myhero_data
- App - hpreston/myhero_app
- Web - hpreston/myhero_web
- Ernst - hpreston/myhero_ernst
- Optional Service used along with an MQTT server when App is in "queue" mode
- Spark Bot - hpreston/myhero_spark
- Optional Service that allows voting through IM/Chat with a Cisco Spark Bot
- Tropo App - hpreston/myhero_tropo
- Optional Service that allows voting through TXT/SMS messaging
Here are some other ideas for demo's to run with Mantl. Several of these leverage example content delivered with the Mantl code in the examples/ directory. Others deploy Mesos frameworks using the Mantl API.
Run all these from the root directory of Mantl. They do leverage the environment variables so be sure to run source myhero_setup
before running these demos.
- Hello-world Example
curl -k -X POST -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps -H "Content-type: application/json" -d @examples/hello-world/hello-world.json'
curl -k -X DELETE -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps/hello-world -H "Content-type: application/json"
- Kong Example
curl -k -X POST -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps -H "Content-type: application/json" -d @examples/kong/kong.json'
curl -k -X DELETE -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps/kong -H "Content-type: application/json"
- Minecraft Example
curl -k -X POST -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps -H "Content-type: application/json" -d @examples/minecraft/minecraft.json'
curl -k -X DELETE -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL:8080/v2/apps/minecraft -H "Content-type: application/json"
These can be run from anywhere but do leverage the environment variables so be sure to run source myhero_setup
before running these demos.
- List available packages
curl -k -u $MANTL_USER:$MANTL_PASSWORD https://$MANTL_CONTROL/api/1/packages | python -m json.tool
- Cassandra
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X POST -d "{\"name\": \"cassandra\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X DELETE -d "{\"name\": \"cassandra\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool
- Kafka
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X POST -d "{\"name\": \"kafka\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X DELETE -d "{\"name\": \"kafka\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool
- HDFS
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X POST -d "{\"name\": \"hdfs\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X DELETE -d "{\"name\": \"hdfs\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool
- Elastiseach
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X POST -d "{\"name\": \"elasticsearch\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X DELETE -d "{\"name\": \"elasticsearch\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool
- Arangodb
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X POST -d "{\"name\": \"arangodb\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool
curl -k -u $MANTL_USER:$MANTL_PASSWORD -X DELETE -d "{\"name\": \"arangodb\"}" https://$MANTL_CONTROL/api/1/install | python -m json.tool