Deploying Rancher in InfoboxCloud: a portable web-based infrastructure for Docker

    Docker has changed the face of the modern approach to hosting applications and user services in the clouds, introducing portable containers for applications. Portability means no vendor lock-in , cloud-based migration of applications, easy deployment, lower support and maintenance costs. With a containerized, portable application, you can focus on increasing application performance, accessibility, and other important application features. Existing technologies like Kubernetes, Swarm, Panamax, Helios, Clocker, Dies, etc. Develop technology on top of Docker and make a significant contribution to the development of the ecosystem.



    Rancherfocuses on a completely different issue. Imagine you are deploying an application in Docker in the cloud. The infrastructure is portable, but service services such as fail-safe load balancers and other solutions are not. If you need to migrate to another cloud where this functionality differs, problems will arise. Rancher

    Target- Creation of portable infrastructure services around Docker, including flexible block storage, virtual networks, fail-safe load balancer, security groups, monitoring, database services and much more. You can transfer all this between your own servers and clouds of various manufacturers, use several regions of the cloud provider at the same time. And since there is no dependency at the infrastructure level, you can choose a cloud based on the ratios of reliability, performance, price and trust.

    By the way, Rancher source code is available under the Apache 2.0 license.

    In this article, we will take a closer look at the Rancher infrastructure and install 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:
    Using Docker and not worrying about vendor-lock.
    Diving into the Docker: Dockerfile and communication between containers.
    Overview of Docker Engine innovations from 1.0 to 1.7. Introduction to Docker Compose


    Key features


    1. Private networks . Ability to create private SDN networks for each environment, allowing secure communications between containers between hosts and clouds.
    2. Load balancing . Built-in elastic load balancer to distribute traffic between containers or services. The load balancing service can work even between different regions of the cloud.
    3. Storage management . Support for snapshots and backups of Docker volumes, the ability to backup the status of containers and the status of services.
    4. Service discovery . Distributed DNS discovery service with built-in health monitoring, which allows containers to automatically register themselves as services and dynamically find others on the network.
    5. Service upgrades . The ability to easily upgrade services using cloning and redirecting service requests. This allows you to check the updated service before sending traffic to it.
    6. Resource management . Support for Docker Machine, a host provisioning tool. Ability to monitor host resources and manage container deployment.
    7. Sharing and user management . The ability to create multiple infrastructure users and work together to support the service life cycle. 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:
    1. Users can work with Rancher using the Docker CLI and API. Rancher is not another layer of orchestration and control that hides Docker functionality from users. The Docker platform is constantly evolving and the wrapper layer would not keep up with the new Docker features. Rancher runs in the background and users can continue to use the native Docker Command Line Interface and Compose templates. Rancher uses labels - a feature of Docker 1.6 to transfer additional information through the Docker CLI. This opportunity was developed by Rancher Labs and it was included in Docker.
    2. Users can interact with Rancher using the rancher-compose command-line utility . This utility allows users to run many containers and services that are based on docker-compose and the Rancher infrastructure. Rancher – compose supports the docker-compose.yml format. Optionally, the rancher-compose file can be expanded using service definitions.
    3. Users can interact with Rancher using the Rancher UI . In it, you can perform configuration tasks, such as setting access control, managing environments, adding docker registries. Rancher UI is a simple and intuitive way to manage your infrastructure and services.


    Install Rancher in InfoboxCloud


    What InfoboxCloud gives when used with Rancher
    In this scenario, InfoboxCloud will allow you to create the required number of cloud servers in St. Petersburg , Moscow or Amsterdam for the configurations that are required specifically 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 with triple replication and scheduled automatic backups . The entire disk subsystem is accelerated by Enterprise SSD caching on PCI – Express SSDs and Datacenter SSDs. Availability of servers via SLA - 99.99% per year.

    Use the clouds because they successfully solve your problems at affordable prices., and not because there’s nowhere else to go.

    Rancher is deployed as a set of Docker containers (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 can work in highly accessible configurations, but we will consider them in future articles.

    System requirements

    • We recommend using Rancher with CentOS 7 and Docker.
    • The management server requires 1Gb of RAM.


    Install Rancher Server

    How to create a server for Docker in InfoboxCloud
    If you do not have access to InfoboxCloud yet - order it .

    Using the cloud is very convenient because there is no monthly fee. When registering, you replenish your account at least 500 rubles at a time (similar to buying a sim-card from a mobile operator) and then you can use the cloud as needed. You can quickly calculate how much a cloud server will cost you per month here(specify the correct dimensions, for example 2 gigahertz of frequency, and not 2000 gigahertz). Payment is made on an hourly basis and is frozen in your account. Using auto-scaling or changing the amount of available server resources manually, you can only pay for the necessary resources and save more 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.ru

    In 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 necessary server parameters. Be sure to select 1 public IP address for the server and check the box.“Allow OS kernel control” as shown in the screenshot below.


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


    After that, the data for accessing the server will be sent to you by e-mail.

    After creating the 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 does the script do
    1. Updates the OS.
    2. Stops postfix and prohibits its autostart. Postfix occupies port 25, but your services in docker may need this port.
    3. Adds the official Docker repository and installs docker-engine.
    5. Adds the EPEL repository, installs pip, installs Docker Compose with pip.
    6. Starts the Docker service and adds it to startup.

    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/
    


    Go to the user directory:
    cd ~
    

    Download the compose Rancher Server deployment file:
    curl -O http://repository.sandbox.infoboxcloud.ru/scripts/rancher/centos7-docker/docker-compose.yml
    

    Finally, launch the Rancher Server deployment:
    docker-compose up -d
    

    After deployment, you can go to the server at:
    ip–адрес-сервера:8080
    




    It is recommended to direct the A domain record to the Rancher server, which will be used with Rancher, so as not to change authorization keys in the future in the domain direction 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 before Rancher).

    Configure access control


    Access control is necessary for Rancher to limit the number of users who have access to your Rancher servers. The first account that has configured authentication in Rancher becomes an administrator account. Only administrators have rights to view access control settings and register hosts. In addition, administrators have the right to view all environments in the installation, even if they were not added as members of the environment.

    Enable Access Control


    Click Settings in the warning about disabled access control.



    Currently, authorization is only supported through Github , but other methods will appear in the future.

    If you don’t have an account on Github yet, register and log in.

    Click on the icon for your account in the upper right of GitHub and go to the Settings section.



    Go to the “Applications” section and click “Developer Applications”. In this section, click “Register New Application”.



    Fill in the fields:
    • application name - specify anything so that you understand that it is a Rancher.
    • homepage URL - address of the installed Rancher Server (domain or ip – address)
    • Application description - any Rancher description
    • Authorization callback URLs are listed on the Settings page in the Rancher Server that we opened earlier.




    After that click on “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 opens, on which 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 of the Site Access section, click Customize .



    You can specify a person’s or organization’s account on Github and add it to the Rancher user list.



    Added users will be able to create environments and you can allow them to work on existing environments.

    Add host


    On hosts, containers and services will work directly. It is recommended that the host 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 them 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 InfoboxCloud
    In 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 necessary server parameters. Be sure to give the server 1 public IP address and check the box “Allow OS kernel control” , as shown in the screenshot below.



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



    After that, the data for accessing the server will be sent to you by e-mail.


    Install the script on the Docker server:
    bash <(curl -s http://repository.sandbox.infoboxcloud.ru/scripts/docker/centos7/install.sh)
    


    In order to save money during testing, you can use the same server where Rancher Server is installed.

    To add a host to Rancher, go to the "Infrastructure" section and click " Add Host ".



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



    After that, click Close and you will see a host in your infrastructure.

    If you click on this host, you will see the current resource loading schedule. In this case, the RAM is busy because we have allowed the use of Rancher Server and as a host. In the InfoboxCloud control panel, you can simply add RAM to the server and there will be more resources.



    Add a few more hosts to the Rancher Server in different regions. Just create a server in the desired region with CentOS 7 and the “Enable OS kernel management” checkbox selected, 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 prevent the creation of new containers in it.



    Add Docker Registry


    It will be useful to add Docker repositories or your own to Rancher.
    Let's see how easy it is to add a DockerHub.

    Click on your username in the Rancher control panel and then click “Registries”.



    Then click “Add Registry”.

    If you don’t have access to the Docker Hub yet, add it here .
    After that, enter the data for access.



    The Docker Hub repository will be successfully added.



    In the next article, we will examine the functionality of Rancher in practice and deploy a set of useful services in a portable infrastructure.

    How to get a trial version of InfoboxCloud for free?


    Send us your email address and full name at trukhinyuri@infoboxcloud.com , in response you will receive data for access to the control panel. You can test the new region of the cloud for 15 days, then you need to switch to the full version of the cloud. You can request a free trial by August 21, 2015.

    If you have questions or comments, write to us and we will be happy to answer. If you cannot leave comments on Habré, write in InfoboxCloud Community .

    Successful work!

    Also popular now: