ic_banknote_smile_128ic_business_128ic_checkmark_128ic_client_team_manager_128ic_code_file_128ic_code_files_128ic_corporate_cloud_platforms_128ic_crossplatform_apps_128ic_developer_128ic_development_team_128ic_enterprise_128ic_faster_timeframe_128ic_graph_down_128ic_information_finder_128ic_junior_developer_128ic_managed_team_128ic_message_128ic_mobile_app_startups_128ic_mobile_development_128ic_mobile_development_up_128ic_mobile_devices_128ic_multiplatform_128ic_multiplatform_white_128ic_pricetag_128ic_project_checklist_128ic_project_management_128ic_project_management_team_128ic_research_and_development_team_128ic_scalable_team_128ic_senior_developer_128ic_smaller_codebase_128ic_smaller_price_128ic_startup_128ic_team_manager_128ic_three_times_faster_128K&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxK&C_Icons_32pxArrow_Dropdownic_001_google+_16ic_002_xing_16Group 2ic_003_facebook_16ic_004_linkedIn_16Groupic_005_message_16ic_006_upload_16ic_007_remove_16ic_008_email_16ic_009_attachment_16ic_010_file_16ic_011_name_16ic_012_arrow_left_16ic_013_arrow_right_16ic_014_arrow_down_16ic_015_arrow_up_16ic_016_dropdown_arrow_down_16ic_016_dropdown_arrow_leftic_016_dropdown_arrow_rightic_017_K&C_dropdown_arrow_up_16ic_018_language_16ic_019_Quote_16ic_020_+_16ic_021_=_16ic_022_phone_16ic_023_twitter_16ic_024_position_16ic_025_company_16ic_026_search_16ic_027_mobile_16ic_028_fax_16ic_029_location_16ic_030_enlarge_16ic_031_downscale_16ic_032_contactic_download_normal_16pxic_033_skype_16ic_006_download_16 copyic_Interest_based_64ic_acrivate_card_64ic_api_client_64ic_application_architecture_64ic_application_architecture_ white_64ic_application_development_user_64ic_arrow_down_64ic_automated_backups_64ic_automated_infrastructure_provisioning_64ic_automated_infrastructure_provisioning_white_64ic_automated_storage_64ic_automated_storage_64ic_automation_64ic_avaliability_across_the_world_64ic_avaliability_across_the_world_white_64ic_brackets_64ic_brackets_64ic_build_64ic_build_64ic_business_64ic_business_partnership_64ic_business_partnership_white_64ic_business_64ic_calculator_64ic_calendar_64ic_car_rent_64ic_card_renewal_64ic_chat_64ic_chat_bubbles_64ic_chat_bubbles_64ic_chat_white_64ic_checklist_64ic_checkmark_64ic_checkmark_white_64ic_clock_64ic_clock_white_64ic_cloud_media_64ic_cluster_64ic_cluster_white_64ic_code_base_optimization_64ic_coding_64ic_coding_white_64ic_commenting_widget_64ic_commenting_widget_64ic_containers_64ic_containers_white_64ic_continious_64ic_continious_delivery_64ic_continious_delivery_white_64ic_continious_release_64ic_continious_release_white_64ic_continious_white_64ic_cost_saving_64ic_cost_saving_white_64ic_cpu_load_64ic_credit_card_64ic_crossplatform_app_development_64ic_crossplatform_app_development_white_64ic_custom_crm_64ic_custom_crm_64ic_independence_consulring_64ic_database_calls_64ic_database_calls_white_64ic_dedicated_teams_64ic_dedicated_teams_64ic_desktop_application_user_64ic_desktop_application_user_64ic_desktop_code_64ic_desktop_code_white_64ic_developer_64ic_developer_white_64ic_development_64ic_devops_64ic_documents_64ic_documents_graph_64ic_documents_graph_white_64ic_documents_white_64ic_download_presentation_64ic_education_64ic_email_open_64ic_email_open_white_64ic_environment_healthcheckic_euro_64ic_euro_white_64ic_failure_solved_64ic_globe_outlines_64ic_good_quality_64ic_high_load_websites_64ic_high_load_websites_white_64ic_hotel_booking_64ic_inability_64ic_inability_white_64ic_increase_64ic_increasing_team_64ic_independence_64ic_integration_64ic_it_outsourcing_64ic_it_outsourcing_64ic_knowledge_sharing_64ic_mobile_devices_64ic_laptop_user_64ic_laptop_user_64ic_launch_64ic_launch_white_64ic_learning_64ic_learning_two_white_64ic_lighthouse_64ic_link_64ic_load_balancer_64ic_load_balancer_64ic_load_card_64ic_lock_64ic_lock_white_64ic_low_cost_64ic_low_load_websites_64ic_maintenance_tools_64ic_maintenance_tools_white_64ic_media_player_64ic_messaging_platforms_64ic_microservice_architecture_64ic_microservices_64ic_microservices_64ic_mobile_app_64ic_mobile_content_64ic_mobile_development_64ic_mobile_development_white_64ic_mobile_devices_64ic_mobile_devices_white_64ic_mobile_payments_64ic_mobile_social_media_applications_64ic_mobile_workflows_64ic_money_transfers_64ic_multimedia_sharing_64ic_multimedia_sharing_white_64ic_my_garage_64ic_no_access_64ic_no_access_white_64ic_no_oldschool_64ic_online_marketplaces_64ic_online_trading_64ic_pair_device_64ic_parallels_64ic_parallels_white_64ic_passcode_64ic_performance_64ic_performance_issues_64ic_performance_issues_white_64ic_performance_white_64ic_plane_64ic_plane_white_64ic_plus_64ic_pricetags_64ic_product_64ic_product_search_64ic_product_white_64ic_productivity_tools_64ic_productivity_tools_64ic_project_delivery_64ic_project_delivery_white_64ic_project_management_64ic_project_management_collaboration_64ic_project_management_team_64ic_project_risks_reduced_64ic_quality_mark_64ic_quality_mark_white_64ic_question_64ic_react_native_64ic_response_time_64ic_response_time_white_64ic_rest_api_64ic_retail_64ic_transparency_consulting_64ic_scale_up_64ic_scale_up_white_64ic_self_healing_64ic_self_healing_64 copyic_send_money_64ic_server_64ic_server_white_64ic_shopping_64ic_sleep_mode_64ic_small_is_beautiful_64ic_smaller_price_64ic_social_benefits_64ic_social_connections_64ic_socket_64ic_spare_parts_for_cars_64ic_spare_parts_for_cars_white_64ic_speedometer_64ic_performance_consulting_64ic_speedometer_white_64ic_startup_64ic_target_64ic_team_64ic_testing_64ic_testing_checklist_64ic_testing_checklist_64ic_testing_white_64ic_three_times_faster_64ic_touch_64ic_touch_id_64ic_touch_white_64ic_transparency_64ic_ui_design_desktop_64ic_ui_design_mobile_64ic_ui_design_mobile_white_64ic_umbrella_64ic_umbrella_white_64ic_up_and_down_scaling_64ic_up_and_down_scaling_64ic_users_64ic_users_white_64ic_ux_design_64ic_ux_design_desktop_64ic_ux_design_white_64ic_vehicle_64ic_web_based_search_64ic_web_based_search_white_64ic_web_browser_code_64ic_web_browser_developer_mode_64ic_web_browser_user_64ic_web_development_64ic_web_development_white_64ic_web_portals_64ic_web_portals_64ic_web_user_64ic_web_user_white64ic_workflow_64ic_workflow_steps_64ic_workflow_steps_white_64ic_workflow_white_64ic_working_environment_64

