gpt4 book ai didi

kubernetes - 无法将本地 docker 图像与 docker desktop kubernetes 一起使用

转载 作者:行者123 更新时间:2023-12-02 12:16:32 30 4
gpt4 key购买 nike

我有这个 kubernetes yaml 文件

apiVersion: v1
kind: Service
metadata:
name: incremental-api-load-balancer
spec:
selector:
app: incremental-api
tier: api
ports:
- protocol: "TCP"
port: 80
targetPort: 80
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
name: incremental-external-api-service
spec:
selector:
app: incremental-external-api
tier: sidecar
ports:
- protocol: "TCP"
port: 80
targetPort: 80
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: incremental-api-deployment
spec:
selector:
matchLabels:
app: incremental-api
tier: api
track: stable
replicas: 3
template:
metadata:
labels:
app: incremental-api
tier: api
track: stable
spec:
containers:
- name: incremental-flask-app
image: incremental-flask
imagePullPolicy: Never
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: incremental-external-api-deployment
spec:
selector:
matchLabels:
app: incremental-external-api
tier: sidecar
track: stable
replicas: 1
template:
metadata:
labels:
app: incremental-external-api
tier: sidecar
track: stable
spec:
containers:
- name: incremental-external-api
image: incremental-external-api
imagePullPolicy: Never

当我这样做

docker images ls

我明白了

REPOSITORY                                  TAG                                        IMAGE ID            CREATED             SIZE
incremental-flask latest 8bbc4c45efdf 2 minutes ago 1.21GB
incremental-external-api latest 532203259006 3 minutes ago 1.2GB

从查看这个答案 - Docker for Mac(Edge) - Kubernetes - reference local image

我应该拉取本地镜像。

但是,我在运行时得到了这个

kubectl get pods

incremental-api-deployment-98b5d7c95-bmqbf 0/1 ErrImageNeverPull 0 1m
incremental-api-deployment-98b5d7c95-tktqv 0/1 ErrImageNeverPull 0 1m
incremental-api-deployment-98b5d7c95-xcwk2 0/1 ErrImageNeverPull 0 1m
incremental-external-api-service-deployment-b9dddff77-6z4p9 0/1 ErrImageNeverPull 0 1m

我正在使用 Docker Desktop 运行一个本地集群,我想拉取本地镜像。

为什么会出现这个错误?

最佳答案

--image-pull-policy=Never

使用“latest”标签将始终强制拉取,因为 imagePullPolicy:always 的值,它会寻找要拉取的远程仓库。

当你添加 'Never' 选项时,将使用本地 repo

关于kubernetes - 无法将本地 docker 图像与 docker desktop kubernetes 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55761999/

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