当前位置:网站首页>[cloud native • Devops] master the container management tool rancher
[cloud native • Devops] master the container management tool rancher
2022-07-27 09:43:00 【Developer pony】
Learning objectives in this chapter :
- Master container management tools Rancher Installation and use of ;
- Mastery is based on Rancher Application deployment 、 Expansion and contraction operation .
Catalog
One 、 Container management tools Rancher Introduce
3、 ... and 、Rancher The initialization
One 、 Container management tools Rancher Introduce
Rancher Is an open source enterprise level full stack container deployment and management platform , It's really just a Docker Graphical management interface of . It provides infrastructure services for containers , It can make CNI Compatible network services 、 Storage service 、 The host management 、 Load balancing 、 Firewall and other services span the public cloud 、 Private cloud 、 virtual machine 、 Physical machine environment operation , Truly realize one click application deployment and management . In addition, it also provides services such as load balancing 、 Advanced functions such as elastic expansion , It is also a commonly used operation and maintenance tool .
Tips : because Rancher yes Docker Interface operation , For example, application deployment and other operations are actually repeated , To avoid port conflicts , Therefore, it is recommended to operate in a new system image .
Two 、Rancher Installation
First step : download Rancher Mirror image ;
docker pull rancher/serverThe second step : establish Rancher Containers ;
docker run -di --name=rancher -p 9090:8080 rancher/serverThe third step : Local browser input virtual machine / The server IP: Port number Visit , See the following interface Rancher Installation successful ;
If you can't access it, check whether the container you created has been started .

The initial interface is English , You can switch Chinese in the lower right corner ;

3、 ... and 、Rancher The initialization
1. Add environment
Rancher Support grouping resources into multiple environments , Each environment has its own independent infrastructure resources and services , And by one or more users 、 The team / Organizational management . for instance : You can create independent development 、 Test and production environment and ensure safe isolation between these environments , Grant access to the development environment to all personnel , The test environment allows only a small team to access .
Click on “Default” --> “ Environmental management ”, Enter the environment interface ;

Click on “ Add environment ”, Enter the environment name and description to create ;

The following is the development I created 、 production 、 Test environment , Each environment is completely separate , The configuration of the environment will not affect each other ;

Choose “Default” You can switch between environments ;

2. Add host
choice “ Infrastructure ” --> “ host ”, Click Add host ;

The default choice is our virtual machine / The site address of the server , Click save ;

Then you will enter the following interface ;
Notice the code in step 5 , This code means to create a Rancher Proxy container , When you need to add Rancher Virtual machines for services / Run this command on the server , Then the virtual machine / The server will communicate with Rancher Services build connections .

Copy the code , When you need to connect Rancher Virtual machines for services / Running on the server , The successful operation is as follows ;

At this time in Rancher The host interface of will add a host ;

3. Add application
The application here actually refers to one of our projects , And there are many services under a certain project , In other words, an application is actually a grouping of services ;
Click on “ application ” --> “ All / user ”, And then click “ Add application ” Button ;

Enter the name and description and click “ establish ”;

The success is as follows ;

After the application is created successfully , You can deploy services on the application , That is, application deployment .
Four 、 Application deployment
Actually in Rancher Central deployment application and traditional methods ( Command line operations ) The biggest difference is that all operations here are carried out in the graphical interface , More intuitive , Please see the following deployment demonstration .
1. Mysql Deploy
Download Image first centos/mysql-57-centos7 Add database services ;
[[email protected] ~]# docker pull centos/mysql-57-centos7
Using default tag: latest
latest: Pulling from centos/mysql-57-centos7
d8d02d457314: Pull complete
a11069b6e245: Pull complete
596303fb1aa3: Pull complete
a29499e779a7: Pull complete
17d1a52c2e00: Pull complete
ed24591227fe: Pull complete
de0ad46e3ed9: Pull complete
c62e4a984a9c: Pull complete
01d54c6bda68: Pull complete
Digest: sha256:e08ee4d43b7356607685b69bde6335e27cf20c020f345b6c6c59400183882764
Status: Downloaded newer image for centos/mysql-57-centos7:latest
docker.io/centos/mysql-57-centos7:latest
[[email protected] ~]#
Then in the application we created , Click on “ Add service ”;

At this point, it can be deployed in the form of a graphical interface MySQL Yes , Make relevant settings ;


Click on “ establish ”, Show “Active” The deployment is successful ;

2. RabbitMQ Deploy
Download mirroring rabbitmq:management;
[[email protected] ~]# docker pull rabbitmq:management
management: Pulling from library/rabbitmq
7b1a6ab2e44d: Pull complete
37f453d83d8f: Pull complete
e64e769bc4fd: Pull complete
c288a913222f: Pull complete
12addf9c8bf9: Pull complete
eaeb088e057d: Pull complete
b63d48599313: Pull complete
05c99d3d2a57: Pull complete
43665bfbc3f9: Pull complete
f14c7d7911b1: Pull complete
Digest: sha256:4c4b66ad5ec40b2c27943b9804d307bf31c17c8537cd0cd107236200a9cd2814
Status: Downloaded newer image for rabbitmq:management
docker.io/library/rabbitmq:management
[[email protected] ~]#
Add service , Set relevant properties and port mapping ( Include port 5671 5672 4369 15671 15672 25672);

