简体   繁体   English

使用 kubectl 代理推出重启 statefulset

[英]Rollout restart statefulset using kubectl proxy

I have started kubectl proxy from within my pods and am able to access kubernetes APIs.我已经从我的 pod 中启动了 kubectl 代理,并且能够访问 kubernetes API。 I have a need to restart my statefulset.我需要重新启动我的 statefulset。

Using kubectl, I would done this:使用 kubectl,我会这样做:

kubectl rollout restart statefulset my-statefulset

However, I would like to do this using the REST APIs.但是,我想使用 REST API 来执行此操作。 For instance, I can delete my pods, using this:例如,我可以使用以下命令删除我的 pod:

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

Is there any equivalent REST endpoint that I can use to rollout restart a statefulset?是否有任何等效的 REST 端点可用于推出重启 statefulset?

I run your command kubectl rollout restart statefulset my-statefulset --v 10 and notice the output logs.我运行您的命令kubectl rollout restart statefulset my-statefulset --v 10并注意 output 日志。

I figured out kubectl makes a patch request when I apply above command.当我应用上述命令时,我发现kubectl会发出补丁请求。 And I am able to do that patch request using curl like following我可以使用curl来完成该补丁请求,如下所示

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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