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 stateful cloud native applications on Kubernetes

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

Share

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

How to deploy stateful cloud-native applications on Kubernetes, for this problem, this article details the corresponding analysis and solutions, hoping to help more small partners who want to solve this problem find a simpler and easier way.

Kubernetes enables developers to operate and maintain complex distributed systems. It greatly lowers the threshold for containerized application deployment. Users can easily deploy a set of highly available and scalable distributed stateless services through the Deployment and ReplicaSet controllers provided by Kubernetes. The characteristics of such applications are that they do not store data locally, and request distribution can be realized through simple Load Balancer policies. However, more and more developers want to deploy stateful services such as databases that depend on their projects into Kubernetes, and orchestrate their deployment so that applications are as close to the backend storage they depend on as possible, which is not easy because of the complexity of stateful services.

There are multiple technologies for running stateful applications in Kubernetes, each with its own advantages and disadvantages. This article attempts to describe key methods for running stateful applications in Kubernetes and explores several possible scenarios for deploying stateful services on Kubernetes.

The first approach is to integrate Kubernetes clusters with traditional storage infrastructure such as Samba, NFS, or GlusterFS, which can easily scale to cloud-based shared file systems such as Amazon EFS, Azure Files, and Google Cloud Filestore, where the storage layer is completely decoupled from the compute layer managed by Kubernetes. Due to the persistence of the underlying storage, workloads are completely decoupled from it, which allows pods to be scheduled on any node without defining node affinities.

However, this approach is not ideal for stateful workloads that require high I/O throughput. Shared file systems are not designed to provide the IOPS required for relational data, NoSQL databases, and other write-intensive workloads. Typical application scenarios for this approach should be content management systems, machine learning systems, and digital asset management systems.

The second method is to maintain the required configuration state through Kubernetes controllers. Deployment, ReplicaSet, DaemonSet, and StatefulSet are some common controllers, of which StatefulSet is a special controller. Cluster workloads can typically have one or more master servers and multiple slave servers, most databases are designed to operate in cluster mode to provide high availability and fault tolerance, and stateful cluster workloads continuously replicate data between master and slave servers. For this reason, the cluster infrastructure wants participating entities (master-slave) to have consistently exposed endpoints to reliably synchronize state. But in Kubernetes, pods are designed to be temporary and cannot be guaranteed to have fixed names and IP addresses. Another requirement for stateful clustered workloads is a persistent storage backend that is fault-tolerant and capable of meeting IOPS requirements.

StatefulSet controllers are introduced in Kubernetes to run stateful clustered workloads, ensuring that pods belonging to StatefulSets have stable unique identifiers, follow predictable naming conventions, and support orderly and convenient deployment and scaling. Each Pod in a StatefulSet has a corresponding Persistent Volume Declaration (PVC) that follows a similar naming convention. When a Pod terminates and is rescheduled on another node, the Kubernetes controller ensures that the Pod is associated with the same PVC to guarantee the state of the cluster.

Since each Pod in a StatefulSet has a dedicated PVC and PV, there are no special rules for using shared storage. But StatefulSet can be expected to gain support for fast, reliable, durable storage tiers, such as SSD-based block storage devices, from which regular backups and snapshots can be taken after ensuring that writes are fully committed to disk. Typical application scenarios include Apache ZooKeeper, Apache Kafka, MySQL, PostgreSQL, etc.

Although users can deploy and maintain a set of highly available stateful services in Kubernetes based on StatefulSet, such as MySQL, PostgreSQL, etc. However, the process is relatively complex. Users need to be familiar with various Kubernetes resource objects, learn many application-related operation details, and maintain a complex set of management scripts. In order to lower the threshold for deploying complex applications in Kubernetes, CoreOS launched Operator.

Operator is a method used to package, deploy and manage complex applications that need to run on Kubernetes. Operator codes the knowledge of operation and maintenance personnel on software operation, and comprehensively uses various resource objects in Kubernetes to implement the deployment and operation and maintenance of complex applications. Operator defines new resource objects for services through Custom Resource Definition (CRD), while ensuring that applications are in the desired state through custom controllers.

The Operator workflow can be abstracted into the following three steps:

Observe -Observe the state of the target object through the Kubernetes API;

Analyze -Analyze the difference between the current state and the expected state;

Act -Perform orchestration operations to adjust the current state to the desired state.

Due to the advancement of the open source community, operators are becoming more and more popular. However, the maturity of operators applied to various general services varies. For details, please refer to the github open source project awesome-operators. Typical application scenarios of Operator include MySQL high availability cluster, TiDB cluster, TensorFlow cluster, Hadoop eco-related cluster, etc.

About how to deploy stateful cloud native applications on Kubernetes, the answers to the questions are shared here. I hope the above content can be helpful to everyone. If you still have a lot of doubts, you can pay attention to the industry information channel for more relevant knowledge.

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

Internet Technology

Wechat

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

12
Report