M2R Lab
Prerequisites
For this work, you need:
- A Java Development Kit (JDK 1.7+). OpenJDK and Oracle JDK both work.
- Maven (3.x).
- RabbitMQ (follow these instructions to install and configure it).
- Docker (1.5+).
- A good internet connection.
If you do NOT have a Linux system, you will be able to do everything EXCEPT the Docker part.
Installation
This section is about installing the Roboocnf DM and starting it.
- Install all the prerequisites.
- Open a new terminal and verify everything is correctly installed.
# Both command should succeed
java -v
mvn -v
- Download and unzip the DM somewhere on your machine.
- Configure the DM so that it uses RabbitMQ.
- Start the DM (execute bin/karaf).
Building the first Application
This section is about preparing the first application you will deploy with Roboconf.
- Checkout the following project on GitHub.
- Study the structure of the project and look at the files.
In the scope of another work, you will be asked to create a XText editor for some of these configuration files.
By default, the application is configured to be deployed on Docker.
This is not the initial deployment target. Update the graph/VM/target.properties file with the following content:
handler: in-memory
name: in-memory
description: To simulate deployments.
Compile the project with Maven.
# The command's output will be located under the project's "target" directory
mvn clean package
Verify you have a ZIP file under the target directory.
First Deployment
This section is about loading the previous application in the DM.
Go back to the DM’s console (Command Line Interface - CLI).
In the CLI, install the in-memory handler.
roboconf:target in-memory
This handler will simulate the deployment of your application.
It will help to understand the dependency resolution mechanism.
- Open your web browser and go to the Roboconf web console.
- Create a new application from a template to upload (select the application archive you compiled previously).
- Call this application lamp in memory.
- Then, go under the instances sub-menu, start and deploy components to see what happens.
You can use the deploy & start all action. When everything is deployed and started, watch what happens when you stop the database. Which other parts of the application are impacted?
In the graph file of the application project, find the properties that explain this behavior.
Docker Deployment
This section is about deploying the previous application on Docker with Roboconf.
In the DM’s CLI, install the docker handler.
roboconf:target docker
This handler will enable the manipulation of Docker images and containers.
It will be used to deploy the application on your local machine.
In the web console, go into the deployment targets top menu.
Create a new target called docker and copy the following content.
# Common information to any target
handler = docker
name = Docker
description = A Docker installation with an image generated by Roboconf.
# Docker specific properties
docker.generate.image = true
docker.image = roboconf-docker-img
- Save the target properties.
- Create a new application from the archive you uploaded (no need to upload it twice). Simply create a new application from an existing template.
- In the new application properties, set the docker target as the default target in the target associations sub-menu.
- Verify you have Docker installed and configured for REST invocations.
- Go into the instances sub-menu of the application and deployed and start it all.
- Monitor progress with docker ps and docker images commands.
Roboconf will indeed generate a Docker image, install an agent on it, configure and start it.
It will then create containers from this image and install the application on it.
Once everything is deployed and started, find the IP address of the Apache load-balancer (e.g. 172.17.0.19). Then, open your web browser to http://172.17.0.19/roboconf-hello/.
Verify round-robin works.
What happens if you stop one Tomcat server? What happens if you stop the database?
Going Further - Cloud Deployment
This section does not require a cloud account, this is not about manipulating but about understanding how you would proceed.
Assuming you want to deploy this same application on a cloud infrastructure (e.g. Amazon Web Services, for public cloud), how would you do? And assuming you want to deploy the database on a first infrastructure, and the servers on another (hybrid cloud), how would you do?
Going Further - The DSL
- Let’s imagine we want to define a new kind of application in the graph.
- Create a new component that can be directly deployed on a VM (choose a name for it and associate it with the script installer).
- Please, refer to the DSL description to update the graph.
- Add associated instances in the model, on a new VM.
- Create script recipes that simply echo a message.
- Update the project version in your POM to not conflict with the first application template you deployed.
- Compile the project with Maven to verify your model does not contain errors.