Este contenido no está disponible en el idioma seleccionado.

Chapter 17. StatefulSet [apps/v1]


Description

StatefulSet represents a set of pods with consistent identities. Identities are defined as: - Network: A single stable DNS and hostname. - Storage: As many VolumeClaims as requested.

The StatefulSet guarantees that a given network identity will always map to the same storage identity.

Type
object

17.1. Specification

PropertyTypeDescription

apiVersion

string

APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

kind

string

Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

metadata

ObjectMeta

Standard object’s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

spec

object

A StatefulSetSpec is the specification of a StatefulSet.

status

object

StatefulSetStatus represents the current state of a StatefulSet.

17.1.1. .spec

Description
A StatefulSetSpec is the specification of a StatefulSet.
Type
object
Required
  • selector
  • template
  • serviceName
PropertyTypeDescription

minReadySeconds

integer

Minimum number of seconds for which a newly created pod should be ready without any of its container crashing for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)

ordinals

object

StatefulSetOrdinals describes the policy used for replica ordinal assignment in this StatefulSet.

persistentVolumeClaimRetentionPolicy

object

StatefulSetPersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from the StatefulSet VolumeClaimTemplates.

podManagementPolicy

string

podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. The default policy is OrderedReady, where pods are created in increasing order (pod-0, then pod-1, etc) and the controller will wait until each pod is ready before continuing. When scaling down, the pods are removed in the opposite order. The alternative policy is Parallel which will create pods in parallel to match the desired scale without waiting, and on scale down will delete all pods at once.

Possible enum values: - "OrderedReady" will create pods in strictly increasing order on scale up and strictly decreasing order on scale down, progressing only when the previous pod is ready or terminated. At most one pod will be changed at any time. - "Parallel" will create and delete pods as soon as the stateful set replica count is changed, and will not wait for pods to be ready or complete termination.

replicas

integer

replicas is the desired number of replicas of the given Template. These are replicas in the sense that they are instantiations of the same Template, but individual replicas also have a consistent identity. If unspecified, defaults to 1.

revisionHistoryLimit

integer

revisionHistoryLimit is the maximum number of revisions that will be maintained in the StatefulSet’s revision history. The revision history consists of all revisions not represented by a currently applied StatefulSetSpec version. The default value is 10.

selector

LabelSelector

selector is a label query over pods that should match the replica count. It must match the pod template’s labels. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors

serviceName

string

serviceName is the name of the service that governs this StatefulSet. This service must exist before the StatefulSet, and is responsible for the network identity of the set. Pods get DNS/hostnames that follow the pattern: pod-specific-string.serviceName.default.svc.cluster.local where "pod-specific-string" is managed by the StatefulSet controller.

template

PodTemplateSpec

template is the object that describes the pod that will be created if insufficient replicas are detected. Each pod stamped out by the StatefulSet will fulfill this Template, but have a unique identity from the rest of the StatefulSet. Each pod will be named with the format <statefulsetname>-<podindex>. For example, a pod in a StatefulSet named "web" with index number "3" would be named "web-3". The only allowed template.spec.restartPolicy value is "Always".

updateStrategy

object

StatefulSetUpdateStrategy indicates the strategy that the StatefulSet controller will use to perform updates. It includes any additional parameters necessary to perform the update for the indicated strategy.

volumeClaimTemplates

array (PersistentVolumeClaim)

volumeClaimTemplates is a list of claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template. A claim in this list takes precedence over any volumes in the template, with the same name.

17.1.2. .spec.ordinals

Description
StatefulSetOrdinals describes the policy used for replica ordinal assignment in this StatefulSet.
Type
object
PropertyTypeDescription

start

integer

start is the number representing the first replica’s index. It may be used to number replicas from an alternate index (eg: 1-indexed) over the default 0-indexed names, or to orchestrate progressive movement of replicas from one StatefulSet to another. If set, replica indices will be in the range: [.spec.ordinals.start, .spec.ordinals.start + .spec.replicas). If unset, defaults to 0. Replica indices will be in the range: [0, .spec.replicas).

17.1.3. .spec.persistentVolumeClaimRetentionPolicy

Description
StatefulSetPersistentVolumeClaimRetentionPolicy describes the policy used for PVCs created from the StatefulSet VolumeClaimTemplates.
Type
object
PropertyTypeDescription

whenDeleted

string

WhenDeleted specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is deleted. The default policy of Retain causes PVCs to not be affected by StatefulSet deletion. The Delete policy causes those PVCs to be deleted.

whenScaled

string

WhenScaled specifies what happens to PVCs created from StatefulSet VolumeClaimTemplates when the StatefulSet is scaled down. The default policy of Retain causes PVCs to not be affected by a scaledown. The Delete policy causes the associated PVCs for any excess pods above the replica count to be deleted.

17.1.4. .spec.updateStrategy

