kruise
kruise copied to clipboard
[feature request] When CloneSet volumeClaimTemplates changed, Pod must ReCreate update
What would you like to be added: Question: When CloneSet volumeClaimTemplates and Image changed, Pod will in-place update, then volumeClaimTemplates not updated to Pod volumes, because the volumes field is only recalculated when the Pod is created.
What happened:
- Create CloneSet with volumeClaimTemplates, as follows:
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
name: web
spec:
updateStrategy:
type: InPlaceIfPossible
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:stable-alpine3.17
env:
- name: version
value: v1
volumeMounts:
- name: www-data
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
- Update image tag from stable-alpine3.17 to stable-alpine, and volumeClaimTemplates storage from 1Gi to 2Gi.
apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
spec:
template:
spec:
containers:
- name: nginx
image: nginx:stable-alpine
volumeClaimTemplates:
- metadata:
name: www-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 2Gi
- Update cloneSet, but pods only in-place update and pvc capacity don't change.
% kubectl get clonesets
NAME DESIRED UPDATED UPDATED_READY READY TOTAL AGE
web 2 2 2 2 2 2m27s
% kubectl get pods
NAME READY STATUS RESTARTS AGE
web-c48gr 1/1 Running 1 (16s ago) 2m33s
web-mjmvl 1/1 Running 1 (23s ago) 2m33s
% kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
www-data-web-c48gr Bound pvc-4100c7c4-0fb0-41b6-90e1-696cfdd970c8 1Gi RWO standard 2m38s
www-data-web-mjmvl Bound pvc-256c0b60-3cee-4da5-ba66-5530ce153b1b 1Gi RWO standard 2m38s
Goals
- Image and volumeClaimTemplates changed, ReCreate update Pod.
Non-Goals
- Only volumeClaimTemplates changed, will not trigger Pod update
Solution
- When CloneSet contains volumeClaimTemplates, NewRevision with volumeClaimTemplates hash. refer code: https://github.com/openkruise/kruise/blob/release-1.5/pkg/controller/cloneset/revision/cloneset_revision.go#L51
apiVersion: apps/v1
kind: ControllerRevision
metadata:
annotations:
kruise.io/cloneset-volumeclaimtemplate-hash: {volumeClaimTemplates.spec hash}
- CanUpdateInPlace determines if the hash value of ControllerRevision has changed, then returns false. refer code: https://github.com/openkruise/kruise/blob/v1.6.1/pkg/util/inplaceupdate/inplace_update.go#L270
@zmberg I'd like to take this shot.If nobody doing this job, can I summit a PR?
@hzliangbin thanks, however we have some internal user problem related to this issue in Alibaba, so we'd like to work on this. You can start with other issue
Please consider assigning this issue to me.
/assign @ABNER-1
/close
@ABNER-1: You can't close an active issue/PR unless you authored it or you are a collaborator.
In response to this:
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.