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 local multi-node K8S cluster in Rancher Server

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

Share

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

In this issue, Xiaobian will bring you about how to deploy local multi-node K8S clusters in Rancher Server. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.

Prepare virtual machines for master and worker nodes

The diagram above shows the architecture of the cluster, with one master node and three worker nodes. This is the minimum configuration to attempt cross-node functionality such as Load Balancer, Session Maintenance, Host Affinity, etc. using ingress controller.

Rancher Server is not complicated to install, it is packaged as a docker image and can be run as a container. The basic configuration of a node is the docker CE daemon running on a Linux virtual machine. In this case, I chose Ubuntu 18.04 LTS (see Rancher's official documentation for node requirements: rancher.com/docs/rancher/v2.x/en/installation/requirements/). When I finished setting up the first VM, I copied it directly into the other three. If you are like me, you can refer to the following two tips:

Install Docker: docs.docker.com/install/linux/docker-ce/ubuntu/

After Clone VM, change Ubuntu hostname: linuxize.com/post/how-to-change-hostname-on-ubuntu-18-04/

Eventually, all 4 nodes started up on my computer (i5, 24 GB RAM) and allocated the following resources.

Master nodes (2 cores, 4G RAM, Ubuntu 18.04 + Docker CE 18.09) x 1

Worker nodes (2 cores, 3G RAM, Ubuntu 18.04 + Docker CE 18.09) x 3

Start Rancher serversudo docker run --restart=unless-stopped \ -p 81:80 -p 444:443 rancher/rancher on master node

The above command starts the Rancher server container and runs it on the master node. By default, the nginx ingress controller is embedded in the worker node and bound to ports 80 and 443. So I publish Rancger servers to ports 81 and 444 or something else to avoid port collisions.

Complete initial setup of Rancher server

First, start the Rancher server console using the master node IP address and port 444, which asks for an administrator password.

Next, verify that the worker node reaches the URL of the Rancher server. For convenience, I use the master node IP address as the URL. After the initial setup, Rancher server is ready to add new clusters.

Create a new K8S cluster and master node

Because I want to run the K8S cluster on my local VM instead of in the cloud, select the option "Custom"(i.e.," From my own existing nodes" above) and select "None" as the cloud provider option for the new cluster.

Copy and run docker command on ubuntu virtual machine to start master node. A master node should have at least etcd and control. If you want to create a single-node cluster, you need to select all three roles and change the command.

After running docker, the new node will appear on the Rancher Server console. It will take some time to configure this node, and once it is configured, the status will change to active.

Creating a worker node

For the worker node, we just need to select the "Worker" role in the node options, and then copy and run the docker command on the Ubuntu virtual machine of the 3 worker nodes.

Finally, the multi-node cluster was ready on my computer.

Install kubectl tool to manage new K8S cluster

The Kubernetes version of the new cluster is v1.14.6, which you can see in the screenshot above. To better match the kubectl tool version to the cluster, run the following command on the master node to install a specific version:

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.14.6/bin/linux/amd64/kubectlchmod +x ./ kubectlsudo mv ./ kubectl /usr/local/bin/kubectl

The Kubectl tool requires a kubeconfig file to connect to the cluster. The kubeconfig file for the new cluster can be found in the console of Rancher Server.

Copy the kubeconfig file above and save it as ~/.kube/config file. Kubectl is then able to retrieve cluster information.

The above is how to deploy a local multi-node K8S cluster in Rancher Server shared by Xiaobian. If you happen to have similar doubts, you may wish to refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.

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