kubernetes ImagePullBackOff - docker

kubectl run docapp --image=docapp:v1 --port=8080
After deploying nodejs into kubernetes, im getting ImagePullBackOff, Please suggest the solutions.
I have attached snapshot below...
imagepullbackoff
minikube dashboard

There is no image named "docapp" in official namespace in dockerhub. If you mean this image: https://hub.docker.com/r/alexkott/docapp/ you need to specify in your image the namespace so it will be: alexkott/docapp

Related

Can't create pods in kubernetes

I am following a tutorial, where a pod is created using the below command:
kubectl run firstPod --image={image from dockerhub repository}
But I am getting the following error:
Error from server (Forbidden): pods "firstPod" is forbidden: error looking up service account default/default: serviceaccount "default" not found
The goal of command is to pull docker image from my own repository and use it to create pod. I saw already some solutions that use .yaml file (but I didn't like the answer). All I want is to run this command. I am using windows 10 and docker desktop for a kubernetes cluster (minikube etc.).
You can test it with network-multitool. It will keep on running a webserver and have a lot of great tools.
kubectl run multitool --image=praqma/network-multitool --replicas=1
If that works, find the podname
kubectl get pods
Then you can exec into it with the name you found above
kubectl exec -it multitool-3822887632-pwlr1 bash
From inside the container/pod you can tjek that the webserver is running by
curl localhost
If the first command doesnt work, then something is wrong.
Check if the service account exists
kubectl get sa
Thanks for answers. Now I realize, that I forget to start my local cluster minikube.
minikube start
Now it is ok to create a pod.

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

Why is my Kubernetes deployment registering as unavailable even though it runs in Docker?

I have a docker image I have created that works on docker like this (local docker)n...
docker run -p 4000:8080 jrg/hello-kerb
Now I am trying to run it as a Kubernetes pod. To do this I create the deployment...
kubectl create deployment hello-kerb --image=jrg/hello-kerb
Then I run kubectl get deployments but the new deployment comes as unavailable...
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hello-kerb 1 1 1 0 17s
I was using this site as the instructions. It shows that the status should be available...
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hello-node 1 1 1 1 1m
What am I missing? Why is the deployment unavailable?
UPDATE
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-kerb-6f8f84b7d6-r7wk7 0/1 ImagePullBackOff 0 12s
If you are running a local image (from docker build) it is directly available to the docker daemon and can be executed. If you are using a remote daemon, f.e. in a kubernetes cluster, it will try to get the image from the default registry, since the image is not available locally. This is usually dockerhub. I checked https://hub.docker.com/u/jrg/ and there seems to be no repository and therefore no jrg/hello-kerb
So how can you solve this? When using minikube, you can build (and provide) the image using the docker daemon that is provided by minikube.
eval $(minikube docker-env)
docker build -t jrg/hello-kerb .
You could also provide the image at a registry that is reachable from your container runtime in the kubernetes cluster, f.e. dockerhub.
I solved this by using kubectl edit deployment hello-kerb then finding "imagePullPolicy" (:/PullPolicy). Finally I changed the value from "Always" to "Never". After saving this when I run kubectl get pod it shows...
NAME READY STATUS RESTARTS AGE
hello-kerb-6f744b6cc5-x6dw6 1/1 Running 0 6m
And I can access it.

Image pull fail when creating a pod

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

How do I set sysctl key in kubernetes pod on a minikube node?

I'm using k8s v 1.7. Following the guide in docs, my deployment has the following in its spec:
annotations:
security.alpha.kubernetes.io/unsafe-sysctls: net.core.somaxconn=16384
But when applying that using kubectl, I get the following error:
forbidden sysctl: "net.core.somaxconn" not whitelisted
Now the docs say I should run something like this in the node:
kubelet --experimental-allowed-unsafe-sysctls 'net.core.somaxconn'
But I don't know where to run that command. I tried inside minikube ssh but kubelet doesn't seem to be installed.
I'm looking for something like:
minikube start --extra-config='allow net.core.somaxconn'
I tried with this and it seemed to work
minikube start --extra-config=kubelet.AllowedUnsafeSysctls=net.core.somaxconn
Extracted from here: https://github.com/kubernetes/kubernetes/blob/master/cmd/kubelet/app/options/options.go

Resources