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 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.
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.
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.
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:
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.
Through the environment template, it is easy to create and deploy Cattle, Swarm, K8S, Mesos container cluster management scheduling platform.
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.
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!
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.
For hardware requirements, please refer to the official link:
https://www.rancher.cn/docs/rancher/v2.x/cn/install-prepare/requirements/
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! **
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:
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
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.
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:
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.
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