How to Build a Rancher & Docker Based Cloud

To build your own fail-safe cloud in your data center, you will need to remain patient as well as having basic Docker knowledge.


To build your own fail-safe cloud in your data center, you will need some basic Docker knowledge. And then you can keep calm as we are here to help. Let’s start.


We will use a considerable program stack:


- Named (round-robin) — Balancing by DNS 
- NGINX — Web server for proxying requests for a web application
- Docker — Software for automation of the application deployment and management within the virtualization environment at the operating system level
- Docker compose — A tool for starting and connecting to several Docker containers
- Docker registry — Software for storing Docker images
- Rancher — Rancher Labs develops software which allows easy deployment and management of containers within any organization operating on any infrastructure
- Rancher compose — Operates on the principle of Docker compose, serves for activation of the Rancher functions
- Consul — A utility for Service Discovery and Key/Value Storage
- Jenkins — A continuous integration tool written in Java



To build a basic infrastructure (without NA), we will need the following:


Name                 IP                               DNS
WebServer         192.168.11.140        web.cloud.infra
CloudMaster      192.168.11.72          master1.cloud.infra
CloudClient1      192.168.11.73          ci1.cloud.infra
CloudClient2      192.168.11.132        ci2.cloud.infra


* The IPs shown were taken from a real system and are required to match screen shots.

RANCHER OPERATION SCHEME

1. Setting up a local DNS

The cloud is built within our network, for which purpose a separate zone shall be created.


Edit the configuration file named

nano /etc/named/cloud.zones
zone "cloud.infra" {
        type master;
        file "/var/named/master/cloud.infra";
};

Now create a zone file:

2. Setting up a master server

