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

Advanced Technology: Kubernetes Advanced Architecture and Application State deployment

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

Share

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

Before learning about Kubernetes application state deployment, let's take a look at the high-level architecture of Kubernetes to better understand the state of Kubernetes.

High-level architecture of Kubernetes

It includes application deployment model, service discovery and load balancing, internal / external route separation, use of persistentvolume, deployment of node daemons, deployment of stateful distributed systems, running of jobs in the background, deployment database, configuration management, certificate management, rolling updates, automatic scaling and package management.

A, one of the basic design strategies of Kubernetes is to deploy existing applications running on virtual machines without changing the application code. In addition, any application running on a virtual machine can be deployed on Kubernetes through containerized components. This is achieved through core functions such as container grouping, container orchestration, overlay network, based on layer 4 virtual IP, service discovery, support for daemon operation, deployment of stateful application components, and extension of the container orchestration system.

B, Kubernetes can provide a set of dynamically scalable hosts, you can apply the container to run workload, and use a group of management hosts called master to provide API to manage the entire container infrastructure. These workload include long-running services, batch jobs, and daemons for container hosts. In order to provide container-to-container routing, all container hosts are connected by an overlay network. Applications deployed on Kubernetes are dynamically visible in cluster networks and can be exposed to external networks through traditional load balancers. The state of the cluster manager is stored in a highly distributed key/value storage (etcd) that runs on master.

Kubernetes application state deployment

The services running on K8s are divided into stateless services and stateful services. Let's take a look at how K8s runs these two different types of services.

01 "stateless" service

Stateless services, applications such as Web servers, agents, and application code, can process data without storing it. Developers prefer to use them during orchestration because they are easy to deploy and easy to extend. If the traffic increases, only more load balancing needs to be added. More importantly, they are "immutable"; there is little difference between the upstream container image and the containers running in the infrastructure. This means that they can be replaced at any time, and there is almost no "switching cost" in the process of switching container instances.

Stateless service. K8s uses Replicaset to guarantee the number of instances of a service. If a Pod instance is crash for some reason, RC will immediately replace it with a new Pod with a Pod template. Because it is a stateless service, the newly launched Pod is exactly the same as the original healthy Pod. When Pod is rebuilt, its IP address may change. In order to provide a stable access interface, K8s introduces the concept of Service. A Service can be followed by multiple Pod to achieve high availability of the service.

In Kubernetes, both Deployment and Replicasets are effective means of using stateless services.

02 "stateful" service

Stateful services, namely routers, CDN (content delivery Network), streaming servers, and authentication servers. From the beginning of deployment, these containers begin to be different from the upstream images, and the longer they are, the more different they are. This difference is called "state". In fact, every running application has at least one small state (difference), but for "stateless" applications, the state (difference) is small and can be quickly replaced.

Compared with stateless service, ordinary stateful service has more requirements for state preservation. K8s provides a storage system based on Volmume and Peristent Volmume, which can save the state of service.

One of the most difficult tasks in containerized applications is to design the deployment architecture of stateful distributed components. Since stateless components may not have predefined startup sequences, clustering requirements, point-to-point TCP connections, unique network identifiers, normal startup and termination requirements, and so on, containerization can be made easily. Such as databases, big data analysis systems, distributed key/value storage and message brokers may have complex distributed architectures, all of which may use the above functions.

Kubernetes introduces StatefulSets resources to support this complex requirement, to manage POD deployment and expansion, and to provide a guarantee of sequence and uniqueness for these pod.

03 StatefulSet deployment-Stateful Application

It is used to solve the independent lifecycle management of each pod instance, providing the startup sequence and uniqueness of each instance.

The prerequisite for using StatefulSet is:

1. The version of Kubernetes cluster ≥ 1.5

2. Install the DNS cluster plug-in, version ≥ 15.

Why StatefulSet is suitable for stateful programs, take a look at its features:

A, stable, unique network identifier. Other members within the cluster can be found.

B, stable persistent storage. This is achieved through Kubernetes's PV/PVC or external storage (provided in advance).

C. orderly when starting or shutting down. Orderly and elegant deployment and expansion. Orderly and elegant deletion and termination. Orderly automatic scrolling updates. Realize the guarantee of deployment and expansion.

04 what are the benefits of using StatefulSet?

Guarantee of deployment and expansion

For StatefulSet with N replica sets, when pod is deployed, they will be created in the order from 0 to NMel 1.

When a Pod is deleted, they will be terminated in the order NMel 1 to 0.

All dependent Pod should be running and ready before Pod expansion.

Before Pod can be terminated, all Pod that depend on it must be stopped completely.

If your system is an ecosystem of micro services, it will be more tedious to deliver new services. If further, the services are stateful, then the automation and robustness features of kubernetes will help you a lot. The purpose of StatefulSet is to provide correct controller support for numerous stateful loads.

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