在Kubernetes中,一个Pod可以暂时使自己不可用吗?

huangapple go评论69阅读模式
英文:

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

以下是翻译好的部分:

  1. 删除与 K8s 服务相关的部署/有状态集 (或服务本身) <-- 如果您有一些 DevOps 部署链,这更容易
  2. 将部署的副本缩放为 0 <-- kubectl -n NAMESPACE scale --replicas=0 deployment APP-NAME
  3. 通过修改与服务相关的标签,以便它们不匹配,对部署进行修补 (通过 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

huangapple
  • 本文由 发表于 2023年3月20日 23:15:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75792078.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定