2

我正在尝试从本地 docker 映像创建 Kubernetes 部署。并且使用 imagePullPolicy as Never这样 Kubernetes 会从通过 tar 导入的本地 docker 镜像中获取它。

环境

  •  SingleNodeMaster  # one node deployment
    

但是 Kubernetes 总是试图获取私有存储库,尽管存在本地 docker 镜像。

有关如何调试和解决问题的任何指示,以便 Kubernetes 从本地 docker 注册表中选择图像?谢谢你。

执行的步骤

  • 搬运工加载-i images.tar
  • docker images # 显示来自 myprivatehub.com/nginx/nginx-custom:v1.1.8 的图像
  • kubectl create -f local-test.yaml with imagepullPolicy as Never

错误

Pulling  pod/nginx-custom-6499765dbc-2fts2   Pulling image "myprivatehub.com/nginx/nginx-custom:v1.1.8" 
Failed   pod/nginx-custom-6499765dbc-2fts2   Error: ErrImagePull   
Failed   pod/nginx-custom-6499765dbc-2fts2   Failed to pull image "myprivatehub.com/nginx/nginx-custom:v1.1.8": rpc error: code = Unknown desc = failed to pull and unpack image "myprivatehub.com/nginx/nginx-custom:v1.1.8": failed to resolve reference "myprivatehub.com/nginx/nginx-custom:v1.1.8": failed to do request: Head "https://myprivatehub.com/v2/nginx/nginx-custom/manifests/v1.1.8": dial tcp: lookup myprivatehub.com: no such host
docker pull <imagename>

Error response from daemon: Get https://myprivatehub.com/v2/: dial tcp: lookup myprivatehub.com on 172.31.0.2:53: no such host
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-custom
  namespace: default
spec:
  selector:
    matchLabels:
      run: nginx-custom
  replicas: 5 
  template:
    metadata:
      labels:
        run: nginx-custom
    spec:
      containers:
      - image: myprivatehub.com/nginx/nginx-custom:v1.1.8
        imagePullPolicy: Never
        name: nginx-custom
        ports:
        - containerPort: 80
4

1 回答 1

2

这是因为容器运行时不同于 docker。我正在使用 containerd ,将容器运行时切换到 docker 后,它开始工作。

于 2021-06-22T06:45:45.490 回答