How to Setup Rancher for Multi Host Docker Container Management

March 15, 2017 | By
| Reply More

This article talks about setting up Rancher for Multi-host Docker container orchestration. If you've had the experience of running containerized applications at scale, then you should have been struggling with how to manage potential dozens of  'dockerized' applications. This can easily be solved with the assistance of a deployment tool like Rancher. Rancher deployment workflow provides Docker-Machine based provisioning which enables the creation of Docker hosts and configures the Docker client to talk to them. Using the Rancher machine integration, we can launch nodes directly from the Rancher UI which is critical in creating and managing multi-node deployments from a single interface.  This article covers how to setup Rancher on Ubuntu 16.04 and add host docker containers.

Prerequisites

Setting up Rancher requires an Ubuntu 14 distro with the Docker 1.12.0 image. One 1GB Ubuntu 14.04 Droplet with the Docker 1.6.0 image.

First and foremost, SSH into the host machine that will be running Rancher. The following script describes how to run a Rancher server.

docker run -d --name rancher-server -p 80:8080 rancher/server

Open up the firewall, then it will take Rancher a while to setup. It will only take a couple of minutes for Rancher server to start up. When the logs show .... Startup Succeeded, Listening on port..., the Rancher UI is up and running. This line of the logs is almost immediately after the configuration is complete. There may be additional logs after this output, so please don’t assume it will be the last line of the logs upon initialization.

Our UI is exposed on port 8080, so in order to view the UI, go to http://<SERVER_IP>:8080. If you are running your browser on the same host running Rancher server, you will need to use the host’s real IP, like

http://192.168.1.100:8080 and not http://localhost:8080 or http://127.0.0.1:8080.

Configuring Authentication

After about a minute, your host should be ready and you can browse to http://<SERVER_IP>:8080 which was displayed when the rancher host successfully launched. You can setup Authentication since the host is online, You can use the GitHub OAuth based authentication.

On the top of the screen, you should see  Access Control is not configured followed by a link to Settings. Click Settings and follow the instructions given there to register a new Application with GitHub, and copy the Client ID and Secret into the respective text fields.

When you finish, click Authenticate with GitHub, then Authorize application in the window that pops up. Once you do, the page will reload, and the instructions on setting up OAuth will be replaced by the Configure Authorization section. Add the relevant users and organizations and save.

Fill in a name of choice and choose the owner in the window that pops up, and click Create. Then use the project selection menu again to select it. All compute nodes we add will be contained in this project.

 Launching Containers

Once the Rancher deployment is secured and project added, click Add Host button to launch a Rancher computer node.

If this is the first time launching a host, you will see a pop-up screen asking you to confirm the IP address your Rancher server is available on, i.e. where the compute nodes will connect.

In the Add Host screen, you will see three providers: DigitalOcean, Amazon EC2, and custom. The first two are used to launch compute nodes on the respective cloud systems and the third lists the command used to manually launch a Rancher compute node on a server with Docker pre-installed.

Select the one you prefer and add the necessary details and hit Create. Rancher will use Docker Machine to create the specified Droplet and install Docker on it. Rancher will also run the rancher-agent on the newly created Droplet, which will in turn register with the Rancher server.

Within a few minutes your should see your compute node in the Rancher UI. You will also get some basic information about the nodes such as their IP address, processor clock-speed, memory, and storage.

 Monitoring Containers

Here, we explore the built-in monitoring for compute nodes, deactivating and deleting nodes. Once the nodes are provisioned, click on the name of the node to pull up the Monitoring screen. Here you can see the memory consumption, CPU utilization and other details about the node. Depending on the server overload you can launch other nodes to reduce container density or reduce the container nodes respectively.

This can be done selecting Deactivate, Activate or Delete from the same menu depending on what you wish to accomplish.

Now you should be able to launch, monitor and terminate nodes using Rancher for Docker containers. Share with the community other use cases you find useful.

Filed Under : CONTAINERS

Tagged With : , ,

Free Linux Ebook to Download

Leave a Reply

All comments are subject to moderation.