Image pull fail when creating a pod - docker

Just testing on local machine. Windows 7 x64, Minikube 1.14, docker toolbox.
$docker image ls does show the image I would like to use.
REPOSITORY myname/hello-service
TAG 0.0.6
IMAGE ID xxxxxxxxxxx
In my Pod yaml:
spec:
containers:
-name: my-pod
image: myname/hello-service:0.0.6
After running $kubectl create -f pod.yaml. It failed
Error: ImagePullBackOff
Failed to pull image "xxxxx" rpc error: code = ... manifest for myname/hello-service:0.0.6 not found
But the previous version :0.0.5 works just fine.
Both image are build on my machine and store in "default" of docker.

Can it be that myname/hello-service:0.0.6 is only on your windows host? If so, minikube cannot find it.
You have a few options to access in Minikube. One of them is building your local image with minikube's Docker daemon. Another is running a private local Docker registry.
A few examples for this and more I found are [well described here].(https://www.edureka.co/community/17481/local-docker-image-on-minikube)

Try to push it on DockerHub first
docker tag <imageid> <usrDockerHub>/<image_name>:<version>
docker push <usernameDockerHub>/<nome immagine>:<tag>
and try again kubectl create -f pod.yaml

Related

Unable to PULL image into minikube from insecure private registry - http: server gave HTTP response to HTTPS client

On Ubuntu 18, I installed Docker (19.03.12) from these instructions
https://docs.docker.com/engine/install/ubuntu/
And then went through these steps
manage docker as non-root user
https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user
start on boot using systemd
https://docs.docker.com/engine/install/linux-postinstall/#configure-docker-to-start-on-boot
and set up a private docker registry using this
docker run -d -p 5000:5000 -e REGISTRY_DELETE_ENABLED=true --restart=always --name registry registry:2
I also added this to the daemon.json file
{ "insecure-registries" : ["my.registrydomain.lan:5000"] }
And restarted the docker daemon
sudo /etc/init.d/docker restart
I checked docker info to make sure the setting for insecure registry was applied and I saw this at the end so it seems ok
Insecure Registries:
my.registrydomain.lan:5000
127.0.0.0/8
On the same machine I start minikube (1.12.3) with this command
minikube start --driver=docker --memory=3000 --insecure-registry=my.registrydomain.lan:5000
So everything is running and fine, and I proceed to apply my deployments using kubectl except when I get to the pod that needs to pull the container form the local registry I get an ErrImagePull status. Here is part of my deployment
spec:
containers:
- name: my-container
image: my.registrydomain.lan:5000/name:1.0.0.9
imagePullPolicy: IfNotPresent
When I describe the pod that failed using
kubectl describe pod mypod-8474577f6f-bpmp2
I see this message
Failed to pull image "my.registrydomain.lan:5000/name:1.0.0.9": rpc
error: code = Unknown desc = Error response from daemon: Get
https://my.registrydomain.lan:5000/v2/: http: server gave HTTP
response to HTTPS client
EDIT: I forgot to mention that I am able to PUSH my images into the registry without any issues from a separate machine over http (machine is Windows 10 and I set the insecure registry option in the daemon config)
I tried to reproduce your issue with exact same settings that you provided and this works just fine. Image is being pulled without any problem. I tested this with my debian 9 and fresh ubuntu installation with this settings:
minikube version: v1.12.3
docker version: v19.03.12
k8s version: v1.18.3
ubuntu version: v18
What I`ve done what is not described in the question is to place an entry in minikube container hosts file:
root#minikube:/# cat /etc/hosts
...
10.128.5.6 my.registrydomain.lan
...
And the tag/push commands:
docker tag 4e2eef94cd6b my.registrydomain.lan:5000/name:1.0.0.9
docker push my.registrydomain.lan:5000/name:1.0.0.9
Here`s the describe from the pod:
Normal Pulling 8m19s (x5 over 10m) kubelet, minikube Pulling image "my.registrydomain.lan:5000/name:1.0.0.9"
As suggested in the comments already you may want to check this github case. It goes thru couple of solution of your problem:
First is to check your hosts file and update it correctly if you hosting your repository on another node. Second solution is related to pushing images in to repository which turned for the user that both insecure-registries and docker push command are case sensitive. Third one is to use systemd to control docker daemon.
Lastly If those would not help I would try to clear all settings, uninstall docker, clear docker configuration and start again from scratch.

error: unable to find container in kubectl set image

I am trying to push an update to my codebase for my docker image. I have the docker image on kubernetes on GCP and I followed the way it was mentioned in the document here.
I even pushed the image with :v2 tag to the container registry and that image is visible in the console as well. But now when I am trying to run:
kubectl set image deployment/clustername myImageName=gcr.io/${PROJECT_ID}/myImageName:v2
it gives me the following error:
error: unable to find container myImageName
I know that the image is there because I build it with
docker build -t gcr.io/${PROJECT_ID}/myImageName:v2 .
I have also fixed the issue of: Error from server (NotFound): deployments.extensions
I am stuck at this very moment. Can anyone throw some light on it?
The error message specifies that your deployment doesn't have a container named myImageName.
The syntax for kubectl set image is:
kubectl set image deployment-name container-name=image-name
container-name must be the name of a container you specified inside your deployment under spec.template.spec.containers.name.
check 'myImageName' container name is matching in the pod description.
Try command : kubectl describe pods
In pod description check the following under 'Containers' section: In the below example 'avroconsumerclient' is the name of the container.
Containers:
avroconsumerclient:
Container ID: docker://ab5890be34dfk5678dfdf5670ac19583d8859427695a258d4fdfd
Image: ************/democlient:v2
Image ID: docker-pullable://********/democlient#sha256:71e97df533915d62c433c2c04168bb7b1dd545c7ef423169a1452ac5abd4302e
Port: <none>
Host Port: <none>
State: Running
The documentation on the GCP hello-app tutorial has the syntax wrong. It should be:
kubectl set image deployment/clustername
clustername=gcr.io/${PROJECT_ID}/myImageName:v2
rather than:
kubectl set image deployment/clustername
myImageName=gcr.io/${PROJECT_ID}/myImageName:v2
Your command is wrong you have to remove the myImageName before the image url and pass the command
kubectl set image <deployment name> gcr.io/${PROJECT_ID}/myImageName:v2

K8S Failed to pull image from local repo

I have an image in my docker repository. I an trying to create POD out of it but K8S is giving the following error.
Failed to pull image "cloudanswer:latest": rpc error: code = Unknown desc = Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
It seems K8S is connecting to https://registry-1.docker.io/v2/ instead of taking from local docker repository.
How to make K8S take image for local docker repository ?
If you use single node in your cluster, make sure this docker image is available on this node.
You can check via
docker image ls
Also set the imagePullPolicy to Never, otherwise Kubernetes will try to download the image.
Multiple node cluster, you can use docker registry image.
Use a local registry:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
Now tag your image properly:
docker tag ubuntu <dns-name-of-machine>:5000/ubuntu
dns name of the machine running registry container should be reachable by all nodes in network
Now push your image to local registry:
docker push <dns-name-of-machine>:5000/ubuntu
You should be able to pull it back:
docker pull <dns-name-of-machine>:5000/ubuntu
Now change your yaml file to use local registry.
imagePullPolicy should be set to IfNotPresent to pull images from local docker repo
Kubernetes supports a special type of secret that you can create that will be used to fetch images for your pods. More details here

kubectl run-ing a tarball'd image

I am trying to run a Nix-built Docker image in tarball form. With docker, docker load -i <path> followed by a docker run works fine. Now I've uploaded the tarball to Artifactory and am trying to run the image on K8s with something like:
$ kubectl run foo-service --image=<internal Artifactory>/foo-service/foo-service-latest.tar.gz
However all I see is:
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
foo-service 1 1 1 0 2h
Is it possible to load an image from a (remote) tarball in K8s? If yes, what is the command to do so?
There is no way to do that directly in Kubernetes.
You can do docker load and then docker push to a registry (you can host a private registry in Kubernetes or use a public one) and after that kubectl run.
Minikube also has a registry addon for local development.

Openshift pods crash

I have created image locally (docker image)
and when i run image witg oc run AA --image=(docker image name).
It runs and crashes after few seconds. There is no log in oc and docker.
Error in oc describe is crashloopbackoff
Try prepending the minishift/openshift internal docker registry to the docker image name:
# e.g. get the registry address
$ minishift openshift registry
172.30.1.1:5000
$ oc run AA -i -t --image=172.30.1.1:5000/<project>/<docker image name>:<tag>

Resources