nano /var/named/master/cloud.infra
$TTL    3600
@	IN	SOA     ns.cloud.infra. hostmaster.cloud.com. (
                                2015111800	; Serial
                                28800           ; Refresh
                                7200            ; Retry
                                604800          ; Expire
                                3600 )         ; Default Minimum TTL
 
                IN	NS ns.cloud.infra.
master1         A	192.168.11.72
ci1             A	192.168.11.73
ci2             A	192.168.11.132
web	        A	192.168.11.140

And restart Named

service named restart

DNS has been set up, so proceed to creating a master server

The master server will accommodate: 


- Rancher-server
- Consul-server
- Jenkins 


Start up the container with Rancher

sudo docker run -d --restart=always -p 8080:8080 rancher/server

Our Rancher server is available at http://master1.cloud.infra:8080.


Let’s set up authorization: 


1. Admin -> Access Control
2. Select LOCAL 

3. Add a new user



Set up environments:

1. Go to the tab: Default
2. Click: Add Environment
3. Select: Cattle
4. Type the name and add users 

Setting up your own registry


1. Go to the tab Infrastructure -> Registries
2. Select: Custom 
3. Insert your values 

Create an API key


1. Go to the tab: API
2. Generate and write down your values 

Let's finish with Rancher for the time being and come back to it when setting up clients


Start up the container with consul-server

docker run -d -p 8500:8500 -p 53:8600/udp  \ 
-p 400:8400 -p 8300:8300 -p 8301:8301 -p 8302:8302 \
--name=consul gliderlabs/consul-server -bootstrap

Consul is (will be) available at http://master1.cloud.infra:8500

Start Jenkins

docker run -d -p 32769:8080 jenkins

Jenkins is (will be) available at http://master1.cloud.infra:32769

3. Setting up clients

Start up two Docker containers on CloudClient1 and CloudClient2

Rancher client
- Consul registrator 



To start Rancher client, go to Rancher master:


1. Go to Infrastructure -> Hosts
2. And click: Add Host
3. Enter the external IP of the server in item 4
4. Copy the content of item (from) 5

Start up containers with Rancher and Consul on CloudClient1

sudo docker run -e CATTLE_AGENT_IP="192.168.11.73"  \ 
-d --privileged -v /var/run/docker.sock:/var/run/docker.sock \ 
-v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 \ 
http://master1.cloud.infra:8080/v1/scripts/E0EC8B33530A5512C0C7:q2qdFb3XY4
docker run -d -v \ 
/var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator \
-ip 192.168.11.73 consul://192.168.11.72:8500

Do the same on CloudClient2 but change the IP addresses

sudo docker run -e CATTLE_AGENT_IP="192.168.11.132"  \ 
-d --privileged -v /var/run/docker.sock:/var/run/docker.sock \ 
-v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 \ 
http://master1.cloud.infra:8080/v1/scripts/E0EC8B33530A5512C0C7:1473764400000:jq2qdFb3XY4
docker run -d -v \ 
/var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator \
-ip 192.168.11.132 consul://192.168.11.72:8500

If everything has been successfully completed, then we will see our servers in Rancher

* Please, ignore the launched services

4. Setting up a project

To create a project in Rancher, you need to create a docker-compose v1 file, add data obtained from the API, and download Rancher-compose.


Rancher does not collect projects from Dockerfile, but downloads them from the registry. For this reason, collect either locally or from any host


Create a homepage project:

nano docker-compose-rancher.yml
homepage:
  image: registry.cloud.infra/homepage 
  ports:
   - "3000"
  links:
   - mongo
  environment:
   - MONGO_URL=mongodb://mongo:27017/homepage-dev
   - ROOT_URL=http://localhost
   - MAIL_URL=smtp://some.mailserver.com:25
  labels:
    io.rancher.container.pull_image: always
mongo:
  image: mongo:3.2.6
  command: mongod --smallfiles
  volumes:
      - /srv/docker/homepage/mongo:/data/db
  labels:
    io.rancher.container.pull_image: always

Also, create a simple build script

nano new.sh
#!/bin/bash
 
IMAGE_NAME="registry.cloud.infra/homepage"
 
case "${1}" in
	--build | -b )  docker build --no-cache --rm -t ${IMAGE_NAME} .
		;;
	--run | -r ) docker run -d -P -t ${IMAGE_NAME}
        ;;
    --help | -h ) printf "usage: ${0} [arg]\n--build,-b\tBuild image\n--run,-r\tRun\n"
		;;
	* ) printf "Print ${0} --help for help\n"
		;;
esac

Export global variables

export RANCHER_URL='http://master1.cloud.infra:8080/v1/'
export RANCHER_ACCESS_KEY='access'
export RANCHER_SECRET_KEY='secret'

And download Rancher-compose (Link in the bottom right-hand corner in Rancher)

Add the project to Rancher

