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 implement K8s Cluster Architecture and High availability parsing

2025-03-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to achieve K8s cluster architecture and high availability parsing, and the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Basic working process

The core working process of Kubernetes:

Resource objects: Node, Pod, Service, Replication Controller, etc., can all be regarded as a kind of resource object.

Operation: add, delete, modify and check by using the kubectl tool

Storage: the target state (preset state) of an object, persisted in etcd

Automatic control: track and compare the target state stored in etcd with the current state of resources, correct the deviation of different resources, and automatically control the status of the cluster.

Kubernetes is actually a highly automated resource control system that abstracts everything it manages into resource objects, ranging from server Node nodes to service instance Pod.

Kubernetes's resource control is a declaration + engine concept:

Disclaimer: declare the target status of a resource

Automation: the Kubernetes automated resource control system will always strive to keep the resource object in the target state.

Architecture (physical + logical)

Kubernetes cluster, which is the master-slave architecture:

Master: management node, cluster control and scheduling

Node: work node that executes specific business containers

The following components are independent processes, each of which is written in Go. The actual deployment of the Kubernetes cluster is to deploy these programs.

Master node:

Kube-apiserver

Kube-controller-manager

Kube-scheduler

Node node:

Kubelet

Kube-proxy

Specifically, the nodes of the two roles need to run different processes and responsibilities, which are described in detail below.

Master management node: manages the entire Kubernetes cluster, receives external commands, and maintains the cluster state.

Apiserver: Kubernetes API Server

Entry of cluster control

Add, delete, modify and query resources, and persist them to etcd

Kubectl interacts directly with API Server, and the default port is 6443.

Etcd: a highly available key-value storage system

Role: status of storage resourc

API that supports Restful.

Default listening on ports 2379 and 2380 (2379 provides services, 2380 is used for cluster node communication) (question: cluster node, does it mean etcd cluster? Master Cluster?)

Scheduler: responsible for scheduling pod resources to the appropriate node.

Scheduling algorithm: scheduling according to the performance, load and data location of node nodes.

By default, port 10251 is listening.

Controller-manager: the automation control center for all resources

Each resource corresponds to a controller (question: what is the purpose?)

Controller manager manages these controllers

Controller manager is an automatic cycle controller.

The core of Kubernetes controls the daemon and listens to port 10252 by default. (question: why is there a monitoring segment taste?)

Supplementary note:

Both scheduler and controller-manager obtain the status of various resources from etcd through apiserver, and carry out corresponding scheduling and control operations.

Node node: Master node, which schedules tasks to the Node node and runs in docker mode; when the Node node goes down, Master automatically schedules the tasks on the Node to other Node.

Kubelet: the life cycle management of this node's Pod, and regularly report the basic information of this node and Pod to Master.

Kubelet runs agent on each Node node

Responsible for maintaining and managing all containers: receiving Pod creation requests from apiserver, starting and stopping Pod

Kubelet does not manage containers that are not created by Kubernetes

Regularly report information to Master, such as operating system, Docker version, CPU, memory, pod running status, etc.

Kube-proxy: communication and load balancing of Service in cluster

Function: service discovery, reverse proxy.

Reverse proxy: TCP and UDP connection forwarding are supported. By default, client traffic is forwarded to a set of backend pod corresponding to service based on Round Robin algorithm.

Service discovery: use etcd's watch mechanism to monitor the dynamic changes of service and endpoint object data in the cluster, and maintain a service-to-endpoint mapping relationship. (in essence: routing relationship)

Implementation: there are two implementation methods, userspace and iptables.

Userspace: in the user space, the proxy service of load balancing through kuber-proxy is the initial implementation scheme, which is stable and inefficient.

Iptables: in kernel space, LB is implemented purely by iptables, which is the default way of Kubernetes at present

Runtime: docker containers are generally used, and other containers are also supported.

High availability of clusters

Kubernetes clusters, in a production environment, must achieve high availability:

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

Achieve high availability of Master nodes and their core components

If there is a problem with the Master node, the whole cluster is out of control.

Specific schematic diagram of HA:

The above method can be used as HA, but it is not yet mature. It is understood that the function of updating HA will be updated in the future.

How it works:

Etcd cluster: three Master nodes are deployed, and the etcd of each Master node forms a cluster

Ingress cluster: a load balancer is placed in front of the APIServer on the three Master nodes, through which the worker node and the client communicate with the APIServer

Pod-master guarantees that only the primary master is available, scheduler and controller-manager have only one working instance in the cluster, and the other is standby.

On how to achieve K8s cluster architecture and high availability parsing is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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

Development

Wechat

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

12
Report