0

I have deployed simple react app on kubernetes through docker-desktop successfully. It was having only one master there. Now I am doing the same thing on AWS Ubuntu EC2 Instance, its having one master and two slave nodes, all are connected properly. Also a demo Nginx server is already deployed successfully on my master EC2 instance.

I am getting ImagePullBackOff status on React deployment/service. Is there any configuration I have to make in EC2 to make it work. How can I debug the things and what could be the reasons for same.

I have followed these guides and you can assume my deployment and service .yml file to be same as provided in these links.

https://dev.to/rieckpil/deploy-a-react-application-to-kubernetes-in-5-easy-steps-516j

https://stackoverflow.com/a/37306838/9465933

I am pushing the pods to local docker registry. Is there any docker secret config's are required for this ? Any help will be highly appreciated.

jeetdeveloper
  • 191
  • 1
  • 13

1 Answers1

3

If you expand on the logs with kubectl describe, you will probably notice that the error is that Kubernetes cannot fetch the image from the registry.

This is due to two things:

  1. You need to create a secret to access your registry. https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/

  2. You said to have a local registry. Is it publicly reachable? Notice that the EC2 instances need to be able to access it. So check port-forwarding, firewall configuration, etc in your LAN.

  • firewall and selinux is disabled. I have run this simple command docker run -d -p 5000:5000 --restart=always --name registry registry:2 . Will this make the registry publicly accessible ? – jeetdeveloper Oct 18 '19 at 08:26
  • Got it I am getting this error Error response from daemon: Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: connect: connection refused -- Also I can successfully connect to localhost nc -nv 127.0.0.1 5000 Connection to 127.0.0.1 5000 port [tcp/*] succeeded!. --Also security goups in AWS is opened. – jeetdeveloper Oct 18 '19 at 08:28
  • @jeetdeveloper you need to forward port 5000 on your router to 5000 on your host. Then you need to change `image: localhost:5000/my-react-app` for `image: :5000/my-react-app`. As you have access to AWS, maybe it's easier for you to just move the registry to another AWS instance, that way you don't need to deal with port forwarding. –  Oct 18 '19 at 08:31
  • thanks for the reply. when I tried this docker push 54.165.169.10:5000/reacttest. I got this error -- Get https://54.165.169.10:5000/v2/: http: server gave HTTP response to HTTPS client --54.x.x.x is my public ip of master ec2 instance – jeetdeveloper Oct 18 '19 at 08:40
  • @jeetdeveloper this is a different issue. You need to also configure an HTTPS to access your docker registry, and if it's using a self-signed certificate, then you need to configure the docker daemon to allow `insecure-registries`. Follow the doc here https://docs.docker.com/registry/deploying/ from `Run an externally-accessible registry` –  Oct 18 '19 at 08:55
  • i am coming across with lot of issues.. next is that when i run Docker command it says --Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? & kubectl command shows this error --The connection to the server 172.31.87.225:6443 was refused - did you specify the right host or port? I have already tried adding my ip to insecure-registries , but it didnt helped. – jeetdeveloper Oct 18 '19 at 10:00
  • @jeetdeveloper I recommend you to open new questions (actually there are plenty of questions already with your same issues) for every new issue you are having. Your original question is solved by this answer, now open new questions so that other people (or myself) can help you out. –  Oct 18 '19 at 10:11
  • I have resolved these issues but I have come back to original issue. how do I make my registry publicly accessible(i.e client can access registry on master). I have tried this :5000/reactapp . Tagged and pushed to local docker registry. still its not working. Can you please tell me how do I fix this. I have 2 worker nodes and 1 master on AWS EC2 instance – jeetdeveloper Oct 18 '19 at 12:51
  • @jeetdeveloper https://docs.docker.com/registry/deploying/. Follow the doc from `Run an externally-accessible registry`. If you have any specific question regarding to this process, open a new question, given that it's different to this one. –  Oct 18 '19 at 13:21