简体   繁体   中英

Rollout restart statefulset using kubectl proxy

I have started kubectl proxy from within my pods and am able to access kubernetes APIs. I have a need to restart my statefulset.

Using kubectl, I would done this:

kubectl rollout restart statefulset my-statefulset

However, I would like to do this using the REST APIs. For instance, I can delete my pods, using this:

curl -XDELETE localhost:8080/api/v1/namespaces/default/pods

Is there any equivalent REST endpoint that I can use to rollout restart a statefulset?

I run your command kubectl rollout restart statefulset my-statefulset --v 10 and notice the output logs.

I figured out kubectl makes a patch request when I apply above command. And I am able to do that patch request using curl like following

curl -k --data '{"spec":{"template":{"metadata":{"annotations":{"kubectl.kubrnetes.io/restartedAt":"'"$(date +%Y-%m-%dT%T%z)"'"}}}}}'\ 
    -XPATCH   -H "Accept: application/json, */*" -H "Content-Type: application/strategic-merge-patch+json"\
    localhost:8080/apis/apps/v1/namespaces/default/statefulsets/my-statefulset

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM