Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement(vector): Add persistence.retentionPolicy for configuring Statefulset PVC retention policy #347

Merged
merged 13 commits into from
Oct 21, 2024

Conversation

alemuro
Copy link
Contributor

@alemuro alemuro commented Nov 24, 2023

Hello! 👋

This PR adds a new variable in the values.yaml file: persistence.retentionPolicy.

This allow users to define which is the PVC retention policy for the created Statefulsets. Kubernetes by default sets a Remain policy, meaning that no PVC are removed when the Statefulset is down-scaled or removed. With this new setting, users can tell Kubernetes to remove these disks, for example for non production environment.

This variable has a default set to {}, meaning that this setting will not be applied and Kubernetes will apply its default value, so current statefulsets will not be affected.

More info about this new feature here:
https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention

Some tests

I've run the following commands to ensure that the output is expected:

Using this setting on a K8S cluster below 1.23: Setting do not appear on the rendered statefulset.

$ helm template \                        
      -s templates/statefulset.yaml  \
      --kube-version "1.22" --set 'persistence.retentionPolicy.whenDeleted=Delete' \
      . |                  
      yq -r '.spec.persistentVolumeClaimRetentionPolicy'
null

Using this setting on a k8s cluster above 1.23: Setting appears on the rendered statefulset.

$ helm template \
      -s templates/statefulset.yaml  \
      --kube-version "1.27" --set 'persistence.retentionPolicy.whenDeleted=Delete' \
      . |
      yq -r '.spec.persistentVolumeClaimRetentionPolicy'
{
  "whenDeleted": "Delete"
}

$ helm template \
      -s templates/statefulset.yaml  \
      --kube-version "1.27" \
      --set 'persistence.retentionPolicy.whenScaled=Delete' \
      . |
      yq -r '.spec.persistentVolumeClaimRetentionPolicy'
{
  "whenScaled": "Delete"
}

Using the default value in a k8s cluster above 1.23: Setting do not appear on the rendered statefulset.

$ helm template \
      -s templates/statefulset.yaml  \
      --kube-version "1.27" \                                                                            
      . |
      yq -r '.spec.persistentVolumeClaimRetentionPolicy'
null

@dsmith3197 dsmith3197 self-requested a review November 28, 2023 14:17
Copy link
Contributor

@dsmith3197 dsmith3197 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good overall. Thank you for testing the changes!

Could you please add a CHANGELOG entry, bump the chart version, and change the PR title to follow conventional commits (e.g., enhancement(vector): ...)? (ref)

# whenScaled: Retain
# ```
# @type: map
persistentVolumeClaimRetentionPolicy: {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

persistence.persistentVolumeClaimRetentionPolicy is quite lengthy and redundant. What do you think about naming this persistence.retentionPolicy instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do it! The reason of using the whole name is because this is the name of the variable in Kubernetes, but it might be redundant as you said 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello again! I've executed the requested actions, but according to the README, I think they should be executed on develop after merging into main.

  • Chart is using the latest Vector version, so I didn't bumped it.
  • Updated the Chart version in Chart.yaml from 0.29.0 to 0.30.0.
  • Updated Changelog manually: I've created a new commit (otherwise I can't reference the commit itself in the Changelog)
  • I've renamed the variable name as proposed
  • I've updated the tests in the description (and I've run them again to validate that it works fine)
  • I've updated the commit to include the PR and to be a conventional commit ( enhance(): ...)

Hope it's fine now! Please let me know if I should run any other action 🙏

Many thanks 😄

@dsmith3197 dsmith3197 changed the title Add persistence.persistentVolumeClaimRetentionPolicy for configuring Statefulset PVC retention policy enhancement(vector): Add persistence.persistentVolumeClaimRetentionPolicy for configuring Statefulset PVC retention policy Dec 1, 2023
@alemuro alemuro changed the title enhancement(vector): Add persistence.persistentVolumeClaimRetentionPolicy for configuring Statefulset PVC retention policy enhancement(vector): Add persistence.retentionPolicy for configuring Statefulset PVC retention policy Dec 4, 2023
@alemuro alemuro force-pushed the add-pvc-retentionpolicy branch 4 times, most recently from 316ce26 to a0295de Compare December 4, 2023 07:49
@alemuro alemuro force-pushed the add-pvc-retentionpolicy branch from a0295de to f94671a Compare December 4, 2023 07:50
@jszwedko jszwedko requested a review from dsmith3197 December 4, 2023 14:54
Signed-off-by: Jesse Szwedko <[email protected]>
@jszwedko jszwedko merged commit ab8df81 into vectordotdev:develop Oct 21, 2024
11 checks passed
@alemuro alemuro deleted the add-pvc-retentionpolicy branch October 24, 2024 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants