Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

Support PersistentVolumeClaimRetentionPolicy for statefulsets #208

Open

Description

@SatyaKuppam

As of Kubernetes v1.32 PersistentVolumeClaimRetention policy is enabled by default for statefulsets and is behind a feature gate for v1.31. This feature provides a K8s native way to manage orphaned PVCs, that is pretty similar to the existing deleteOrphanPvc config in the Druid CRD. By using this policy, we can control how orphaned PVCs will be treated:

persistentVolumeClaimRetentionPolicy:
   whenDelete: <true|false>
   whenScaled: <true|false>

Some folks might prefer persistentVolumeClaimRetention over deleteOrphanPvc because:

  • allows more granular control because its at the statefulset level, instead of deleteOrphanPvc which affects the entire Druid cluster. For example:
    • we might want to Retain historical PVCs because loading data from S3 might be expensive
    • but we might want to delete middlemanagers' PVCs on scale-downs
  • dont have to be bound by the deleteOrphanPvc's delayed deletion of 60s (ref)

I want to add this functionality in the nodeSpec if folks think its useful and I want to align on the following:

  • this makes sense only for statefulsets and not deployments
  • if the deleteOrphanPvc is set, then the persistentVolumeClaimRetention configuration is automatically ignored to allow for backward compatibility
  • this configuration only makes sense if StatefulSetAutoDeletePVC feature flag is set (ref).
    • I am actually not sure how to check for this. Any ideas?
  • this feature is only available from v1.31, but from the compatibility matrix (ref), the latest we support is v.1.30.1.
    • What do I have to do to use the > v.1.30 API?

Activity

  1. AdheipSingh commented on Mar 3, 2025

    @AdheipSingh
    Contributor

    +1. Makes sense to use persistentVolumeClaimRetention.
    What do I have to do to use the > v.1.30 API? - You can just test with > v.1.30 . Its just that the last release was tested on v.1.30. The underlying client libraries should work.

    How do you plan to add this ? similar to deleteOrphanPvc flag in nodeSpec ? Also what is the default behavior of statefulset, do we need to enable this flag explicitly ?

  2. layoaster commented on Apr 9, 2026

    @layoaster
    Contributor

    @SatyaKuppam, thanks for raising this issue.

    @AdheipSingh this is a critical issue for users on kubernetes > = 1.32.x. The flag deleteOrphanPvc is not being honored because the default value of STS persistentVolumeClaimRetentionPolicy is Retain.

    Perhaps I'm wrong, but it makes sense to drop support for the flag deleteOrphanPvc to adopt k8s native handling of orphan PVCs, which also has finer-grained control for deletion of orphan PVCs.

  3. AdheipSingh commented on Apr 9, 2026

    @AdheipSingh
    Contributor

    Yes i agree, deleteOrphan logic was written way before when sts din't support this. We should adhere to STS feature and just expose the persistentVolumeClaimRetentionPolicy within the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions