gpt4 book ai didi

kubernetes - kubectl - 如何重新启动部署(或所有部署)

转载 作者:行者123 更新时间:2023-12-03 23:59:21 25 4
gpt4 key购买 nike

我们有一个 AKS 集群,有时我们最终会遇到部署需要重新启动的问题(例如,缓存数据已更新,我们想要刷新它,或者我们想要刷新损坏的缓存数据)。
我一直在使用将部署扩展到 0 的方法,然后使用以下命令将其扩展回来:

kubectl scale deployments/<deploymentName> --replicas=0
kubectl scale deployments/<deploymentName> --replicas=1
这符合我的预期,但感觉很糟糕,这意味着在此过程发生时我们没有运行任何部署。
这样做的更好方法是什么?对于特定部署和所有部署?

最佳答案

如果您有 RollingUpdate 的策略在您的部署中,您可以删除 pod 以替换 pod 并刷新它。
关于滚动更新策略:

Users expect applications to be available all the time and developersare expected to deploy new versions of them several times a day. InKubernetes this is done with rolling updates. Rolling updates allowDeployments' update to take place with zero downtime by incrementallyupdating Pods instances with new ones.


滚动更新配置:
spec:
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
maxSurge指定可以在所需 Pod 数量上创建的最大 Pod 数量。 maxUnavailable指定在更新过程中可能不可用的最大 Pod 数。
删除 pod :
kubectl delete pod <pod-name>
编辑:
此外,您可以推出部署,这将重新启动 pod,但也会创建部署的新版本。
例如: kubectl rollout restart deployments/<deployment-name>

关于kubernetes - kubectl - 如何重新启动部署(或所有部署),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64271173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com