简体   繁体   中英

Kubernetes Minikube on Windows Pod failed to pull image

I'm trying to run Kubernetes on Windows using Minikube and Hyper-V. I've managed to succesfully run Minikube using minikube start --vm-driver=hyperv --hyperv-virtual-switch=KuberNAT and checking minikube status gives me

PS > minikube status
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.1.74

but now I'm trying to run an image in kubernetes using kubectl, I've managed to get my powershell window to point towards the kubernetes vm with minikube docker-env | Invoke-Expression minikube docker-env | Invoke-Expression (powershell only, I haven't been able to do something similar on Command Prompt) and I have to insert this command in every powershell window I want to use to push an image to the kubernetes images.

The issue I'm having is that that I can't run a container, I can "deploy" an image with kubectl run cloudconfig --image=cloudconfig but the created pod is giving me this error:

 Failed to pull image "cloudconfig": rpc error: code = Unknown desc = Error response from daemon: repository cloudconfig not found: does not exist or no pull access

If I run docker image ls I get

REPOSITORY                                             TAG                 IMAGE ID            CREATED             SIZE
cloudconfig                                            latest              9199d500e746        2 minutes ago       105MB
openjdk                                                8-jre-alpine        5699ac7295f9        6 days ago          81.4MB
gcr.io/google_containers/k8s-dns-sidecar-amd64         1.14.5              fed89e8b4248        5 weeks ago         41.8MB
gcr.io/google_containers/k8s-dns-kube-dns-amd64        1.14.5              512cd7425a73        5 weeks ago         49.4MB
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64   1.14.5              459944ce8cc4        5 weeks ago         41.4MB
gcr.io/google_containers/kubernetes-dashboard-amd64    v1.7.0              284ec2f8ed6c        5 weeks ago         128MB
gcr.io/google-containers/kube-addon-manager            v6.4-beta.2         0a951668696f        4 months ago        79.2MB
gcr.io/google_containers/pause-amd64                   3.0                 99e59f495ffa        18 months ago       747kB

and docker container ls gives me

CONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS              PORTS               NAMES
3d79bab2a212        gcr.io/google_containers/pause-amd64:3.0               "/pause"                 41 seconds ago      Up 40 seconds                           k8s_POD_cloudconfig-88c867589-qpqph_default_ac2dd8bb-bee1-11e7-8e51-00155d00ba16_0
e6723a726c26        gcr.io/google_containers/k8s-dns-sidecar-amd64         "/sidecar --v=2 --..."   43 minutes ago      Up 43 minutes                           k8s_sidecar_kube-dns-6fc954457d-gvmz6_kube-system_f5de0b0e-be4b-11e7-8699-00155d00ba16_1
36980feeff76        gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64   "/dnsmasq-nanny -v..."   43 minutes ago      Up 43 minutes                           k8s_dnsmasq_kube-dns-6fc954457d-gvmz6_kube-system_f5de0b0e-be4b-11e7-8699-00155d00ba16_1
d3d61e3861f0        gcr.io/google_containers/k8s-dns-kube-dns-amd64        "/kube-dns --domai..."   43 minutes ago      Up 43 minutes                           k8s_kubedns_kube-dns-6fc954457d-gvmz6_kube-system_f5de0b0e-be4b-11e7-8699-00155d00ba16_1
45208e98bd7f        gcr.io/google_containers/kubernetes-dashboard-amd64    "/dashboard --inse..."   43 minutes ago      Up 43 minutes                           k8s_kubernetes-dashboard_kubernetes-dashboard-8hw2w_kube-system_f5bb8241-be4b-11e7-8699-00155d00ba16_1
1fbb3688711d        gcr.io/google_containers/pause-amd64:3.0               "/pause"                 43 minutes ago      Up 43 minutes                           k8s_POD_kube-dns-6fc954457d-gvmz6_kube-system_f5de0b0e-be4b-11e7-8699-00155d00ba16_1
c71ab868584c        gcr.io/google-containers/kube-addon-manager            "/opt/kube-addons.sh"    43 minutes ago      Up 43 minutes                           k8s_kube-addon-manager_kube-addon-manager-minikube_kube-system_9831e93c3188555873fdb49f43198eef_1
1df643d195d2        gcr.io/google_containers/pause-amd64:3.0               "/pause"                 43 minutes ago      Up 43 minutes                           k8s_POD_kubernetes-dashboard-8hw2w_kube-system_f5bb8241-be4b-11e7-8699-00155d00ba16_1
28f48e09fd46        gcr.io/google_containers/pause-amd64:3.0               "/pause"                 43 minutes ago      Up 43 minutes                           k8s_POD_kube-addon-manager-minikube_kube-system_9831e93c3188555873fdb49f43198eef_1

So I'm assuming all the other things are working correctly and kubernetes just somehow doesn't know where to find my image. Does anyone know how I can get it working?

I've found the solution, it's suggested by a user in this github thread

If anyone else ends up on this thread, the solution that worked for me was updating the image pull policy, you can find info on this here. From the docs: Be default, the kubelet will try to pull each image from the specified registry. You need to update this so it can look locally.

If you're running from the CLI, add --image-pull-policy=IfNotPresent to your kubectl run, ie

kubectl run some-node-proj --image=my-awesome-local-image:v1 --image-pull-policy=IfNotPresent

adding --image-pull-policy=IfNotPresent allowed me to run the containers no problem.

Altenatively, I got mine to work by changing the driver from hyperkit to docker. Seems hyperkit has issues with network.

minikube start --driver=docker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM