Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy rancher2.x and create a k8s cluster in a centos7 system?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

How to deploy rancher2.x and create a k8s cluster in a centos7 system? In response to this problem, the editor summed up this article today, hoping to help more friends who want to solve this problem to find a more simple and feasible way.

Objectives of this article:

1. Deploy rancher-server UI, version 2.3.5

2. Deploy a k8s cluster crystal-cluster through rancher

3. Subordinate nginx instances on k8s cluster crystal-cluster

Several prerequisites for deployment:

1. In accordance with the official requirements, select the rancher version corresponding to the supported system version and docker version

2. Install ntp to ensure time synchronization between each server, otherwise the problem of certificate verification error may occur.

3. Turn off firewall and selinux. (if you want to turn on the firewall, if you want to release the ports required for rancher in the firewall, it is best to check the default firewall rules to ensure that the server communicates with Helm (Kubernetes's software package management tool).

4. All node servers are assigned static IP, and one DHCP should be retained to ensure that the IP assigned to the node is the same.

5. The hostname of all nodes should not be underlined "_".

(for more information, please see the official website link: https://rancher.com/docs/rancher/v2.x/en/installation/requirements/)

Description of the environment of this experiment

System version: CentOS Linux release 7.7.1908 (Core)

Docker version: 18.06.2-ce

Rancher-server version: 2.3.5 (current latest version)

Host allocation and configuration:

HostnameIPrancher role system configuration (cpu/mem) kubernets cluster role test10210.0.0.102rancher-server1C/1G without test10310.0.0.103rancher-node11C/2Getcd, Control Plane, Worktest10410.0.0.104rancher-node21C/1GWork four environment preparation

1. The version installed by default for yum is version 13. Upgrade docker to 18.06.2-ce version:

1) make sure the kernel version is 3.10 and above: uname-a 2) remove the old version: yum remove-y docker docker-common docker-selinux docker-engine # this step is also best performed when installing docker for the first time Otherwise, there may be an error when installing docker later. 3) install the required software package: yum install-y yum-utils device-mapper-persistent-data lvm24) set Docker yum source: yum-config-manager-- add-repo https://download.docker.com/linux/centos/docker-ce.repo5) View all docker versions in all repositories: yum list docker-ce--showduplicates | sort-R6) install docker:yum-y install docker-ce-18.06.2.ce -3.el77) set to boot: systemctl enable docker8) start: systemctl start docker9) View startup status: systemctl status docker10) View version: docker version

2. Configure docker with Ali source accelerator:

1) create / modify configuration file / etc/docker/daemon.json

The file [root@test102 ~] # cat / etc/docker/daemon.json # may not exist and needs to be newly created, and then write the following {"registry-mirrors": ["https://fzhifedh.mirror.aliyuncs.com"]}[root@test102 ~] #

2) reload the newly modified configuration and restart docker

Systemctl daemon-reload systemctl restart docker

3. Install ntp to ensure server time synchronization:

Yum-y install ntpsystemctl enable ntpdsystemctl start ntpdtimedatectl set-ntp yesntpdate-u cn.pool.ntp.orgln-sf / usr/share/zoneinfo/Asia/Shanghai / etc/localtime watch-n 1 'date' environment subordinate 1 rancher server deployment

1.1 Command:

# docker run-d-restart=unless-stopped-p 8080 data/rancher/ranchermaster:/var/lib/rancher rancher/rancher:latest 80-p 8443 data/rancher/ranchermaster:/var/lib/rancher rancher/rancher:latest

1.2 Port description:

1.3 when the container is up, you can access:

