Deploy React app to kubernetes on AWS EC2

Deploy React app to kubernetes on AWS EC2

ยท

1 min read

  • First we need to setup and configure minikube on AWS EC2 instance.

  • Checkout this for setup minikube on AWS EC2 instance: https://blog.kubekode.org/setup-minikube-on-aws-ec2-instance

  • We already have a docker image for React todo list application on docker hub: https://hub.docker.com/repository/docker/kubekode/react-todo-list-app/general

  • Deploy a pod with the react todolist app image

  •   kubectl run todolistapp --image=kubekode/react-todo-list-app
    
  • Deploy a NodePort service for this pod.

  •   kubectl expose pod todolistapp --type=NodePort --port=80 --name=todolistapp-service
    
  • Check service is working or not

  •   minikube service todolistapp-service --url
    
  • Request the URL using curl to check it's working or not.

  •   curl <URL>
    
  • Now We want to access our application from outside.

  • Make sure you've enabled port 3000 for ingress traffic in AWS Instance security group.

  • Now Just use kubectl port-forward to forward the traffic from 3000 port to 80 port on our pod.

  •   kubectl port-forward svc/todolistapp-service 3000:80 --address 0.0.0.0 &
    

Now just paste your instance public IP in your browser and boom your application is deployed.


ย