ubuntu Docker installation and deployment of Rancher

1. Introduction to Rancher

Rancher is an open source enterprise-level container management platform. With Rancher, companies no longer need to use a series of open source software to build the [Container Service] (https://cloud.tencent.com/product/tke?from=10680) platform from scratch. Rancher provides a full-stack container deployment and management platform for managing Docker and Kubernetes used in the production environment. It mainly includes service management, public cloud node management, support for third-party user rights management, application store, api is very flexible, but there are fewer documents, so you can refer to official documents more.

Chinese document: https://www.rancher.cn/docs/

Rancher structure

1、 Infrastructure Orchestration

Rancher can use Linux host resources of any public cloud or private cloud. The Linux host can be a virtual machine or a physical machine. Rancher only needs the host computer to have CPU, memory, local disk and network resources. From Rancher's perspective, a cloud host provided by a cloud vendor is the same as a physical machine of its own.
Rancher implements a layer of flexible infrastructure services for running containerized applications. Rancher's infrastructure services include network, storage, [load balancing] (https://cloud.tencent.com/product/clb?from=10680), DNS and security modules. Rancher's infrastructure services are also deployed through containers, so Rancher's infrastructure services can also run on any Linux host.

2、 Container Orchestration and Scheduling

Many users will choose to use the container orchestration framework to run containerized applications. Rancher includes all current mainstream orchestration and scheduling engines, such as Docker Swarm, Kubernetes, and Mesos. The same user can create a Swarm or Kubernetes cluster. And you can use native Swarm or Kubernetes tools to manage applications.
In addition to Swarm, Kubernetes and Mesos, Rancher also supports its own Cattle container orchestration and scheduling engine. Cattle is widely used for orchestrating Rancher's own infrastructure services and for the configuration, management and upgrade of Swarm clusters, Kubernetes clusters and Mesos clusters.

3、 app Store

Rancher users can deploy applications composed of multiple containers in the application store with one click. The user can manage the deployed application, and can automatically upgrade the application when a new version is available. Rancher provides an application store maintained by the Rancher community, which includes a series of popular applications. Rancher users can also create their own private application stores.

4、 Enterprise level authority management

Rancher supports flexible plug-in user authentication. Support Active Directory, LDAP, Github and other authentication methods. Rancher supports role-based access control (RBAC) at the environment level. You can configure the access permissions of a user or user group to the development environment or production environment through roles.

The following figure shows the main components and functions of Rancher:

Features of Rancher

1、 Graphical method

The easy-to-use web management interface, based on the ease of use of Docker, once again reduces the difficulty of deploying container applications using container technology.

2、 Support multiple schedulers

Through the environment template, it is easy to create and deploy Cattle, Swarm, K8S, Mesos container cluster management scheduling platform.

3、 Manage host cluster

The management object is a cluster of multiple hosts, not just a single container host. To create and manage a few or dozens of application server clusters, you only need Ctrl+C, Ctrl+V, and copy and paste.

4、 Built-in application store

Use one of the WordPress templates to create a WordPress blog system with just a few clicks of the mouse, and deployment is no more difficult than applying for a free email address!

5、 Flexible resource allocation

Built-in application load balancer, "service" requires only 1 container instance at least. When the load is insufficient/or excessive, just click the mouse to increase/decrease the number of container instances in the "service" to solve the problem. The application system has Innate flexible capacity expansion.

Second, install Rancher server

For hardware requirements, please refer to the official link:

https://www.rancher.cn/docs/rancher/v2.x/cn/install-prepare/requirements/

Environment introduction

Operating system ip docker version role
ubuntu-16.04.4-server-amd64 192.168.10.104 Docker 18.09.2 rancher-server
ubuntu-16.04.4-server-amd64 192.168.10.108 Docker 18.09.2 rancher-agent

**Note: 2 servers have already installed docker! **

Install Rancher host

Before installing the server, let's configure Alibaba Cloud's docker image acceleration address, otherwise the download of the image will be very slow:

vim /etc/docker/daemon.json

The content is as follows:

{" registry-mirrors":["https://xwx6wxd1.mirror.aliyuncs.com"]}

Reload docker

/etc/init.d/docker reload

Create database mount directory

mkdir -p /data/rancher_server/mysql

External database data is recommended. Even if the container is broken, the data is still there, just rebuild another container

docker run -d -v /data/rancher_server/mysql:/var/lib/mysql --restart=always -p 8080:8080 rancher/server

Check the operation

root@ubuntu:~# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
27 e65bb6ae54        rancher/server      "/usr/bin/entry /usr…"45 minutes ago      Up 45 minutes       3306/tcp,0.0.0.0:8080->8080/tcp   hopeful_rosalind

View log

root@ubuntu:~# docker logs -f fbac96ddb14c
Running mysql_install_db......
time="2019-09-03T07:33:40Z" level=info msg="Listening on :8090" time="2019-09-03T07:33:43Z" level=info msg="Waiting for machinedriver.activate event" service=gms 
...

When Listening on: 8090 appears, it means the startup is successful

View rancher service listening port

root@ubuntu:~# netstat -antupl | grep 8080
tcp6       00:::8080:::*                    LISTEN      5563/docker-proxy

Access test

http://192.168.10.104:8080

The effect is as follows:

Click Deutsch in the lower right corner, select language, select Chinese

The Chinese effect is as follows:

Three, Rancher server configuration

Add account

When logging in for the first time, the access authority has not been configured. For the sake of security, first click System Management-->Access Control above to create a local account and password.

Select Local, enter the user name and password

Click Enable local verification.

Prompt is already enabled

Four, add host

Click Infrastructure-->Host

Add host

Click save directly

copy this command

Log in to the machine 192.168.10.108, which is rancher-agent

Before installing the agent, let's configure Alibaba Cloud's docker image acceleration address, otherwise the download of the image will be very slow:

vim /etc/docker/daemon.json

The content is as follows:

{" registry-mirrors":["https://xwx6wxd1.mirror.aliyuncs.com"]}

Reload docker

/etc/init.d/docker reload

Run the join command, note: each environment, the command is different. Please focus on page display.

sudo docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.11 
http://192.168.10.104:8080/v1/scripts/89EA1D52A25C98723969:1546214400000:XODniKMfCrisNwBj3gF24syj0

Click on Infrastructure-->Host on the page again, and you will see the newly added host

Note: The agent-1 node has been added successfully! Add a few nodes as many as there are. The method of adding nodes is the same as that of agent-1, so I won't say much, but when executing the command, it is on the node host with different ip! Remember that the rancher registration script generated by each click to add host is limited to one node, and multiple nodes cannot reuse a script.

Five, add container

Create a nginx container to test it, click Infrastructure-->Container

Click to add container

Enter the name, mirror name, and port number

The following, basically, remain unchanged and click Save.

Wait 30 seconds, the container is up and running

Log in to the agent server and view the nginx process.

root@ubuntu:~# docker ps|grep nginx
26478 f808e4e        nginx:latest                      "/.r/r nginx -g 'dae…"2 minutes ago       Up 2 minutes                            r-nginx-6d0e2e27

Use agent ip and port 80 to access the page

http://192.168.10.108/

The effect is as follows:

6. Use of Rancher App Store

Rancher's application store is its core function. Through the application store, only 2 steps of interface operations can be completed to complete the deployment of an application.

Click on the App Store, here is the deployment of Alfresco as an example, click to view details

Keep the default parameters, click start

Wait a few minutes, it will become Active, click port 8080, a new window will open

The effect of the new window is as follows:

Note: If it is the first time to create the image, it will take a few minutes for the agent to download the image, depending on the network speed.

I believe smart friends have guessed it. In addition to the official apps in the app store, we can also configure our app store. A new test service will be temporarily deployed in the future, and it will be solved in 2 steps directly.

More

In addition to these basic functions, rancher has many functions. The basic ones include container log viewing, shell access, resource occupancy monitoring, etc., and the extended ones include multi-environment management and multi-host service deployment management. At the same time, various operations of the container can also be controlled through the rancher-cli, rancher-compose command line tool or its own http api.

To expand, you can also use the container to replace +http api call to quickly reset the database data (data content of the database is placed in the mirror in advance). This can save a lot of time for initializing data for some operations that often need to clear-reinitialize the database (such as resetting the database before running automated tests). At the same time, the database data is also initially obtained version management through mirror version management.

Reference link for this article:

https://blog.51cto.com/13043516/2299949

https://www.cnblogs.com/YatHo/p/7851758.html

Recommended Posts

ubuntu Docker installation and deployment of Rancher
Installation and deployment of Nginx in Ubuntu
Centos6.5 installation and deployment of KVM
Installation of Docker CE under Ubuntu
Ubuntu installation and deployment Redash operation notes (2020.08)
Centos-6.5 installation and deployment of LNMP environment
Centos7 installation and deployment of gitlab server
Installation and uninstallation of CUDA under Ubuntu 16.04
Installation and use of Win10 subsystem Ubuntu
Centos7 installation and deployment of Airflow detailed
Ubuntu introduction and installation
Installation of pulseaudio and API usage under Ubuntu 12.04
Installation, configuration and uninstallation of GitLab in Ubuntu19.1
Installation and use of SSH in Ubuntu environment
Ubuntu16.04 installation and simple configuration
Installation and use of GDAL in Python under Ubuntu
Ubuntu deployment and experience Nexus3
Installation and simple practice of MySQL in ubuntu environment (1)
CentOS environment installation of Docker
One, docker into the pit (win10 and Ubuntu installation)
Installation and usage instructions of rz/sz command under ubuntu
Ubuntu PostgreSQL installation and configuration
Centos8 minimal deployment and installation of OpenStack Ussuri detailed tutorial
Centos7 installation and configuration of Jenkins
Happy installation of Jenkins in ubuntu
Installation of deb package under Ubuntu
CentOS7 installation and maintenance of Gitlab
Install and configure Docker in Ubuntu
Redis installation under ubuntu and windows
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
Nginx installation and configuration load (ubuntu12.04)
CentOs7 installation and deployment Zabbix3.4 original
2-Kubernetes entry manual installation and deployment
Ubuntu18.04 installation Anaconda3 and VSCode guide
Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04
Erlang 20.2 installation and deployment under CentOS 7
Ubuntu configuration source and installation software
Docker CE for Ubuntu installation notes
JumpServer Bastion Host--CentOS 8 Installation and Deployment (4)
Detailed explanation of quick installation and configuration of Subversion (SVN) under Ubuntu
Detailed explanation of the installation and use of SSH in the Ubuntu environment
Ubuntu basic settings: introduction to the installation and use of openssh-server
Installation and use of Mysql under CentOS
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Ubuntu18.04 system installation and prerequisite software installation guide
Installation and configuration of redis under centos7
Install docker on ubuntu and basic usage
Ubuntu18.04 Server version installation and use (graphic)
The implementation of the Ubuntu18.04 installation Pycharm tutorial
Zabbix installation and deployment and localization under CentOS
n1. Docker installation and operation exceptions encountered
Jenkins installation and deployment tutorial under CentOS 7
Ubuntu 14.04 16.04 Linux nvidia driver download and installation
Linux install Docker and run Ubuntu system
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Installation and configuration of JDK in CentOS 7 system
UBUNTU 16.04 installation diary
Production environment deployment of ubuntu Django + Uwsgi + Nginx
Debian and Ubuntu installation source configuration file description
ubuntu18.04 install docker