IT Operations Management (ITOM)
cancel

Extend your DevOps flows: How to automate Docker with Operations Orchestration

Extend your DevOps flows: How to automate Docker with Operations Orchestration

collinchau

Written by Meir Wahnon, HP Software (RnD)

 

Servers-to-services2.pngIn my previous post, on how to “Automate Docker and enhance your DevOps flows with HP Operations Orchestration,” you saw how easy it is to use HP Operations Orchestration to build a simple Java-based web app that uses a MySQL database and link the Docker-based app container to the database container.

 

In this post, you will learn how you can extend the DevOps flow by validating and testing the app, and in the end, clear the environment. 

 

Extending the flow

As I detailed in the other post, this is an example of an app flow you can create using OO’s “build app flow”:

 

Docker_1.png

 

But creating a flow that starts our app is only the first step. What about verifying that it’s really up and running?

 

First, give the app a couple of seconds from the moment you start the container, then check it in a loop that executes a simple http GET request until we get a 200 response (“OK”). This is how it works in the context of a flow:

 

Docker_2.png

 

Now if you enter the website address, you can see this the welcome page:

 

Docker_3.png

 

Also, since you’ve used spring-data-rest in the app, you can use CRUD operations using REST API.  For example, if you go to the link: 16.60.169.142:8080/name, you get an empty JSON response about all the records in the repository.

 

If you do an HTTP POST to the same link, with the next JSON as body, {"value":"Brian"}, you will add a record to the repository. Now when you go to the same link again, this time you will get a JSON response with the value (Brian) added.

 

Here is how you can also make this a test flow:

 

Docker_4.png

 

Clean the docker env:

So, after creating all of those containers, we usually need to clean them up from time to time — they can take a lot of disk space! For that we need the next commands:

 

docker stop spring-boot-app
docker rm spring-boot-app
docker stop mysqldb
docker rm mysqldb

 

By dragging existing Docker operations to the flow, we can easily create a flow that clears containers:

 

Docker_5.png

 

After this you can run “docker ps -a” to verify none of those containers are left in your docker host.

 

Final step: Wire all the flows

So we have now made several flows, but what about using all of them in a single flow for a more complete process? Simply use all the above flows as sub-flows in another master flow, like this:

 

Docker_6.png

  

Going further

Of course, this flow can be further extended to make more complex tests, and even add deployment phases in the end. You can add onto the flow to:

 

Success and next steps

Now you have created flow that:

  • Builds an app
  • Creates app and DB Docker containers and links them
  • Verifies app is up and running
  • Clears the Docker containers

A couple of important notes:

  1. I did not show how to connect a webhook from DockerHub to OO, which is a necessary step to make the whole process automated from commit to deployment, but since OO exposes the REST API, you can do this easily
  2. This flow was built on the assumption that you have only one Docker host machine, so all containers are in the same machine. However, if you want to make it work on different hosts, you will need to use the Ambassador Pattern, with some changes to the flow logic, or use another solution (like fleet or Kubernetes).

 

For me, HP Operations Orchestration Community Edition (OO-CE) really simplified how I created these processes, and made it easy for me to present and explain my DevOps process to other.

 

Learn more

Read all about what Operations Orchestration has to offer. Then download and experiment with the latest Operations Orchestration Community Edition. It’s free!

 

Next. come join us at HP Discover Barcelona, and see this in action at our hands-on playpen area. Check out the different activities we have in store for you!

 

DiscBarc2014_ITExpertsHub_loc_Image_Wht_RGB_1_964X215.jpg

Making Cloud Simple
  • infrastructure management
About the Author

collinchau

Lending 20 years of IT market expertise across 5 continents, for defining moments as an innovation adoption change agent.