In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what is the use of StatefulSets in Kubernetes services, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
StatefulSets is also a beta feature in v1.5, replacing the PetSets feature of v1.4. Users of PetSets can upgrade the running PeetSets to StatefulSets by referring to the upgrade instructions in v1.5.
StatefulSet is a controller that provides a unique flag to Pod, which ensures the order of deployment and expansion.
Use StatefulSet
The value of StatefulSet is realized when the application has any of the following requirements.
● stable, unique network identity.
● stable, persistent storage.
The orderly and elegant deployment and expansion of ●.
● deletes and stops in an orderly and elegant manner.
In the points mentioned above, stability and persistence have the same meaning in Pod scheduling. If an application does not require any stable identification or sequential deployment, deletion, and expansion, then you should use a controller that provides stateless backup to deploy your application. Things like Deployment or ReplicaSet may be better suited to your stateless service needs.
Limit
● StatefulSet is still the beta version, and Kubernetes v1.5 is not available.
●, like all alpha/beta resources, can disable StatefulSet by passing the-- runtime-config option to apiserver.
● the storage for a given Pod must be a PersistentVolume Provisioner based on the request storage level (Storage Class), or pre-configured by the administrator.
● deletes and / or reduces StatefulSet copies and does not delete StatefulSet-related volumes. This is done to ensure data security and is more valuable than automatically clearing StatefulSet-related resources. The current StatefulSet of ● requires Headless services to be responsible for network consistency of Pod. You need to create the service.
● currently, updating an existing StatefulSet needs to be performed manually.
module
The following example demonstrates the components of StatefulSet.
● A Headless service called nginx is used to control the network domain.
● StatefulSet, named web, takes three copies of nginx containers in the same Pod.
● volumeClaimTemplates uses PV from PV vendors to provide stable storage.
-apiVersion: v1kind: Servicemetadata: name: nginx labels: app: ports:-port: 80 name: web clusterIP: None selector: app: nginx---apiVersion: apps/v1beta1kind: StatefulSetmetadata: name: webspec: serviceName: "nginx" replicas: 3 template: metadata: labels: app: nginxspec: terminationGracePeriodSeconds: 10 containers:-name: nginx image: gcr.io/google_containers / nginx-slim:0.8 ports:-containerPort: 80 name: web volumeMounts:-name: www mountPath: / usr/share/nginx/html volumeClaimTemplates:-metadata: name: www annotations: volume.beta.kubernetes.io/storage-class: anything spec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 1GiPod consistency
StatefulSet Pod has unique consistency, which includes sequence (start and stop order), stable network consistency, and stable network. This consistency is closely related to Pod, no matter which node node the Pod is dispatched to.
Order index
For each StatefulSet,StatefulSet with N copies, each Pod is assigned a numeric sequence number, which is in the range of [0MagneN) and is unique in the Set.
Stable network ID
Each Pod in StatefulSet derives its hostname from the name of the StatefulSet and the sequence number of the Pod. The pattern of the composed hostname is $(statefulset name)-$(serial number). The above example creates a name called web-0,web-1,web-2. StatefulSet can control the Pod domain by using the Headless service, which uses the format $(service name). $(namespace) .svc.cluster.local, where "cluster.local" refers to the cluster domain. After Pod is created, each Pod gets a matching DNS subdomain in the format of $(podname). $(governing service domain), where "governing service" is defined through the serviceName field in StatefulSet.
Here are a few examples that show the DNS composition of StatefulSet's Pod.
Cluster DomainService (ns/name) StatefulSet (ns/name) StatefulSet DomainPod DNSPod Hostnamecluster.localdefault/nginxdefault/webnginx.default.svc.cluster.localweb- {0..N-1} .nginx.default.svc.cluster.loca lweb- {0..N-1} cluster.localfoo/nginxfoo/webnginx.foo.svc.cluster.localweb- {0..N-1} .nginx.foo.svc.cluster.localweb-{0..N-1} kube.localfoo/nginxfoo/webnginx.foo.svc.kube.localweb- {0 .. Nmur1} .nginx.foo.svc.kube.localweb-{0..N-1} Note: unless otherwise configured The cluster domain is set to cluster.local.
Stable storage
Kubernetes creates a PV for each VolumeClaimTemplate. In the above nginx example, each Pod gets a PV with a storage level (storagee class) of anything and a size of 1Gb. When Pod is dispatched to other node nodes, volumeMounts remaps the corresponding PVC. Note that when Pod or StatefulSet is deleted, the corresponding PV and PVC are not deleted, and the deletion must be performed manually.
Deployment and expansion
● for StatefulSet with N copies, when Pod is deployed, they are created sequentially (from 0 to NMel 1).
● when Pod is deleted, the order in which they are terminated is from NMel 1 to 0.
● when performing an extension operation on a Pod, the Pod in front of it must be in both Running and Ready states.
● when Pod is terminated, all of its successors must be completely closed.
You should not set the pod.Spec.TerminationGracePersonality secondary value of StatefulSet to 0, because the operation is unsafe and strongly discouraged. For a more in-depth explanation, please refer to the forced deletion of StatefulSet Pod.
When the above nginx example is created, three Pod are deployed sequentially, named web-0, web-1, and web-2. Web--1 will not be deployed until web-0 becomes Running and Ready. Similarly, web-2 will not deploy until web-1 becomes Running and Ready. If web-0 fails to run after web-1 becomes Running and Ready, but before web-2 is started, web-2 will not start until web-0 successfully starts again and becomes Running and Ready.
If the user wants to change the number of Pod in the above example, such as modifying the replicas=1, then the web-2 is terminated first. The web-2 will not be terminated until the web-1 is completely closed and deleted. If there is an error in the operation of the web-1 after the web-2 is terminated and completely closed, but before the web-1 is terminated, the web-1 will not be terminated until the web-0 becomes Running and Ready again.
The above is all the contents of the article "what is the use of StatefulSets in Kubernetes Services". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.