Kubernetes StatefulSet: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=
* https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/ StatefulSets
* https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/


=Internal=
=Internal=
* [[Kubernetes Higher Level Pod Controllers#StatefulSet|Kubernetes Higher Level Pod Controllers]]
* [[Kubernetes Workload Resources#StatefulSet|Kubernetes Workload Resources]]
* [[Kubernetes API Resources Concepts#StatefulSet |API Resources Concepts]]
* [[Kubernetes API Resources Concepts#StatefulSet |API Resources Concepts]]


=Overview=
=Overview=


Used for stateful application components, where the application component relies on access to "stable" file storage to maintain state between restarts. As such, [[Kubernetes_Storage_Concepts#local|local volumes]] that are directly attached to node hosts, can be used. A StatefulSet and the individual pods the StatefulSet manages are registered with the [[Kubernetes_Networking_Concepts#The_DNS_Service|cluster's DNS service]].
StatefulSet is the workload API object used to manage stateful applications.


A stateful set makes sure pods are rescheduled in such a way that they retain their [[Kubernetes_Pod_and_Container_Concepts#Pod_Identity|identity]] and [[Kubernetes_Pod_and_Container_Concepts#Pod_State|state]].
<font color=darkkhaki>State and identity (name, hostname). It is not guaranteed the same IP address, but the name is constant. The state a StatefuSet pod holds is relevant, we need to be able to get to it, based on a name.</font>


The StatefulSet '''creates''' PersistentVolumeClaims in a manner similar to the one in which it creates pods. More details in [[#StatefuSet_Storage|StatefulSet Storage]] below.
=Scaling=
A StatefulSet has a Scale sub-resource, allowing it to be controlled by a [[Kubernetes Horizontal Pod Autoscaler#Overview|horizontal pod autoscaler]].


=StatefulSet Manifest=
=StatefulSet and DNS=
{{Internal|Kubernetes StatefulSet Manifest|StatefulSet Manifest}}
{{External|https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id}}
=TODO=


=StatefulSet Storage=
{{Internal|Kubernetes StatefulSet TODEPLETE|Kubernetes StatefulSet TODEPLETE}}
 
==Persistent Volume Claim Template==
 
Because persistent volume claims map to persistent volumes one-to-one, and each pod of a StatefulSet needs its dedicated, separate storage, each pod of a StatefulSet needs to reference a different persistent volume claim to have its own separate persistent volume. The StatefulSet achieves this behavior by creating persistent volume claims alongside pods, based on a persistent volume claim template.
 
===Labels on a Persistent Volume Claim created from the Persistent Volume Claim Template===
 
When the persistent volume claims associated with the StatefulSet pods are created, each persistent volume claim will automatically get all labels declared in the [[Kubernetes_StatefulSet_Manifest#spec_selector_matchLabels|.spec.selector.matchLabels]] section of the StatefulSet manifes.
 
===Persistent Volume Claim Template Manifest===
{{Internal|Kubernetes_StatefulSet_Manifest#volumeClaimTemplates|StatefulSet Manifest}}
 
=Operations=
{{Internal|Kubernetes StatefulSet Operations|StatefulSet Operations}}
 
=TODO=
* https://medium.com/better-programming/kubernetes-a-detailed-example-of-deployment-of-a-stateful-application-de3de33c8632

Latest revision as of 20:15, 13 July 2023

External

Internal

Overview

StatefulSet is the workload API object used to manage stateful applications.

State and identity (name, hostname). It is not guaranteed the same IP address, but the name is constant. The state a StatefuSet pod holds is relevant, we need to be able to get to it, based on a name.

Scaling

A StatefulSet has a Scale sub-resource, allowing it to be controlled by a horizontal pod autoscaler.

StatefulSet and DNS

https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id

TODO

Kubernetes StatefulSet TODEPLETE