gpt4 book ai didi

macos - kubectl 从本地 docker 镜像运行?

转载 作者:行者123 更新时间:2023-12-01 09:44:40 25 4
gpt4 key购买 nike

如何引用存在的本地镜像?

kubectl run u --rm -i --tty --image my_local_image -- bash

结果 ImagePullBackOffkubectl显然是试图从远程存储库而不是本地寄存器中提取。

answer没有帮助,后续指的是 minikube 和 kubernetes。

一些事件日志
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 1m default-scheduler Successfully assigned u-6988b9c446-zcp99 to docker-for-desktop
Normal SuccessfulMountVolume 1m kubelet, docker-for-desktop MountVolume.SetUp succeeded for volume "default-token-q2qm7"
Normal SandboxChanged 1m kubelet, docker-for-desktop Pod sandbox changed, it will be killed and re-created.
Normal Pulling 23s (x3 over 1m) kubelet, docker-for-desktop pulling image "centos_postgres"
Warning Failed 22s (x3 over 1m) kubelet, docker-for-desktop Failed to pull image "centos_postgres": rpc error: code = Unknown desc = Error response from daemon: pull access denied for centos_postgres, repository does not exist or may require 'docker login'
Warning Failed 22s (x3 over 1m) kubelet, docker-for-desktop Error: ErrImagePull
Normal BackOff 9s (x5 over 1m) kubelet, docker-for-desktop Back-off pulling image "centos_postgres"
Warning Failed 9s (x5 over 1m) kubelet, docker-for-desktop Error: ImagePullBackOff

最佳答案

Kubernetes Pod 有一个 imagePullPolicy field 。如果您将其设置为 Never ,它永远不会尝试拉取镜像,由您来确保 kubelet 使用的 docker 守护进程包含该镜像。默认策略是 IfNotPresent , 应该和 Never 一样工作如果图像已经存在于 docker 守护进程中。仔细检查您的 docker 守护进程是否确实包含您认为它包含的内容,并确保您的 imagePullPolicy设置为我提到的两个之一。

apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-image
image: local-image-name
imagePullPolicy: Never

关于macos - kubectl 从本地 docker 镜像运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51826603/

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