The successful deployment is as follows ;

Access in browser virtual machine / The server IP:15672;

RabbitMQ Installation successful .
3. Redis Deploy
Download mirroring redis;
[[email protected] ~]# docker pull redis
Using default tag: latest
latest: Pulling from library/redis
a2abf6c4d29d: Pull complete
c7a4e4382001: Pull complete
4044b9ba67c9: Pull complete
c8388a79482f: Pull complete
413c8bb60be2: Pull complete
1abfd3011519: Pull complete
Digest: sha256:db485f2e245b5b3329fdc7eff4eb00f913e09d8feb9ca720788059fdc2ed8339
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
[[email protected] ~]#
Add service , Set relevant properties and port mapping ( port 6379);

The successful creation is as follows ;

Open the local Redis terminal , Input redis-cli -h virtual machine / The server IP Connect , The following can operate normally ,redis Deployment success ;

Four 、 Expand and shrink
Capacity expansion is to expand the number of containers , Shrink volume vice versa . In the actual operation and maintenance process , The container needs to provide a back-end support for the website , When the website access is high, more containers are needed to form the container's Micro service cluster , To reduce the bearing pressure . If the traffic is not so high , You can shrink the volume and release more space .
1. Capacity expansion
Select application , Add a new service base-service, But do not set port mapping , After creation, it defaults to a container ;

Click here “API” --> “WebHooks”;

Enter the add receiver interface , Select Add receiver , as follows ;

After selecting parameters , Click Create , At this point, a receiver is created for the service ( Expansion and contraction Services );

In fact, the receiver is configured with URL, This URL It mainly uses post Way to trigger , It's an interface , So that a certain software can call through this address Rancher,Rancher Trigger after receiving , Then carry out the corresponding expansion and contraction operation .
Return to the service page , You can see that the number of containers for the service is 1;

Copy receiver trigger address ( Interface ), Use the local interface test tool to call the address ( I'm using ApiPost) Click Send ;

At this point, the number of containers for the service will automatically increase .
2. Shrinkage capacity
The operation of capacity reduction is the same as that of capacity expansion , No more details here .
5、 ... and 、 Load Balancer
When using expansion and reduction services , We do not set port mapping , Then there is no way to access the service directly , To solve this problem ,Rancher Provides a load balancer . When you want to access a service without port mapping , You need to add load balancing to this service .
Click on “ Add service ” --> “ Add load balancing ”;

Input port and target information , Create ; At this point, we can access our services through the special services of the load balancer .
边栏推荐
- July training (day 09) - two point search
- S交换机堆叠方案配置指南
- Binary tree traversal
- 七月集训(第08天) —— 前缀和
- July training (the 26th day) - and check the collection
- Vscode uses remote SSH connection and the solution of connection failure
- 七月集训(第11天) —— 矩阵
- 年底了,我教你怎么拿高绩效!
- Understand chisel language. 23. Chisel sequential circuit (III) -- detailed explanation of chisel shift register
- 一骑入秦川——浅聊Beego AutoRouter是如何工作
猜你喜欢

Understand chisel language. 26. Chisel advanced input signal processing (II) -- majority voter filtering, function abstraction and asynchronous reset

I grabbed a ticket and thought I found the system bug of 12306

语音直播系统——开发推送通知需要遵守的原则

c'mon! Please don't ask me about ribbon's architecture principle during the interview
![[untitled]](/img/03/dcea9137dc9948e3121333c684ec8f.png)
[untitled]

Talk about 10 scenarios of index failure. It's too stupid

拟搬迁!211中国石油大学(华东)新校区,正式启用!

基于 FPGA 按键控制呼吸灯原理、仿真及验证全过程

刷题《剑指Offer》day03

Vscode uses remote SSH connection and the solution of connection failure
随机推荐
ESP8266-Arduino编程实例-PWM
July training (day 16) - queue
July training (day 04) - greed
七月集训(第10天) —— 位运算
Lua函数嵌套调用
给自己写一个年终总结,新年快乐!
材料工程基础-重点
食品安全 | 无糖是真的没有糖吗?这些真相要知道
A ride into Qinchuan -- a brief talk on how beego Autorouter works
快应用JS自定义月相变化效果
刷题《剑指Offer》day04
工程材料知识点总结(全)
Understand chisel language. 23. Chisel sequential circuit (III) -- detailed explanation of chisel shift register
Meeting seating function of conference OA project & Implementation of meeting submission for approval
吃透Chisel语言.26.Chisel进阶之输入信号处理(二)——多数表决器滤波、函数抽象和异步复位
[cloud native] how can I compete with this database?
July training (day 06) - sliding window
Understand chisel language. 26. Chisel advanced input signal processing (II) -- majority voter filtering, function abstraction and asynchronous reset
七月集训(第18天) —— 树
Fundamentals of Materials Engineering - key points