rancher-compose --file docker-compose-rancher.yml create

Start the project

rancher-compose --file docker-compose-rancher.yml up -d

If everything has been successfully completed, then we will see the following in Rancher:

We will also see the following in Consul:

5. Setting up a WEB server

Install NGINX and download consul-template

yum install nginx
wget https://releases.hashicorp.com/consul-template/0.15.0/

Create a Consul-template for NGINX

nano /etc/nginx/conf.d/homepage.ctmpl
server {
    listen 80;
    server_name homepage.cloud.infra;
    client_max_body_size 4M;
    proxy_cache            one;
 
    location / {
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        {{range service "homepage-3000" }}
        proxy_pass http://{{.Address}}:{{.Port}};{{end}}
        proxy_read_timeout 90;
        proxy_cache_valid      200  10m;
        proxy_cache_methods    GET HEAD POST;
        proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
    }
 
}

Start NGINX and consul-template

service nginx start 
consul-template \ 
-consul master1.cloud.infra:8500 \ 
-template "/etc/nginx/conf.d/nginx.ctmpl:/etc/nginx/conf.d/nginx.conf:service nginx restart"

Now, Consul-template will keep track of changes in Consul-server and rewrite data to the NGINX configurations.

6. Jenkins CI

The final tweak in our cloud is adding continuous integration. 

For this purpose, add values obtained from the API to the configuration in Jenkins

Create a Job and insert the following in the shell exec item

cd $JOB_NAME; ./new.sh -b
docker push registry/homepage
rancher-compose --file docker-compose-rancher.yml up --force-upgrade --pull --confirm-upgrade -d

P.S.

Once everything has been completed, we will have a cloud project which can be deployed by clicking on a button. The containers are up on the least loaded hosts and linked between each other via the internal Rancher network.


I have not described all the capabilities of this cloud because it takes time, but I have described the basic capabilities.


Now you can continue on your own!

SHARE WITH FRIENDS
You might find this interesting
Case Study
Bosch Classic Cars - Digital Engagement Platform for 19K Vintage Car Owners
Case Study
Liferay Portal Performance Tuning Services for a Major Online Gaming Software Supplier
Article
How to Make Your Web Solution Rock: 7 Areas to Check
Blogpost
How to Motivate Your Dedicated Team to Work with Legacy Projects
Blogpost
SEO Tips & Tricks for Single Page Web Applications
Success Story
Drivelog.de — Web Marketplace for Car Owners and Service Providers
blog post
Docker: Virtualize Your Development Environment Right
eBook
How to Secure Web Product Development — FREE eBook
blog post
When Microservices Help Make Future-Ready Products
Case Study
Portal Performance Tuning For Major German Travel Agency
case study
Micro-service Architecture for New AngularJS Application - Case Study
blog post
How We Use Ansіble for Configuration of Our Environments
blog post
DevOps with Puppet: Tips on Setting it up for Configuring Servers
blog post
How We Manage Our Infrastructure with Chef
Success Story
Fast and Lightweight Mobile Application based on PhoneGap/ Cordova
blog post
Centralized Logging with Logstash, Elasticsearch & Kibana
blog post
How the QA Team Tests Your Project
blog post
4 Time-Saving Ways to Test Your Cross Platform Mobile App
blog post
Plan to Succeed: 4 Tips for Building Scalable Software
ebook
Top Tools for Cost-Effective Web Development — eBook
Blogpost
How to start services on Linux
Blog Post
Scaling software solutions - how it works
Blog Post
Angular 2.0 vs Angular 1.4. What fits you best?
Blog Post
Reasons to believe in Ionic hybrid app
Blog Post
Debunking imaginary shortcomings of cross-platform frameworks
E-book
Determining Approaches to Mobile App Development
Blog Post
Technologies that Foster Digital Transformation
Blog Post
A Guidance for Keeping Your Web Development Project Within the Budget: Three Key Pillars
Blog Post
Agile and DevOps are Key Drivers of Digital Transformation
Blog Post
Dedicated Teams for Web Development: Choice Criteria to be Checked
Blog post
Cost efficient technologies
Blog Post
A secret formula of an agile dream team
Blog post
GoLang: Features, Pros and Cons
Blog post
K&C insights: how to make your workflow work for you
Blog post
Microservices… when do we need them?
Success Story
How to apply React Native while developing heavy cross-platform mobile apps
Success Story
Reformation of Deployment Cycle for Bosch Classic Cars Portal
Blog Post
Angular 4 vs React – what to choose in 2017
Blog post
Use case: how to build and run Docker containers with NVIDIA GPUs
Blog post
Cloud Deployment: Overview of Options
Stay tuned!
We'll gladly share fresh blog updates and our best practices to your email.
We protect your data and will notify you on important updates only.