k8s use the local docker image

2/9/2020

When I was trying to create a deployment in microk8s, I got some problem with docker images.

My yaml looks like this,as you can see,I use the IfNotPresent ImagePullPolicy to create my deployment:

enter image description here

I pull the image to my docker:

enter image description here

However, it seems k8s cannot find the images inside my computer:

enter image description here enter image description here

Anyone can help me to solve the problem?

-- 朱江源
kubernetes
microk8s

1 Answer

2/11/2020

Posting @朱江源 solution as community wiki.

Use "docker tag k8s.gcr.io/heapster-grafana-amd64:v1.3.3 {your dockerhub account}/heapster-grafana-amd64:v1.3.3" to rename your image.

Then use "docker push {your dockerhub account}/heapster-grafana-amd64:v1.3.3" to push the image into you dockerhub. At the same time, you need to change the image location of your pod to "{your dockerhub account}/heapster-grafana-amd64:v1.3.3". In this way, you can use "docker create -f xxx,yaml" to create your pod.

Additionally there are container registry proxies for users from China:

global                 proxy in China       format

dockerhub (docker.io)  dockerhub.azk8s.cn   dockerhub.azk8s.cn/<repo-name>/<image-name>:<version>
gcr.io                 gcr.azk8s.cn         gcr.azk8s.cn/<repo-name>/<image-name>:<version>
quay.io                quay.azk8s.cn        quay.azk8s.cn/<repo-name>/<image-name>:<version>
mcr.microsoft.com      mcr.azk8s.cn         mcr.azk8s.cn/<repo-name>/<image-name>:<version>
-- KFC_
Source: StackOverflow