[Cloud native] rancher of k8s graphical management tool

foreword


In the previous k8s basic learning, we learned the collocation and use of various resources, as well as command line and declarative file creation. These are for k8s administrators to experience the framework and content foundation of k8s. In a real production environment, most companies still use graphical management tools to manage k8s clusters, which greatly improves work efficiency. 

 When building a k8 cluster in binary, we know that k8s itself has a native k8s cluster management tool, but the native graphical management tool dashborad only has the ability to manage one cluster. For modern productivity companies, there are still too few things that a cluster can do, so we need to introduce more powerful cluster management tools. Rancher kubesphere k9s is more commonly used in the market. This time we mainly introduce the functions of rancher and its construction.
 

 1.  Rancher related knowledge

1.1 Introduction to Rancher 


 Rancher is an open source enterprise-level multi-cluster Kubernetes management platform, which realizes the centralized deployment and management of Kubernetes clusters in hybrid cloud + local data center to ensure the security of clusters and accelerate the digital transformation of enterprises. More than 40,000 businesses use Rancher to innovate rapidly every day. 
 

  1.2 The relationship and difference between Rancher and k8s


 The relationship between Rancher and K8s, the difference between Rancher and K8s. In simple terms, K8s (Kubernetes) provides enterprises with a consistent way to manage any computing infrastructure, and Rancher is a complete platform for managing Kubernetes clusters located in any location. If users manually deploy K8s clusters by themselves, the process is still relatively complicated and requires certain technical knowledge. Therefore, in order to simplify Kubernetes operations, some Kubernetes management platforms have emerged, such as Rancher. 

Rancher perfectly solves the problem of Kubernetes users installing and configuring Kubernetes clusters. Users can define cluster configuration as code, and Rancher will build and expand Kubernetes on any infrastructure through the Kubernetes distribution and configuration engine RKE. 

 

The biggest difference between k8s and Rancher:

Both Rancher and k8s are used as container scheduling and orchestration systems. But rancher can not only manage application containers, but more importantly, it can manage k8s clusters. The bottom layer of Rancher2.x is based on the k8s scheduling engine. Through Rancher's packaging, users can easily deploy containers to k8s clusters through Rancher without being familiar with the concept of k8s.

1.3 Advantages of Rancher 


Simplify the Kubernetes learning curve and drive enterprises to adopt Kubernetes to
quickly build, integrate, and automate CI/CD pipelines
Manage complex microservice applications
Provide a Helm-based application store to create a one-stop application deployment
Best practices for cluster monitoring and cluster security
Build and run Kubernetes clusters on any cloud, VMware cluster, or physical machine

 

 2. Installation and deployment of Rancher

 

 2.1 Experimental Environment and Deployment Map Assignment


Prepare at least one k8s cluster deployed in binary or other ways, and prepare an initialized virtual machine (implementing docker installed and warehouse sources adjusted) as a rancher server machine.

Rancher node/rancher 192.168.73.108
 control node/master01 192.168.73.105
working node/node01 192.168.73.106
working node/node02 192.168.73.107
 

 

2.2 Specific deployment operations 

(1) Download the rancher image on the rancher node

docker load -i rancher.tar
 
#If you have not downloaded the image tar package in advance, you can also directly pull the image
docker pull rancher/rancher:v2.5.7

(2) Download the rancher-agent image on all k8s node nodes 

#Upload the rancher-agent:v2.5.7 package to the master, and pass it to other nodes
scp rancher-agent:v2.5.7 [email protected]:`pwd`
scp rancher-agent:v2.5.7 [email protected]:`pwd`
#Pull the local image
docker load -i rancher-agent:v 2.5.7
 
 
 
#If there is no local image, use each node host to pull the official image
docker pull rancher/rancher-agent:v2.5.7

(3) Start the rancher image on the rancher host and map the port 

docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged --name rancher rancher/rancher:v2.5.7
#--restart=unless-stopped indicates that the container is always restarted when the container exits, but does not consider containers that have stopped when the Docker daemon starts
 
docker ps -a|grep rancher

 (4) Perform client login rancher 

 

 

 

(5) Rancher manages existing k8s clusters 

Select [Add Cluster], click [Import]
[Cluster Name] is set to k8s-cluster, click [Create]
and select to copy the third command to bypass the certificate check and import the k8s cluster 

 

 

 

Execute the copied command on the k8s control node master01. If an error is reported for the first execution, execute it again

curl --insecure -sfL https://192.168.73.108/v3/import/c7kj7vrz6rzn899pwdzmcbw89sv5bcnhlmk8s2j2h4s894sdjth6gt_c-g2b75.yaml | kubectl apply -f -

kubectl get pods -n cattle-system -o wide
 

 

3. Basic operations of the Rancher graphical interface 

3.1 Rancher deployment monitoring system

 Click [Enable Monitoring to view real-time monitoring]
[Monitoring component version] select 0.2.1, other defaults can be
clicked [Enable Monitoring], it may take a long time to start monitoring, and it takes about 10 minutes

 

 

 

3.2 Use the Rancher dashboard to manage k8s clusters 


Take creating nginx service as an example, click [Dashboard] to enter the k8s cluster dashboard interface 

(1) Create a namespace namespace 
 Click on the left menu [Namespaces], then click on the right [Create] [
Name] enter dev, [Description] is optional and can be customized
Click on the lower right corner [Create]

 

 

 

 (2) To create a Deployment resource 
 , click [Deployments] on the left menu, and then click [Create] on the right [
Namespace] drop-down select dev, [Name] enter nginx-dev, [Replicas] enter 3 and click the
middle option [Container], [Container Image] enter nginx:1.14, [Pull Policy] select IfNotPresent,
click [Add Lable] under [Pod Labels], [Key] enter app, [Value] Enter nginx and click the
middle option [Labels and Annotations], click [Add Label], [Key] enter app, [Value] enter nginx and click [Create] in the lower right
corner

 

 

 

 

 

(3) To create a service, 
 click [Services] on the left menu, then click [Create] on the right, click [
Node Port],
[Namespace] pull down and select dev, [Name], enter nginx-dev,
[Port Name], enter nginx, [Listening Port], enter 80, [Target Port], enter 80, [Node Port], enter 30180, and click the middle option [Selectors], [Key], enter app, [Value], enter nginx and click [Create] in the lower right corner Click [nginx-dev] to check whether the service is associated
with
the
Pod

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/zhangchang3/article/details/131796053