英文:
Can a pod make itself unavailable temporarily in kubernetes?
问题
Kubernetes pod that is connected to a service make itself look unavailable temporarily to the service so that no traffic is scheduled on that pod? And make itself available again?
英文:
Can a Kubernetes pod that is connected to a service make itself look unavailable temporarily to the service so that no traffic is scheduled on that pod? And make itself available again?
答案1
得分: 1
我认为你正在寻找的是一个readiness
探针。当一个Pod不ready
时,它不会接收请求。因此,你可以定义一个readiness
探针,并使它失败。更多信息。
英文:
I think what you are looking for is a readiness
probe. When a pod is not ready
, it gets no requests. So you could define a readiness probe, and make it fails. More.
答案2
得分: 0
以下是翻译好的部分:
- 删除与 K8s 服务相关的部署/有状态集 (或服务本身) <-- 如果您有一些 DevOps 部署链,这更容易
- 将部署的副本缩放为 0 <--
kubectl -n NAMESPACE scale --replicas=0 deployment APP-NAME
- 通过修改与服务相关的标签,以便它们不匹配,对部署进行修补 (通过 kubectl 或编辑 YAML 文件) <-- 最后的手段
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#label-selector-updates
英文:
You can do this in these ways:
1.delete the Deployment/Statefulset that is connected to the Service K8s (or the Service itself) <-- easier if you have some chain of DevOps for deploy
2.scaling the replica of your Deployment to 0 <-- kubectl -n NAMESPACE scale --replicas=0 deployment APP-NAME
3.patch (via kubectl or editing the YAML file) the Deployment by changing the label associated with the Service, so that it does not match <-- last resort
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#label-selector-updates
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论