fix(volume): Reclaim persistent volumes when the StatefulSet is deleted #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
When upgrading a StatefulSet to use a Prometheus sidecar, the StatefulSet needs to be deleted first. We need the volume reclaim settings to be set to "retain" to avoid dataloss. When the new StatefulSet is created, it will attach to the same volume and avoid dataloss.
You can learn more here: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention
Testing
Start minikube:
minikube start
Create the following
values.yaml
file.Deploy
helm template --values ./values.yaml charts/bindplane | kubectl apply -f -
Port forward and connect to the UI:
http://localhost:3011
Create a config. You do not need to roll it out or anything, we just need a way to prove that we have not lost data.
With a config created, update the values file to include the Prometheus sidecar.
If you re-deploy with helm, you will see this error:
Delete the StatefulSet in order to re-create it.
kubectl delete sts release-name-bindplane helm template --values ./values.yaml charts/bindplane | kubectl apply -f -
The bindplane pod should be re-created and contain two containers. Re-run the port forward command and check the UI for your configuration. If the configuration exists, we have not lost data despite deleting the StatefulSet.
Please check that the PR fulfills these requirements