From b9f5fe4edcedb7ab9b750bcf3266f202f4a20cce Mon Sep 17 00:00:00 2001 From: "Krishnakumar R(KK)" <65895020+kk-src@users.noreply.github.com> Date: Mon, 8 Jun 2020 11:36:54 -0700 Subject: [PATCH] KEP-0661: StatefulSet volume resize --- .../0661-statefulset-volume-resize/README.md | 685 ++++++++++++++++++ .../0661-statefulset-volume-resize/kep.yaml | 15 + 2 files changed, 700 insertions(+) create mode 100644 keps/sig-storage/0661-statefulset-volume-resize/README.md create mode 100644 keps/sig-storage/0661-statefulset-volume-resize/kep.yaml diff --git a/keps/sig-storage/0661-statefulset-volume-resize/README.md b/keps/sig-storage/0661-statefulset-volume-resize/README.md new file mode 100644 index 00000000000..beada74b71d --- /dev/null +++ b/keps/sig-storage/0661-statefulset-volume-resize/README.md @@ -0,0 +1,685 @@ + +# KEP-0661: StatefulSet volume resize + + + + + + +- [Release Signoff Checklist](#release-signoff-checklist) +- [Summary](#summary) +- [Motivation](#motivation) + - [Goals](#goals) + - [Non-Goals](#non-goals) +- [Proposal](#proposal) + - [Background](#background) + - [Changes required](#changes-required) + - [Error indications to user](#error-indications-to-user) + - [Revision control](#revision-control) + - [User Stories (optional)](#user-stories-optional) + - [Story 1](#story-1) + - [Story 2](#story-2) + - [Notes/Constraints/Caveats (optional)](#notesconstraintscaveats-optional) + - [Risks and Mitigations](#risks-and-mitigations) +- [Design Details](#design-details) + - [API server validation relaxation](#api-server-validation-relaxation) + - [StatefulSet controller changes](#statefulset-controller-changes) + - [RBAC changes.](#rbac-changes) + - [Test Plan](#test-plan) + - [Graduation Criteria](#graduation-criteria) + - [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy) + - [Version Skew Strategy](#version-skew-strategy) +- [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire) + - [Feature enablement and rollback](#feature-enablement-and-rollback) +- [Drawbacks](#drawbacks) +- [Alternatives](#alternatives) +- [Infrastructure Needed (optional)](#infrastructure-needed-optional) + + +## Release Signoff Checklist + + + +Items marked with (R) are required *prior to targeting to a milestone / release*. + +- [ ] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR) +- [ ] (R) KEP approvers have approved the KEP status as `implementable` +- [ ] (R) Design details are appropriately documented +- [ ] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input +- [ ] (R) Graduation criteria is in place +- [ ] (R) Production readiness review completed +- [ ] Production readiness review approved +- [ ] "Implementation History" section is up-to-date for milestone +- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io] +- [ ] Supporting documentation e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes + + + +[kubernetes.io]: https://kubernetes.io/ +[kubernetes/enhancements]: https://git.k8s.io/enhancements +[kubernetes/kubernetes]: https://git.k8s.io/kubernetes +[kubernetes/website]: https://git.k8s.io/website + +## Summary + +This enhancement proposes to add the ability to resize volumes associated with +StatefulSet via modifications to it's specification. + + + +## Motivation + +Stable persistent volumes can be created by specifying `volumeClaimTemplates` in `StatefulSet` +[specification](https://kubernetes.io/docs/concepts/workloads/controllers/StatefulSet/). +Currently, StatefulSets do not allow the associated volumes to be resized directly by modifying the +`volumeClaimTemplates`. Instead users have to modify each PVC one by one to achieve this. +The intent of this proposal is to avoid this user overhead and simplify the process of +resizing StatefulSet volumes. + + + +### Goals + +Allow users to resize the volumes associated with `StatefulSet` by modifying the size of +PVC in the `volumeClaimTemplate`. + + + +### Non-Goals + +Currently, PVC resize does not support shrinking the volume. Also, some environments require Pod restarts inorder +to get access to the resized volume. This proposal does not try to address these scenarios but relies on the +underlying PVC resize logic to take the appropriate action or indicate error as needed. + + + +## Proposal + +### Background + +Before we proceed to the proposal it is imperative to layout the various components involved +in creating and managing the persistent volumes associated with `StatefulSet`. StatefulSet +controller creates the PVCs from `volumeClaimTemplates` and associates them with the pods +spawned from it. Reconciliation logic runs for every change made to the StatefulSet +`Spec` and `Status` reflects the progress towards making the real world state equal to the + `Spec`. The admission controller in the api server is responsible for restricting the fields +which can be edited in a StatefulSet specification. The RBAC specification in the controller +policy is responsible for adding the required RBAC permission for StatefulSet. StatefulSet +controller also supports revision control. + +### Changes required + +The following changes are proposed to achieve the goal: +1. Make the `volumeClaimTemplates` storage size editable by modification to the api server + validation. +2. Add reconciliation of the associated PVC's size and the individual `volumeClaimTemplates` + size into the StatefulSet controller reconciliation. +3. Append PVC `update` to the StatefulSet controller's RBAC clusterrole. + +Once the above changes are made, modification to any of the `volumeClaimTemplates` storage +size by user will update the underlying PVC via the reconciliation performed by (2) above. +The existing PVC [resize](https://kubernetes.io/blog/2018/07/12/resizing-persistent-volumes-using-kubernetes/) +code kicks in at this point and attempts at the resize of the volume. + +### Error indications to user + +Whether a resize works or not would depend on many factors such as is `allowExpansion` set in the +storage class, does the underlying storage allow expansion etc. Such failures will be reported in +the corresponding PVC events. StatefulSet would only report any failures in the update operation +performed to the PVC object. + +### Revision control + +StatefulSet supports [revision control](https://kubernetes.io/blog/2017/09/kubernetes-statefulsets-daemonsets/). +The storage size change will not be added to the fields supporting revision control. Any change in +revision - going forward to a new version or going back to an older version etc. would not make any +changes to the persistent volume size. Any changes requiring resize of the volume will need editing +of the StatefulSet storage size specification. + + + +### User Stories (optional) + + + +#### Story 1 + +#### Story 2 + +### Notes/Constraints/Caveats (optional) + + + +### Risks and Mitigations + +Currently, shrinking the PVC size is not supported and the same will apply to StatefulSet changes. There +will not be any validations done at the StatefulSet controller level for checking the size change +(e.g., whether if the size is getting increased or decreated by user). This provides the flexibility +to future changes in the PVC resize code to support new features (like shrink support) without requiring +any StatefulSet change. User confusion could be a side effect of this approach; and will be mitigated by +documentation with pointers to PVC events. + +Controller revision is a very useful funtionality. As specified earlier in this doc, no changes will be made to the +controller revision code. This can potentially lead to situations where the pod goes back to an earlier state which +requires larger volume or so. But given that PVC shrink is not supported yet and to keep things simple, we will not +add any changes to controller revision. Specific documentation will be added to mitigate any user expectation mismatch. + + + +## Design Details + +### API server validation relaxation +Modifications would be made to `ValidateStatefulSetUpdate` inorder to allow changes in the +storage size of the volume in the `VolumeClaimTemplates`. + +### StatefulSet controller changes +The `sync` function in the `StatefulSetController` runs the reconciliation to match the current +reality and the expected declaration in the `Spec`. An addendum will be made to validate each +PVC associated with each pod and ensure that their sizes are matching VolumeClaimTemplate specification. +If not, a call is made to update the PVC object with the size specified in the VolumeClaimTemplate. + +### RBAC changes. +Now that StatefulSet controller needs to updte the PVC, `update` is added to the `statefulset-controller` +role in the buildControllerRoles. + + + +### Test Plan + + + +### Graduation Criteria + + + +### Upgrade / Downgrade Strategy + + + +### Version Skew Strategy + + + +## Production Readiness Review Questionnaire + + + +### Feature enablement and rollback + + + +## Drawbacks + + + +## Alternatives + +An alternative approach considered with respect to the revision control is to add the + volume size as part of the revision control. In such a case, if we did an expand + volume, users will not be able to rollback to previous versions since volume shrink + is not yet supported. Hence we take a pragmatic path and keep the volume size separate +from controller revision changes. + + + +## Infrastructure Needed (optional) + + diff --git a/keps/sig-storage/0661-statefulset-volume-resize/kep.yaml b/keps/sig-storage/0661-statefulset-volume-resize/kep.yaml new file mode 100644 index 00000000000..cbe4b7f3e3b --- /dev/null +++ b/keps/sig-storage/0661-statefulset-volume-resize/kep.yaml @@ -0,0 +1,15 @@ +title: StatefulSet volume resize +kep-number: 0661 +authors: + - "@kk-src" +owning-sig: sig-apps +participating-sigs: + - sig-storage +status: provisional +creation-date: 2020-06-04 +reviewers: + - "kow3ns" + - "@gnufied" + - "@msau42" +approvers: + - TBD \ No newline at end of file