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

[feature request] When CloneSet volumeClaimTemplates changed, Pod must ReCreate update #1536

Open
zmberg opened this issue Mar 21, 2024 · 4 comments
Assignees
Milestone

Comments

@zmberg
Copy link
Member

zmberg commented Mar 21, 2024

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:

  1. 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
  1. 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
  1. 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

  1. 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}
  1. 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 zmberg added this to the 1.7 milestone Mar 21, 2024
@hzliangbin
Copy link

@zmberg I'd like to take this shot.If nobody doing this job, can I summit a PR?

@furykerry
Copy link
Member

@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

@furykerry furykerry removed the kind/good-first-issue Good for newcomers label Mar 21, 2024
@ABNER-1
Copy link
Contributor

ABNER-1 commented Mar 28, 2024

Please consider assigning this issue to me.

@zmberg
Copy link
Member Author

zmberg commented Mar 28, 2024

/assign @ABNER-1

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

No branches or pull requests

4 participants