Description
StatefulSetUpdateStrategy indicates the strategy that the StatefulSet controller will use to perform updates. It includes any additional parameters necessary to perform the update for the indicated strategy.
Type
object
PropertyTypeDescription

rollingUpdate

object

RollingUpdateStatefulSetStrategy is used to communicate parameter for RollingUpdateStatefulSetStrategyType.

type

string

Type indicates the type of the StatefulSetUpdateStrategy. Default is RollingUpdate.

Possible enum values: - "OnDelete" triggers the legacy behavior. Version tracking and ordered rolling restarts are disabled. Pods are recreated from the StatefulSetSpec when they are manually deleted. When a scale operation is performed with this strategy,specification version indicated by the StatefulSet’s currentRevision. - "RollingUpdate" indicates that update will be applied to all Pods in the StatefulSet with respect to the StatefulSet ordering constraints. When a scale operation is performed with this strategy, new Pods will be created from the specification version indicated by the StatefulSet’s updateRevision.

17.1.5. .spec.updateStrategy.rollingUpdate

Description
RollingUpdateStatefulSetStrategy is used to communicate parameter for RollingUpdateStatefulSetStrategyType.
Type
object
PropertyTypeDescription

maxUnavailable

IntOrString

The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding up. This can not be 0. Defaults to 1. This field is alpha-level and is only honored by servers that enable the MaxUnavailableStatefulSet feature. The field applies to all pods in the range 0 to Replicas-1. That means if there is any unavailable pod in the range 0 to Replicas-1, it will be counted towards MaxUnavailable.

partition

integer

Partition indicates the ordinal at which the StatefulSet should be partitioned for updates. During a rolling update, all pods from ordinal Replicas-1 to Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched. This is helpful in being able to do a canary based deployment. The default value is 0.

17.1.6. .status

Description
StatefulSetStatus represents the current state of a StatefulSet.
Type
object
Required
  • replicas
PropertyTypeDescription

availableReplicas

integer

Total number of available pods (ready for at least minReadySeconds) targeted by this statefulset.

collisionCount

integer

collisionCount is the count of hash collisions for the StatefulSet. The StatefulSet controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ControllerRevision.

conditions

array

Represents the latest available observations of a statefulset’s current state.

conditions[]

object

StatefulSetCondition describes the state of a statefulset at a certain point.

currentReplicas

integer

currentReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.

currentRevision

string

currentRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).

observedGeneration

integer

observedGeneration is the most recent generation observed for this StatefulSet. It corresponds to the StatefulSet’s generation, which is updated on mutation by the API Server.

readyReplicas

integer

readyReplicas is the number of pods created for this StatefulSet with a Ready Condition.

replicas

integer

replicas is the number of Pods created by the StatefulSet controller.

updateRevision

string

updateRevision, if not empty, indicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas)

updatedReplicas

integer

updatedReplicas is the number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.

17.1.7. .status.conditions

Description
Represents the latest available observations of a statefulset’s current state.
Type
array

17.1.8. .status.conditions[]

Description
StatefulSetCondition describes the state of a statefulset at a certain point.
Type
object
Required
  • type
  • status
PropertyTypeDescription

lastTransitionTime

Time

Last time the condition transitioned from one status to another.

message

string

A human readable message indicating details about the transition.

reason

string

The reason for the condition’s last transition.

status

string

Status of the condition, one of True, False, Unknown.

type

string

Type of statefulset condition.

17.2. API endpoints

The following API endpoints are available:

  • /apis/apps/v1/statefulsets

    • GET: list or watch objects of kind StatefulSet
  • /apis/apps/v1/watch/statefulsets

    • GET: watch individual changes to a list of StatefulSet. deprecated: use the 'watch' parameter with a list operation instead.
  • /apis/apps/v1/namespaces/{namespace}/statefulsets

    • DELETE: delete collection of StatefulSet
    • GET: list or watch objects of kind StatefulSet
    • POST: create a StatefulSet
  • /apis/apps/v1/watch/namespaces/{namespace}/statefulsets

    • GET: watch individual changes to a list of StatefulSet. deprecated: use the 'watch' parameter with a list operation instead.
  • /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}

    • DELETE: delete a StatefulSet
    • GET: read the specified StatefulSet
    • PATCH: partially update the specified StatefulSet
    • PUT: replace the specified StatefulSet
  • /apis/apps/v1/watch/namespaces/{namespace}/statefulsets/{name}

    • GET: watch changes to an object of kind StatefulSet. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
  • /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status

    • GET: read status of the specified StatefulSet
    • PATCH: partially update status of the specified StatefulSet
    • PUT: replace status of the specified StatefulSet

17.2.1. /apis/apps/v1/statefulsets

HTTP method
GET
Description
list or watch objects of kind StatefulSet
Table 17.1. HTTP responses
HTTP codeReponse body

