Docker has changed the face of the modern approach to placing user applications and services in the clouds, presenting portable containers for applications. Portability means no dependency on a specific cloud infrastructure (
vendor lock-in ), simple migration of applications between the clouds, simple deployment, reduced support and maintenance costs. With a containerized, portable application, you can focus on increasing application performance, availability, and other important application features. Existing technologies like Kubernetes, Swarm, Panamax, Helios, Clocker, Dies, etc. develop technologies on top of Docker and make a significant contribution to the development of the ecosystem.
Rancher focuses completely on another issue. Imagine you are deploying an application in a Docker in the cloud. Infrastructure is portable, but service services such as fault-tolerant load balancers and other solutions are not. If you need to migrate to another cloud where this functionality differs, problems will arise.
')
Rancher's goal is to create portable infrastructure services around Docker, including elastic block storage, virtual networks, a fault-tolerant load balancer, security groups, monitoring, database services, and more. All this you can transfer between your own servers and clouds of different manufacturers, use several regions of the cloud provider at the same time. And since there is no dependence at the infrastructure level, you can choose a cloud based on the ratios of reliability, performance, price and trust.
By the way,
Rancher sources are available under the Apache 2.0 license.
In this article we will look at the Rancher infrastructure in more detail and install the
Rancher in
InfoboxCloud .
How to get a trial version of InfoboxCloud for free - read at the end of the article.Before using Docker, Compose and Rancher, it will be useful to read the articles:
We use Docker and do not worry about vendor-lock
Dive into Docker: Dockerfile and communication between containers
Overview of Docker Engine from 1.0 to 1.7. Introduction to Docker ComposeMain features
- Private networks . The ability to create private SDN networks for each environment, allowing secure communication between containers between hosts and clouds.
- Load balancing Built-in elastic load balancer to distribute traffic between containers or services. The load balancing service can even work between different cloud regions.
- Storage Management Support for Docker snapshots and backups, the ability to backup the state of containers and the status of services.
- Service discovery A distributed DNS discovery service with integrated health monitoring that allows containers to automatically register themselves as services and dynamically find others on the network.
- Service upgrades . The ability to easily upgrade services using cloning and redirecting requests to the service. This allows you to check the updated service before sending traffic to it.
- Resource Management . Support for Docker Machine, a host provisioning tool. The ability to monitor host resources and manage container deployment.
- Sharing and managing users . The ability to create multiple users of infrastructure and collaborate on supporting the life cycle of services. The ability to create separate environments for development, testing and industrial use with the ability to share resources.
Interfaces for working with Rancher
There are three main ways to work with Rancher:
- Users can work with Rancher using the Docker CLI and API. Rancher is not another layer of orchestration and control, hiding Docker functionality from users. The Docker platform is constantly evolving and the wrapper layer would not keep pace with the emergence of new Docker features. Rancher works in the background and users can continue to use the native Docker Command Line Interface and Compose templates. Rancher uses labels - the Docker 1.6 feature to transfer additional information through the Docker CLI. This feature was developed by Rancher Labs and was included in the Docker.
- Users can interact with Rancher using the rancher-compose command line utility. This utility allows users to run multiple containers and services that are based on docker-compose and Rancher infrastructure. Rancher – compose supports docker-compose.yml format. Optionally, the rancher-compose file can be extended using service definitions.
- Users can interact with Rancher using Rancher UI . In it, you can perform configuration tasks, such as installing access control, managing environments, adding docker-registries. Rancher UI is a simple and intuitive way to manage infrastructure and services.
Install Rancher in InfoboxCloud
What InfoboxCloud will give when used with RancherIn this scenario,
InfoboxCloud will allow you to create the required number of cloud servers in
St. Petersburg ,
Moscow or
Amsterdam configurations required for your tasks, and not choose from pre-configured server templates (if you need more CPU, RAM or disk, just add this resource) .
Cloud server data will be protected by triple replication and
automatic scheduled backups . The entire disk subsystem is accelerated by Enterprise SSD caching on PCI – Express SSD and Datacenter SSDs. SLA server availability at 99.99% per year.
Use the clouds because they successfully solve your problems
at affordable prices , and not because there is nowhere else to go.
Rancher is deployed as a Docker container set (which means installation will be easy). The installation consists of two containers: one container is the managing server, the other is the agent on the node. Rancher may work in high-available configurations, but we will consider them in future articles.
System requirements
- It is recommended to use Rancher with CentOS 7 and Docker.
- For the control server to work, 1Gb of RAM is required.
Install the Rancher Server
How to create a server for Docker in InfoboxCloudIf you do not have access to InfoboxCloud -
order it .
Using the cloud is very convenient because there is no subscription fee. When registering, you simultaneously replenish your account with at least 500 rubles (by analogy with the purchase of a sim – card from a mobile operator) and then you can use the cloud as needed. Quickly calculate how much approximately a cloud server will cost for you per month
here (specify the correct dimensions, for example 2 GHz of frequency, and not 2000 GHz). Payment is made on an hourly basis and is frozen on your account. Using autoscaling or changing the amount of available server resources manually, you can only pay for the necessary resources and further save and be able to get more resources when necessary.
After registration, you will receive data to access the control panel by email. Enter the control panel at:
https://panel.infobox.ruIn the “Cloud Infrastructure” section of your subscription, click “New Server” (if necessary, the subscription changes in the upper right corner in the drop-down menu).

Set the required server parameters. Be sure to allocate a public IP address to the server and check the box
“Allow OS kernel management” , as shown in the screenshot below.

In the list of available operating systems, select CentOS 7 and complete server creation.

