![尽管规范中只有 1 个副本,但 Kubernetes Pod 显示 2/2 已就绪](https://linux22.com/image/756747/%E5%B0%BD%E7%AE%A1%E8%A7%84%E8%8C%83%E4%B8%AD%E5%8F%AA%E6%9C%89%201%20%E4%B8%AA%E5%89%AF%E6%9C%AC%EF%BC%8C%E4%BD%86%20Kubernetes%20Pod%20%E6%98%BE%E7%A4%BA%202%2F2%20%E5%B7%B2%E5%B0%B1%E7%BB%AA.png)
由于某种原因,跨多个命名空间的一堆 pod 显示多个 pod,即使它们的部署规范指定了replicas: 1
。
例子:
NAME READY STATUS RESTARTS AGE
calibre-9569796f5-d5gt8 1/1 Running 1 2d4h
> calibre-web-d4965df64-29t9c 2/2 Running 5 2d4h < this one right here for example
jellyfin-67f58745dc-dbvss 1/1 Running 6 2d4h
但在我deployment.yml
的
spec:
replicas: 1
答案1
当列出 pod 时,该Ready
列并不表示副本,而是ready
pod 内的容器。
例如这里我正在运行带有 sidecar 的 pod,并kubectl proxy
为第二个 pod 打开:
NAME READY STATUS RESTARTS AGE
kubectl-pod 2/2 Running 2 2d19h
您会注意到,它显示我的两个容器都已准备就绪。为了检查副本数量,您必须列出您的部署:
➜ ~ kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-deployment 3/3 1 3 52d
➜ ~ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deployment-9bf6f7ddf-858hh 1/1 Running 0 52d
nginx-deployment-9bf6f7ddf-rr65g 1/1 Running 0 52d
nginx-deployment-9bf6f7ddf-wsdpb 1/1 Running 0 52d