This repository contains the steps to create, containerize, and deploy a React Quiz application using Docker, Kubernetes, and HPA for autoscaling
- Docker installed on your machine
- Minikube installed for Kubernetes
- kubectl installed for managing Kubernetes clusters
Create a new React application using the following command:
npx create-react-app my-quiz-app
Download and install Docker from the Docker website.
Create a Dockerfile in the root directory of your React app: React-Docker-Kubernetes/Reactquiz-Docker/dockerfile
Create a .dockerignore file in the root directory of your React app: React-Docker-Kubernetes/Reactquiz-Docker/.dockerignore
Use the following commands to build and run your Docker container:
docker build .
docker images
docker run -p 3000:3000 <image-id>
You can now access your React app in the browser at http://localhost:3000.
Download and install Minikube from the Minikube website.
Download and install kubectl from the Kubernetes website.
React-Docker-Kubernetes /kubernetes files
Use the following commands to apply the YAML files and manage your Kubernetes resources:
kubectl apply -f file.yaml
kubectl get pods
kubectl get services
minikube ip
minikube service <SERVICE_NAME> --url
kubectl delete pods --all
Access your app in the browser using the Minikube IP address and the port number from the service.
To use autoscaling, you need to apply the metrics server. Navigate to the metrics_server directory and apply all files: React-Docker-Kubernetes/Metric files/
kubectl apply -f
Create the HPA (Horizontal Pod Autoscaler) YAML files.
React-Docker-Kubernetes /kubernetes files
kubectl apply -f file.yaml
kubectl top nodes
kubectl get hpa
kubectl run -i --tty load-generator --rm --image=busybox --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://<hpa-demo-deployment>; done"
docker push <docker-username>/<app-name>
docker pull saisamarth21/reactquiz-docker
docker pull ghcr.io/saisamarth21/react-docker:latest