After that, the data to access the server will come to your email.
After creating a server with CentOS 7, connect to it
via SSH .
We have prepared a script that will allow you to install Docker and useful utilities for working with Docker on such a server. The necessary settings will be made automatically.
Run the command to install Docker and Compose:
bash <(curl -s http://repository.sandbox.infoboxcloud.ru/scripts/docker/centos7/install.sh)
What the script does1. Updates the OS.
2. Stops postfix and disables its autostart. Postfix takes port 25, but this port may need your docker services.
3. Adds the official Docker repository and installs the docker-engine.
5. Adds EPEL repository, installs pip, installs Docker Compose with pip.
6. Starts the Docker service and adds it to the autoload.
Reboot the server.
Now you can install Rancher Server.
Create a folder where the Rancher server files and subdirectories for the database will be stored with the command:
mkdir -p ~/rancher/var/lib/mysql/
Change directory to user:
cd ~
Download the compose Rancher Server deployment file:
curl -O http://repository.sandbox.infoboxcloud.ru/scripts/rancher/centos7-docker/docker-compose.yml
Finally, run the Rancher Server deployment:
docker-compose up -d
After deployment, you can access the server at:
ip–-:8080
It is recommended to send the A domain record to the Rancher server that will be used with Rancher, in order not to change the authorization keys in the future when sending the domain and not to reconfigure Rancher hosts when changing the management server.In future articles, we will look at how to enable SSL support with Rancher (you need to deploy nginx reverse proxy in front of Rancher).
Configure access control
Access control is needed so that Rancher limits the number of users who have access to your Rancher servers. The first account that configured authentication in Rancher becomes an administrator account. Only administrators have rights to view access control settings and register hosts. In addition, administrators have rights to view all environments in an installation, even if they have not been added as members of the environment.
Enable Access Control
Click on
Settings in the warning about disabled access control.

Currently, authorization is only supported through
Github , but in the future there will be other ways.
If you do not have an account on Github,
register and
log in.
Click on your account icon at the top right of the
GitHub and go to the Settings section.

Go to the "Applications" section and click on "Developer Applications". In this section, click "Register New Application".

Fill in the fields:
- application name - specify anything, so that you can understand that this is a Rancher.
- homepage URL - the address of the installed Rancher Server (domain or ip – address)
- Application description - any Rancher description
- The authorization callback URL is listed on the Rancher Server Settings page, which we opened earlier.

After that click "Register New Application".
You will see Client ID and Client Secret.

Paste them into the Rancher Access Control Settings section.

After that, click
Authenticate with Github to save the settings.
The Github page will open, where you need to click "Authorize Application".

Access control is now configured.
If you want to add a person or organization to Rancher, in the
Access control section in the
Site Access section, click
Customize .

You can specify a person or organization account on Github and add Rancher to the list of users.

Added users will be able to create environments and you can allow them to work on existing environments.
Add a host
Containers and services will work directly on the hosts. It is recommended for the host to create a separate server in InfoboxCloud with CentOS 7. You can create hosts in different regions, for example in Moscow, St. Petersburg and Amsterdam, and place Rancher services and containers where you need to at the moment. An additional cloud region can be added on the main page of the control panel in the “Order a new service” section.
How to create a server for Docker in InfoboxCloudIn the “Cloud Infrastructure” section of your subscription, click “New Server” (if necessary, the subscription changes in the upper right corner in the drop-down menu).

Set the required server parameters. Be sure to allocate a public IP address to the server and check the box
“Allow OS kernel management” , as shown in the screenshot below.

In the list of available operating systems, select CentOS 7 and complete server creation.

After that, the data to access the server will come to your email.
Install the script on the Docker server:
bash <(curl -s http://repository.sandbox.infoboxcloud.ru/scripts/docker/centos7/install.sh)
In order to save during testing, you can use the same server where Rancher Server is installed.
To add a host to the Rancher, go to the “Infrastructure” section and click “
Add Host ”.

Click “Custom”. You will see the command that you need to run in the console to add the server as a host.

After that click Close and you will see the host in your infrastructure.
If you click on this host, you will see the current schedule for loading resources. In this case, the RAM is busy because we allowed the use of Rancher Server and as a host. In
the InfoboxCloud
control panel, you can simply add RAM to the server and resources will increase.

Add a few more hosts to Rancher Server in different regions. We simply create a server with a CentOS 7 in the required region and a tick "Allow OS kernel management", install the Docker script, click on the Rancher Server
Add Host and execute the command issued by Rancher on the host. So simple.
Now we have the infrastructure at Rancher, operating in various regions of InfoboxCloud.

At any time, you can deactivate one of the hosts to prohibit the creation of new containers in it.

Add Docker Registry
It would be useful to add Docker or own repositories to Rancher.
Let's see how easy it is to add a DockerHub.
Click on the name of your user in the Rancher control panel and then click on “Registries”.

Then click “Add Registry”.
If you don’t have access to Docker Hub,
add it here .
After that, enter the data for access.

Docker Hub repository will be successfully added.

In the next article, we will look at the functionality of Rancher in practice and deploy a set of useful services into a portable infrastructure.
How to get a trial version of InfoboxCloud for free?
Send us your email address and full name to
trukhinyuri@infoboxcloud.com , in response you will receive data to access the control panel. You can test a new cloud region for 15 days, then you need to upgrade to the full version of the cloud. You can request a free trial version until August 21, 2015.
If you have questions or comments,
write to us and we will be happy to answer. If you can not leave comments on Habré, write in the
InfoboxCloud Community .
Successful work!