1.4 access and configure the password of the admin user through the IP+ port (https://10.0.0.102/)):

1.5 once the password is configured, jump to the URL address of the configured rancher-server. You can use the public network IP/ private network IP here, as long as you ensure that other rancher-node can access the rancher-server through this URL. If there is no special network reason, it is best to use private network IP:

Click "Save URL" to jump to the rancher-server home page. You can see the current rancher-server version number in the lower left corner, and you can switch languages in the lower right corner, and then you can create a cluster and have fun:

2 create a custom k8s cluster crystal-cluster and add two node nodes

2.1 Click the "Add Cluster" button in the upper right corner to create a cluster:

2.2 you can choose to create a custom cluster or import a cluster. Here is to create a completely new cluster, so choose Custom:

2.3 start configuring cluster related information:

The above configuration instructions:

Cluster Name: enter the cluster name (crystal-cluster)

Member Roles: configure the users who access the cluster, and the operation rights of each user to the cluster

Label & Annotations: configure tags and comments for the cluster, as needed.

Kubernetes Options:

-> Kubernetes Version: select the kubernets version

-> Network Provider: select the required network driver

-> Project Network Isolation: configure network isolation between namespace

-> Cloud Provider: select a cloud provider. This article uses VMware virtual machine deployment, and none is selected by default.

Private Registry: configure a private image repository

Advanced Options: configure custom cluster parameters and configure them as needed.

Authorized Endpoint: configure authorized access addr

The above parameters can be configured according to the prompts on the page and their own needs. In this experiment, except for Cluster Name, all the other parameters have chosen the default configuration.

Then click "Next", add the host command to the next step, and select the host role:

(select host role and port release reference: https://rancher.com/docs/rancher/v2.x/en/installation/references/)

Role selection: each host can run multiple roles. Each cluster requires at least one Etcd role, one Control role, and one Worker role.

After the role is selected, the following code box generates the corresponding host command according to the selected role, and then copies the command to the node host to run (note whether the node node has installed the supporting version of docker, and the docker is in the state of running).

2.5 once the role is selected, copy the command to the node node deployment:

Test103 (10.0.0.103), running the etcd, Control Plane, Work roles. Therefore, execute this command on test103:

Note: if you also choose to deploy three roles on a node, then the minimum memory must be greater than 2G memory. 1G memory can be up, but the cluster will die if it doesn't last long. Don't ask me how I know.

This step requires a lot of components to be installed and you need to be patient for a while. When the component is installed, rancher-server can see the following prompt:

Continue to add a second node.

Run the role work on test104 (10.0.0.104), so run this command on test104:

Click the "Done" button to go back to the home page and view the cluster details:

Click "2" in the picture above to enter the interface, and you can see the State, hostname, IP, Roles and other information of the two node nodes that have just been added.

There are several places marked in the following figure:

1. Edit: you can edit the host and set an alias to the host, such as the test machine

2. Delete: the host can be deleted

3. Edit Cluster: click this button to go back to the interface where you just created the host to edit the cluster. If you need to add a new node, you can also find the add host command from here.

Click the cluster name in the upper left corner to see the dashboard information of the corresponding cluster:

At this point, the cluster is added.

3 create project and namespace under the crystal-cluster cluster

3.1Create a project:

In order to apply better management, rancher encapsulates the concept of projects on the namespace of kubernetes. A projects can contain multiple namespace, adding a project first.

3.1.1 Click Projects/Namespace to enter the interface for creating project:

3.1.2 Click "Add Project" in the upper right corner:

3.1.3 enter Project Name and click Create to create a project called "crystal-cluster-project":

(as for the following configuration of member information, resource quota, container limit, label, etc., there is no configuration here. The page tip is very detailed and can be configured on demand)

Then at the end of the projects-namespaces page, you can see the project you just created.

3.2Create a Namespace:

3.2.1 according to the previous naming rules, click "Add Namespace" to create a namespace called "crystal-cluster-project-namespace":

3.2.2 just like creating project, only name is entered here, and the rest of the configuration defaults (Container Default Resource Limit is a container resource limit, which is recommended in the formal environment to reduce OOM risk):

In the projects-namespaces interface, you can see the namespace you just created:

4 deploy nginx instance

4.1First, enter the project you just created:

4.2 Click "Deploy" in the upper right corner to start deployment:

4.3 fill in the deployment information related to Name, Docker Image, Port Mapping, etc.:

Complete the relevant information and click launch deployment:

The environment variables, host scheduling, health check, data volume, and zoom / upgrade strategy in the following box are very useful in the real world, and the function is similar to rancher1.

Then jump to this page and see that the status has changed to active, and the subordinate has been successfully deployed:

You can see the relevant configuration of this application in the details interface, and you can also expand and scale up the capacity:

4.4 access authentication:

Access the authentication function through the IP+ port of nginx:

The above is the method of deploying rancher2.x and creating K8s cluster in centos7 system, the content is more comprehensive, the editor believes that there may be some knowledge points that we may see or use in our daily work. I hope you can learn more from this article.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report