kuberneets pods 镜像 ErrImageNeverPull
我有一个创建了用户服务的 docker 映像并将其标记为 localhost:5001 我有一个在端口 5001 运行的本地注册表
用户服务推送到本地注册表
并使用deploy_new.yaml 文件创建了 pod
apiVersion: v1
kind: Pod
metadata:
name: user-service
labels:
component: web
spec:
containers:
- name: web
image: localhost:5001/user-service
resources:
limits:
memory: 512Mi
cpu: "1"
requests:
memory: 256Mi
cpu: "0.2"
imagePullPolicy: Never
ports:
- name: http
containerPort: 4006
protocol: TCP
livenessProbe:
httpGet:
path: /health/health
port: 4006
initialDelaySeconds: 3
periodSeconds: 3
failureThreshold: 2
readinessProbe:
httpGet:
path: /health/health
port: 4006
initialDelaySeconds: 15
periodSeconds: 10
问题:
- 什么是 ErrImageNeverPull 图像以及如何修复它?
- 如何测试活跃度和就绪度探针?
I have a docker image created user-service and tagged it to localhost:5001
I have a local registry running at PORT 5001
User-service pushed to local registry
and created pod using deploy_new.yaml file
apiVersion: v1
kind: Pod
metadata:
name: user-service
labels:
component: web
spec:
containers:
- name: web
image: localhost:5001/user-service
resources:
limits:
memory: 512Mi
cpu: "1"
requests:
memory: 256Mi
cpu: "0.2"
imagePullPolicy: Never
ports:
- name: http
containerPort: 4006
protocol: TCP
livenessProbe:
httpGet:
path: /health/health
port: 4006
initialDelaySeconds: 3
periodSeconds: 3
failureThreshold: 2
readinessProbe:
httpGet:
path: /health/health
port: 4006
initialDelaySeconds: 15
periodSeconds: 10
Questions :
- What is ErrImageNeverPull image and how to fix it?
- How to test liveliness and readiness probes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1.什么是 ErrImageNeverPull 图像以及如何修复它?
作为
imagePullPolicy
设置为Never
kubelet 不会获取图像,而是查找本地存在的图像。该错误意味着它无法在本地找到图像,并且不会尝试获取它。如果集群可以访问本地 docker 注册表,只需将
image: user-service
更改为image: localhost:5000/user-service:latest
如果您使用的是 minikube ,检查README 重用您的 docker 守护进程,以便您无需上传即可使用您的图片。
eval $(minikube docker-env)
。docker build -t user-service 。
image: user-service
imagePullPolicy: Never
代码> 您的容器(您已经拥有)2。如何测试活跃度和就绪探针?
我建议您尝试 Kubernetes 文档 他们很好地解释了两者之间的区别以及您可以配置的不同类型的探测器。
在检查活性和就绪探针之前,您需要首先使 Pod 运行。但就您而言,一旦 Pod 启动,它们就会成功。只需描述它并查看事件即可。
1. What is ErrImageNeverPull image and how to fix it?
As the
imagePullPolicy
is set toNever
the kubelet won't fetch images but look for what is present locally. The error means it could not found the image locally and it will not try to fetch it.If the cluster can reach to your local docker registry, just change the
image: user-service
toimage: localhost:5000/user-service:latest
If you are using minikube, check the README to reuse your docker daemon so you can use your image without uploading it.
eval $(minikube docker-env)
on each session you need to use it.docker build -t user-service .
image: user-service
imagePullPolicy: Never
for your container (which you already have)2. How to test liveliness and readiness probes?
I suggest you try the examples form the Kubernetes documentation they explain really good the difference between the two and the different types of probes you can configure.
You need first to make your pod running before checking liveness and readiness probes. But in your case they will succeed as soon as the Pod starts. Just describe it and see the events.
还有一件事需要注意。如果您使用非默认的
minikube
配置文件,eval $(minikube docker-env)
将默默失败,从而导致观察到的行为:One more thing to note.
eval $(minikube docker-env)
will fail silently if you are using a non-defaultminikube
profile, leading to the observed behavior:To address this re-run specifying the profile you are using: