Reputation: 1
I'm using Kubernetes to deploy my latest app. I've containerized it using docker and when I deploy it with docker it works fine. If I then take the same image and try to deploy it using Kubernetes with
kubectl create deployment mydeploy --image=myimage
I get the following error showing as the status of my pod crashloopbackoff
.
If I log the pod I can see that the app is crashing because of this error:
/bin/sh: 1: [npm,: not found
Even more strange is that if I now try and use that same image in docker again the container fails to start and I get the exact same error in docker. If I rebuild the image it will start working with docker again but I still have yet to get a working deployment with Kubernetes.
I've used the kubectl create deployment
with other peoples' images and it works fine, only seems to be an issue when I'm using the image I am building for my app.
Please help!
Upvotes: 0
Views: 458
Reputation: 11
I actually had this same issue a while back.
The cause of the issue for me had to do with how Kubernetes uses permissions when it is loading the image. I am using Kubernetes on a Mac for all my dev work and in that setup docker and Kubernetes are kinda linked together with docker desktop. The problem is that if Kube doesn't think it has permissions to access the image it will try and create a deployment but won't use the image you specified, because it hasn't been given access. You will get the same error if you have a misspelling your image tag name as well.
In my case the tag name was correct but I needed to push my newly created image up to docker before I tried to run it in Kube. Once I did that Kube had the permissions access it needed to use the image and I was able to deploy without issue.
First I'd check the spelling on your image tag and if that looks good try pushing it to docker before you deploy with Kube. Hope this helps!
Upvotes: 1