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/02 Report--
StatefulSet is a type of controller that creates a POD with a unique identity. It provides orderly deployment and scaling.
Use statefulset
Use restriction
component
Pod identity recognition
Ensure deployment and scalability
Use statefulset
Statefulset is valuable for the following applications.
Stable, unique network access address
Stable and persistent storage
Orderly and elegant deployment and scalability
Orderly. Graceful deletion and termination
In the above description, stability equals persistence after POD rescheduling. If applications do not require stable authentication or orderly deployment, deletion, and scaling, you can use stateless copies (such as Deployment or ReplicaSet) to deploy your applications, which will be more suitable for stateless applications.
Use restriction
Statefulset is currently a bate version and will not be available in any release until 1.5
Like all alpha/beta resources, you can disable Statefulset with the apiserver parameter-- runtime-config
The persistent storage used by POD can be storage class-based dynamic volumes or pre-assigned by administrators
Deleting or reducing a Statefulset does not delete the assigned volumes. This is to ensure data security, which is more important than automatically clearing resources associated with statefulset
Statefulset currently needs a Headless Service to provide a network access address
Currently, you need to complete the update manually. There is a Statefulset.
component
The following example describes the components of Statefulset.
A Headless Service called nginx is used to control network access
A Statefulset named web, which starts three copies of POD
VolumeClaimTemplates will provide persistent storage
-apiVersion: v1kind: Servicemetadata: name: nginx labels: app: nginxspec: 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 p_w_picpath: 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: 1Gi
POD identity recognition
StatefulSet POD has a unique identity, consisting of a serial number, a stable network identity, and stable storage. Identity binding POD, no matter which node the POD is dispatched to.
1) serial number index
There are N instances of Statefulset, and each POD will be assigned a unique integer sequence number in the range of [1 ~ N].
2) stable network ID
The name of each POD of a StatefulSet consists of the name of the StatefulSet and the Pod sequence number. The format of the POD name is $(statefulset name)-$(ordinal). The name of the POD created in the above example is web-0,web-1,web-2. Statefulset uses Headless Service to control the domain name of POD. The format of the service domain name is $(service name). $(namespace) .svc.cluster.local, and cluster.local is cluster domain. After each POD is created, there will be a matching domain name in the format $(podname). $(service_domain). The following table is an example of how cluster domain, service name, and statefulset name interact.
Cluster Domain Service (ns/name) StatefulSet (ns/name) StatefulSet Domain Pod DNS Pod Hostname
Cluster.local default/nginx default/web nginx.default.svc.cluster.local web- {0..N-1} .nginx.default.svc.cluster.local web- {0..N-1}
Cluster.local foo/nginx foo/web nginx.foo.svc.cluster.local web- {0..N-1} .nginx.foo.svc.cluster.local web- {0..N-1}
Kube.local foo/nginx foo/web nginx.foo.svc.kube.local web- {0..N-1} .nginx.foo.svc.kube.local web- {0..N-1}
3) stable storage
Kubernetes creates a PV for each VolumeClaimTemplate. In the above example of nginx, each POD will get a PV of 1G in size. When the POD is dispatched to a node, the volumeMounts mounts the PV through the PVC bound to it.
Note: PV bound to PVC will not be deleted because of POD or statefulset deletion. Deletion needs to be performed manually.
Ensure deployment and scalability
For N copies of statefulset, when POD is deployed, they will be in order, [0..N-1]
When the POD is deleted, they will be terminated in reverse order, first terminating the POD of Nmuri 1
Before the scaling operation is applied to POD, you must ensure that the state of all previous POD is running and ready.
Before the POD is terminated, all POD after the current sequence number must be completely closed
StatefulSet should not specify pod.Spec.TerminationGracePeriodSeconds as 0. This practice is unsafe and strongly discouraged. "for further explanation, see Force deletion of StatefulSet POD."
After the above nginx example is created, the three POD will be deployed in web-0 web-1 web-2 order. Web-1 will not be deployed before web-0 running and ready, and web-2 will not start deployment until web-1 is in the running and ready state. After web-1 running and ready, but web-2 has not been started, if web-0 fails, web-2 will not be started until web-0 is successfully restarted and reaches the status of running and ready.
If a user modifies a deployed statefulset, for example, replicas=1,web-2 will be terminated first. Web-1 will not be terminated until web-2 is completely closed and deleted. Web-2 has been terminated and completely closed, but before web-1 terminates, if web-0 fails at this time, web-1 will not be terminated until web-0 is in the state of running and ready.
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.