gpt4 book ai didi

kubernetes - Kubernetes 集群中的一个 pod 崩溃,但其他 pod 没有崩溃

转载 作者:行者123 更新时间:2023-12-02 11:34:29 27 4
gpt4 key购买 nike

奇怪的是,kubernetes 集群中的一个 pod 崩溃了,但其他 pod 却没有崩溃!

codingjediweb-6d77f46b56-5mffg   0/1     CrashLoopBackOff   3          81s
codingjediweb-6d77f46b56-vcr8q 1/1 Running 0 81s

它们应该具有相同的图像并且都应该有效。可能是什么原因?

我怀疑崩溃的 Pod 具有旧图像,但我不知道为什么。这是因为我修复了一个问题并希望代码能够正常工作(位于其中一个 Pod 上)。

有没有可能不同的 Pod 有不同的镜像?有没有办法检查哪个 Pod 正在运行哪个镜像?有没有办法“刷新”旧图像或强制 K8S 下载,即使它有缓存?

更新

听了法门的建议,我看了一下图片。我可以看到崩溃的容器似乎正在使用现有的图像(可能是旧的)。如何让K8S始终拉取镜像?

manuchadha25@cloudshell:~ (copper-frame-262317)$ kubectl get pods
NAME READY STATUS RESTARTS AGE
busybox 1/1 Running 1 2d1h
codingjediweb-6d77f46b56-5mffg 0/1 CrashLoopBackOff 10 29m
codingjediweb-6d77f46b56-vcr8q 1/1 Running 0 29m
manuchadha25@cloudshell:~ (copper-frame-262317)$ kubectl describe pod codingjediweb-6d77f46b56-vcr8q | grep image
Normal Pulling 29m kubelet, gke-codingjediweb-cluste-default-pool-69be8339-wtjt Pulling image "docker.io/manuchadha25/codingjediweb:08072020v3"
Normal Pulled 29m kubelet, gke-codingjediweb-cluste-default-pool-69be8339-wtjt Successfully pulled image "docker.io/manuchadha25/codingjediweb:08072020v3"
manuchadha25@cloudshell:~ (copper-frame-262317)$ kubectl describe pod codingjediweb-6d77f46b56-5mffg | grep image
Normal Pulled 28m (x5 over 30m) kubelet, gke-codingjediweb-cluste-default-pool-69be8339-p5hx Container image "docker.io/manuchadha25/codingjediweb:08072020v3" already present on machine
manuchadha25@cloudshell:~ (copper-frame-262317)$

此外,工作 Pod 有两个镜像条目(拉取和拉取)。哪里有两个?

最佳答案

当您创建部署时,会在后台创建一个副本集。该副本集的每个 Pod 都具有相同的属性(即图像、内存)。

当您通过更新部署的 PodTemplateSpec 来应用任何更改时。创建一个新的 ReplicaSet,部署 Controller 以受控的速率管理 Pod 从旧 ReplicaSet 到新 ReplicaSet 的移动。此时,您可能会发现来自不同副本集的不同 pod 具有不同的属性。

检查图像:

# get pod's yaml
$ kubectl get pods -n <namespace> <pod-name> -o yaml

# get deployment's yaml
$ kubectl get deployments -n <namespace> <deployment-name> -o yaml

在部署 yaml 中将 imagePullPolicy 设置为 Always,以通过强制拉取来使用更新的镜像。

关于kubernetes - Kubernetes 集群中的一个 pod 崩溃,但其他 pod 没有崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62804083/

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