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] How to restart all pods in a cloneset, just restart not create new pods and delete old pods #1826

Open
bellondr opened this issue Nov 13, 2024 · 1 comment
Assignees

Comments

@bellondr
Copy link

Hi guys, I am a DevOps form Jerry.ai.
I want to know How to restart all pods in a cloneset ? just restart not create new pods and delete old pods
Use ContainerRecreateRequest is too complex that need to create as many ContainerRecreateRequest as pods.
https://openkruise.io/zh/blog/openkruise-0.9.0/

What would you like to be added:
Is there a command like kubectl rollout restart CloneSet demo to restart all pods?

Why is this needed:

@furykerry
Copy link
Member

ContainerRecreateRequest(CRR) is for restarting a single container in a pod ( pod may have multiple containers). Initiating multiple CRR from kruise cli is a possible solution for you case, but it do has some problems. In particular, restarting a container from all pods in a cloneset can make the service unavailable temporally . Safer solution is to modify the podtemplate in cloneset and triggering an inplace update. the cloneset controller will respect the maxUnavailable setting during inplace-update. It is possible to trigger inplace-update without changing the image in podtemplate, one can setup a downward api backed environment, and change the corresponding annotation, e.g.

apiVersion: apps.kruise.io/v1alpha1
kind: CloneSet
metadata:
  ...
spec:
  replicas: 1
  template:
    metadata:
      annotations:
        RESTART-TRIGGER: "... arbitrary timestamp or random string ..."
    spec:
      containers:
      - name: sidecar
        env:
        - name: RESTART-TRIGGER
          valueFrom:
            fieldRef:
              fieldPath: metadata.annotations['RESTART-TRIGGER']
      - name: main
        image: main-image:v1
  updateStrategy:
    type: InPlaceIfPossible

you can refer to the doc for more information about inplace-update the container environment
https://openkruise.io/docs/core-concepts/inplace-update#understand-inplaceifpossible

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

3 participants