This project contains one simple micro-service that gets deployed:
-
as a Cloud Foundry application,
-
as a container in a Kubernetes cluster,
-
and as an OpenWhisk action.
Watch this Youtube video that walks you through the deployment of the service and test the behavior of the deployment options when the service crashes:
- An IBM Bluemix account. Either sign up, or use an existing account.
- Bluemix CLI
- OpenWhisk CLI
- Bluemix Container Registry plugin
- Bluemix Container Service plugin
- Node.js, version 6.9.1 (or later)
- Kubernetes CLI (kubectl) version 1.5.3 (or later)
- Docker CLI version 1.9 (or later)
The micro-service used in this project computes Fibonacci numbers.
From Wikipedia: In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
The implementation of the Fibonacci sequence is done in service/lib/fibonacci.js. The same implementation is used across all deployment options.
Follow these instructions.
Follow these instructions.
Once deployed, the service implements 3 API calls:
- compute the Fibonacci number after n iterations,
- let the computation run for t milliseconds,
- and simulate a crash of the service.
Depending on which compute option you are using, use the following cURL calls:
Endpoint Type | Endpoint | URL |
---|---|---|
Cloud Foundry | iteration | curl -v http://fibonacci-service-<random-string>.mybluemix.net/fibonacci?iteration=1000 |
duration | curl -v http://fibonacci-service-<random-string>.mybluemix.net/fibonacci?duration=5000 |
|
crash | curl -v -X POST http://fibonacci-service-<random-string>.mybluemix.net/fibonacci?crash=true |
|
Kubernetes | iteration | curl -v http://<cluster-ip>:30080/fibonacci?iteration=1000 |
duration | curl -v http://<cluster-ip>:30080/fibonacci?duration=5000 |
|
crash | curl -v -X POST http://<cluster-ip>:30080/fibonacci?crash=true |
|
OpenWhisk | iteration | curl -v https://openwhisk.ng.bluemix.net/api/v1/web/<namespace>/default/fibonacci?iteration=1000 |
duration | curl -v https://openwhisk.ng.bluemix.net/api/v1/web/<namespace>/default/fibonacci?duration=5000 |
|
crash | curl -v -X POST https://openwhisk.ng.bluemix.net/api/v1/web/<namespace>/default/fibonacci?crash=true |
File | Description |
---|---|
app.js | Main application, start the express web server and expose the service API |
lib/fibonacci.js | The implementation of the Fibonacci sequence, shared by all deployment options |
package.json | List the packages required by the application |
manifest.yml | Description of the application to be deployed |
.cfignore | List files to ignore when deploying the application to Cloud Foundry |
File | Description |
---|---|
app.js | Main application, start the express web server and expose the service API |
lib/fibonacci.js | The implementation of the Fibonacci sequence, shared by all deployment options |
package.json | List the packages required by the application |
Dockerfile | Description of the Docker image |
fibonacci-deployment.yml | Specification file for the deployment of the service in Kubernetes |
The OpenWhisk action is deployed as a zip action where several files are packaged into a zip file and the zip file is passed to OpenWhisk as the implementation for the action. deploy.js takes care of packaging the zip file.
File | Description |
---|---|
handler.js | Implementation of the OpenWhisk action |
lib/fibonacci.js | The implementation of the Fibonacci sequence, shared by all deployment options |
package.json | Specify the action entry point (handler.js) |
deploy.js | Helper to deploy and undeploy the OpenWhisk action |
Under the tester
directory is a simple web application to register and test the deployed micro-services. It can be pushed to Bluemix with cf push
or simply executed locally with python -m SimpleHTTPServer 28080
as example.
Please create a pull request with your desired changes.
Use
cf logs fibonacci-service
to look at the live logs for the web application.
Use
kubectl proxy
and look at the status of the resources in the console.
Use
wsk activation poll
and perform an invocation of the action.
See License.txt for license information.