Deploying Microservices Style Applications with CoreOs, Docker and Nirmata
Join the DZone community and get the full member experience.Join For Free
[this article was written by ritesh patel .]
as application container adoption continues to grow, the popularity of ‘minimal’ operating systems, designed to run containers, is on the rise. one such operating system is coreos. coreos has been architected to run modern, cloud native applications and provide support for docker containers.
in this post, i will describe how nirmata can be used to deploy and operate microservices applications on coreos. the high level steps are simple:
- create a host group
- setup a coreos vm
- deploy an application
i will describe each step in detail below.
create a host group
in nirmata, a host group is a pool of identical resources. you can define one or more, host groups for each cloud provider, and then map host groups to application and service level policies.
nirmata supports several public and private cloud providers. for this setup, i will use the ‘other’ provider type and directly connect individual coreos instances to my host group.
the first step is to create a new host group in nirmata for my coreos vms. this can be done by going to host groups->other and clicking on the add host group button. in the wizard, i can specify the name for my host group and there resource selection policy.
in the resource selection policy, i select ‘sandbox’ as the environment type and ‘availablememory’ as the placement type. this policy ensures that whenever an application in deployed in the ‘sandbox’ environment, the coreos cluster is used and the containers are placed based on the memory available on the vms within the cluster.
once this host group is created, i can now add my coreos vms to the cluster. the cli command to setup vms to connect to nirmata and to be added to this host group is also displayed.
setup a coreos vm
to set up my coreos vms for use with nirmata, i can ssh to the vm and run the command to setup my vms to connect to nirmata and be added to my host group. the command also displayed on the host group page:
sudo curl -ssl http://www.nirmata.io/nirmata-host-agent/setup-nirmata-agent.sh | sudo sh -s other <host-group-id>
this command will download the host agent container image and run it as a systemd service.
once the host agent is running, it will connect to nirmata and the host will be added to the host group
you can repeat this steps to add multiple coreos vms to your host group. i added one more vm to my host group so my coreos cluster has 2 vms.
deploy your application
now, i am ready to deploy my application. i have imported a small demo application with 6 services in nirmata.
to create an environment to deploy this application, go to environments and click on add environment. in the wizard, select the environment type as ‘sandbox’ and the application as ‘shopme-demo’.
click finish to start deploying the environment. you should see the containers (services) getting deployed.
in a few minutes, all the services are deployed and are running.
i can verify this by going to the host group view and viewing the hosts. i can see that each host has 3 containers deployed.
i can also verify that my containers are deployed by checking my vms.
once my application is deployed, i can actively monitor it and manage it from nirmata. i can easily add additional hosts to my host group as well as scale up or scale down my containers.
as you can see, within a few minutes you can create a cluster of vms and deploy a distributed application with nirmata. once deployed, the application can also be easily monitored and managed. give it a try and let us know what you think!
to deploy your coreos cluster on different cloud providers, you can refer to our documentation .
Published at DZone with permission of Jim Bugwadia, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.