instruction: Create a Dockerfile for workloads
output: ```dockerfile
  from the volumeClaimTemplate are not affected when their Pod is
  deleted. This is the behavior before this new feature.Bear in mind that these policies only apply when Pods are being removed due to the
  StatefulSet being deleted or scaled down. For example, if a Pod associated with a StatefulSet
  fails due to node failure, and the control plane creates a replacement Pod, the StatefulSet
  retains the existing PVC. The existing volume is unaffected, and the cluster will attach it to
  the node where the new Pod is about to launch.The default for policies is Retain, matching the StatefulSet behavior before this new feature.Here is an example policy.apiVersion: apps/v1
  kind: StatefulSet
  ...
  spec:
   persistentVolumeClaimRetentionPolicy:
   whenDeleted: Retain
   whenScaled: Delete
  ...
  The StatefulSet controller adds
  owner references
  to its PVCs, which are then deleted by the garbage collector after the Pod is terminated. This enables the Pod to
  cleanly unmount all volumes before the PVCs are deleted (and before the backing PV and
  volume are deleted, depending on the retain policy). When you set the whenDeleted
  policy to Delete, an owner reference to the StatefulSet instance is placed on all PVCs
  associated with that StatefulSet.The whenScaled policy must delete PVCs only when a Pod is scaled down, and not when a
  Pod is deleted for another reason. When reconciling, the StatefulSet controller compares
  its desired replica count to the actual Pods present on the cluster. Any StatefulSet Pod
  whose id greater than the replica count is condemned and marked for deletion. If the
  whenScaled policy is Delete, the condemned Pods are first set as owners to the
  associated StatefulSet template PVCs, before the Pod is deleted. This causes the PVCs
  to be garbage collected after only the condemned Pods have terminated.This means that if the controller crashes and restarts, no Pod will be deleted before its
  owner reference has been updated appropriate to the policy. If a condemned Pod is
  force-deleted while the controller is down, the owner reference may or may not have been
  set up, depending on when the controller crashed. It may take several reconcile loops to
  update the owner references, so some condemned Pods may have set up owner references and
  others may not. For this reason we recommend waiting for the controller to come back up,
  which will verify owner references before terminating Pods. If that is not possible, the
  operator should verify the owner references on PVCs to ensure the expected objects are
  deleted when Pods are force-deleted.Replicas.spec.replicas is an optional field that specifies the number of desired Pods. It defaults to 1.Should you manually scale a deployment, example via kubectl scale statefulset statefulset --replicas=X, and then you update that StatefulSet
  based on a manifest (for example: by running kubectl apply -f statefulset.yaml), then applying that manifest overwrites the manual scaling
  that you previously did.If a HorizontalPodAutoscaler
  (or any similar API for horizontal scaling) is managing scaling for a
  Statefulset, don't set .spec.replicas. Instead, allow the Kubernetes
  control plane to manage
  the .spec.replicas field automatically.What's nextLearn about Pods.Find out how to use StatefulSetsFollow an example of deploying a stateful application.Follow an example of deploying Cassandra with Stateful Sets.Follow an example of running a replicated stateful application.Learn how to scale a StatefulSet.Learn what's involved when you delete a StatefulSet.Learn how to configure a Pod to use a volume for storage.Learn how to configure a Pod to use a PersistentVolume for storage.StatefulSet is a top-level resource in the Kubernetes REST API.
  Read the
  StatefulSet
  object definition to understand the API for stateful sets.Read about PodDisruptionBudget and how
  you can use it to manage application availability during disruptions.FeedbackWas this page helpful?Yes
  NoThanks for the feedback. If you have a specific, answerable question about how to use Kubernetes, ask it on
  Stack Overflow.
  Open an issue in the GitHub Repository if you want to
  report a problem
  or
  suggest an improvement.Last modified October 22, 2024 at 10:38 AM PST: add documentation for KEP 4017 PodIndexLabel going GA (e73dcd94c6) StatefulSet API reference
    Create child page
   Create an issue
   Print entire sectionUsing StatefulSetsLimitationsComponentsPod SelectorVolume Claim TemplatesMinimum ready secondsPod IdentityOrdinal IndexStart ordinalStable Network IDStable StoragePod Name LabelPod index labelDeployment and Scaling GuaranteesPod Management PoliciesUpdate strategiesRolling UpdatesPartitioned rolling updatesMaximum unavailable PodsForced rollbackPersistentVolumeClaim retentionReplicasWhat's next© 2025 The Kubernetes Authors | Documentation Distributed under CC BY 4.0© 2025 The Linux Foundation ®. ```