Kubernetes stateful Cluster service deployment and management

Source: Internet
Author: User
Tags k8s

There are two requirements for stateful cluster services: one is storage requirements and the other is cluster requirements.
For storage requirements, the Kubernetes solution is: Volume, persistent Volume. For PV, in addition to manually creating a PV pool, the storage system can be automatically created by storage class.

For cluster requirements, the Kubernetes solution is pet Set. The Pet Set also initializes the cluster through the INIT container, providing a stable network identity to the cluster members through the Headless service.

Services running in k8s, from simple to complex, can be divided into three categories: stateless service, normal stateful service, and stateful Cluster service. Here's a look at how k8s works with these three types of services.

    • Stateless service, K8s uses RC (or newer replica Set) to guarantee the number of instances of a service, if a pod instance is crash for some reason, RC will immediately use the Pod template to start a pod instead of it, because it is a stateless service, The city pod is exactly the same as the pod in its original state of health. After the pod is rebuilt its IP address can change, in order to provide a stable access interface, K8S introduced the concept of service. Multiple pods can be hung behind a service, enabling high availability of services.
    • The normal stateful service, compared with stateless services, has more requirements for state preservation. Kubernetes provides a storage system based on volume and persistent volume that enables the state of the service to be saved.
    • Stateful Cluster service, compared with the normal stateful service, has more requirements for cluster management. K8s has developed a new feature based on pet set, which facilitates the deployment and management of stateful Cluster service on k8s. Specifically, the initialization of the cluster is done by Init container, and the Headless Service is used to maintain the stable relationship of the cluster members, the dynamic storage supply is used to facilitate the cluster expansion, and finally the whole cluster is managed by the pet set.

To run a stateful Cluster service there are two problems to solve, one is state saving and the other is cluster management. Let's take a look at how to solve the first problem: State saving. Kubernetes has a set of storage systems based on the volume plug-in, which enables the state of applications and services to be saved.

The k8s storage System is broadly divided into three levels: General volume,persistent Volume and dynamic storage provisioning, from basic to advanced.

To summarize, two types of storage volumes: normal Volume and persistent Volume. The normal Volume is defined directly when the pod is defined, and persistent Volume is dynamically bound by persistent Volume claim. PV can be created manually or dynamically through Storageclass.

What is init Container?

The name is the container that initializes the work. There can be one or more, and if there are more than one, these init Container are executed sequentially in the order defined, and only the primary container is started after all Init Container have finished executing. Since the storage volumes in one pod are shared, the data generated in the Init Container can be used by the main container.

Init container can be used in a variety of k8s resources such as Deployment, Daemon set, Pet set, job, etc., but in the final analysis, when the pod is started, it is executed before the main container starts, doing initialization work.

And pet represents a stateful service. In k8s resource object, pet is a kind of pod which needs special care. It's a state, an identity, and of course more complicated than a normal pod.

There are three characteristics of a pet.

The first is that there is a stable storage,

The second is a stable network identity, which is achieved through a special service called Headless Service.

The third is the ordinal naming rule.

 

Kubernetes stateful Cluster service deployment and management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.