200 - OK

StatefulSetList schema

401 - Unauthorized

Empty

17.2.2. /apis/apps/v1/watch/statefulsets

HTTP method
GET
Description
watch individual changes to a list of StatefulSet. deprecated: use the 'watch' parameter with a list operation instead.
Table 17.2. HTTP responses
HTTP codeReponse body

200 - OK

WatchEvent schema

401 - Unauthorized

Empty

17.2.3. /apis/apps/v1/namespaces/{namespace}/statefulsets

HTTP method
DELETE
Description
delete collection of StatefulSet
Table 17.3. Query parameters
ParameterTypeDescription

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

Table 17.4. HTTP responses
HTTP codeReponse body

200 - OK

Status schema

401 - Unauthorized

Empty

HTTP method
GET
Description
list or watch objects of kind StatefulSet
Table 17.5. HTTP responses
HTTP codeReponse body

200 - OK

StatefulSetList schema

401 - Unauthorized

Empty

HTTP method
POST
Description
create a StatefulSet
Table 17.6. Query parameters
ParameterTypeDescription

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

fieldValidation

string

fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.

Table 17.7. Body parameters
ParameterTypeDescription

body

StatefulSet schema

 
Table 17.8. HTTP responses
HTTP codeReponse body

200 - OK

StatefulSet schema

201 - Created

StatefulSet schema

202 - Accepted

StatefulSet schema

401 - Unauthorized

Empty

17.2.4. /apis/apps/v1/watch/namespaces/{namespace}/statefulsets

HTTP method
GET
Description
watch individual changes to a list of StatefulSet. deprecated: use the 'watch' parameter with a list operation instead.
Table 17.9. HTTP responses
HTTP codeReponse body

200 - OK

WatchEvent schema

401 - Unauthorized

Empty

17.2.5. /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}

Table 17.10. Global path parameters
ParameterTypeDescription

name

string

name of the StatefulSet

HTTP method
DELETE
Description
delete a StatefulSet
Table 17.11. Query parameters
ParameterTypeDescription

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

Table 17.12. HTTP responses
HTTP codeReponse body

200 - OK

Status schema

202 - Accepted

Status schema

401 - Unauthorized

Empty

HTTP method
GET
Description
read the specified StatefulSet
Table 17.13. HTTP responses
HTTP codeReponse body

200 - OK

StatefulSet schema

401 - Unauthorized

Empty

HTTP method
PATCH
Description
partially update the specified StatefulSet
Table 17.14. Query parameters
ParameterTypeDescription

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

fieldValidation

string

fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.

Table 17.15. HTTP responses
HTTP codeReponse body

200 - OK

StatefulSet schema

201 - Created

StatefulSet schema

401 - Unauthorized

Empty

HTTP method
PUT
Description
replace the specified StatefulSet
Table 17.16. Query parameters
ParameterTypeDescription

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

fieldValidation

string

fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.

Table 17.17. Body parameters
ParameterTypeDescription

body

StatefulSet schema

 
Table 17.18. HTTP responses
HTTP codeReponse body

200 - OK

StatefulSet schema

201 - Created

StatefulSet schema

401 - Unauthorized

Empty

17.2.6. /apis/apps/v1/watch/namespaces/{namespace}/statefulsets/{name}

Table 17.19. Global path parameters
ParameterTypeDescription

name

string

name of the StatefulSet

HTTP method
GET
Description
watch changes to an object of kind StatefulSet. deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter.
Table 17.20. HTTP responses
HTTP codeReponse body

200 - OK

WatchEvent schema

401 - Unauthorized

Empty

17.2.7. /apis/apps/v1/namespaces/{namespace}/statefulsets/{name}/status

Table 17.21. Global path parameters
ParameterTypeDescription

name

string

name of the StatefulSet

HTTP method
GET
Description
read status of the specified StatefulSet
Table 17.22. HTTP responses
HTTP codeReponse body

200 - OK

StatefulSet schema

401 - Unauthorized

Empty

HTTP method
PATCH
Description
partially update status of the specified StatefulSet
Table 17.23. Query parameters
ParameterTypeDescription

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

fieldValidation

string

fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.

Table 17.24. HTTP responses
HTTP codeReponse body

200 - OK

StatefulSet schema

201 - Created

StatefulSet schema

401 - Unauthorized

Empty

HTTP method
PUT
Description
replace status of the specified StatefulSet
Table 17.25. Query parameters
ParameterTypeDescription

dryRun

string

When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed

fieldValidation

string

fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.

Table 17.26. Body parameters
ParameterTypeDescription

body

StatefulSet schema

 
Table 17.27. HTTP responses
HTTP codeReponse body

200 - OK

StatefulSet schema

201 - Created

StatefulSet schema

401 - Unauthorized

Empty

Red Hat logoGithubRedditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

© 2024 Red Hat, Inc.