Skip to content

Latest commit

 

History

History
94 lines (76 loc) · 2.5 KB

README_KUBES.md

File metadata and controls

94 lines (76 loc) · 2.5 KB

Starting MiniKube

  1. Assuing you have installed MiniKube and Kubectl on your machine, you can start MiniKube by running the following command:
minikube start
minikube status
minikube dashboard
  1. Build Frontend Image in Minikube
eval $(minikube docker-env)
docker build -t 002_imagepro-frontend:latest --file Dockerfile_Frontend .
  1. Create a Deployment for Frontend
kubectl apply -f frontend_kube_deployment.yaml
kubectl apply -f frontend_kube_service.yaml
  1. Add ingress to minikube and verify the nginx controller is running
minikube addons enable ingress
minikube addons enable ingress-dns
kubectl get pods -n ingress-nginx

Note: If running on MacOS you will need to add the following to your /etc/hosts file to ensure ingress works locally

sudo nano /etc/hosts

Add the following line to the file

127.0.0.1       frontend.example.com
  1. Verify the frontend service is running
minikube service frontend-service --url

To visit the frontend open a new terminal and run

minikube tunnel

Then visit the url http://frontend.example.com.

  1. Build Backend Image in Minikube
eval $(minikube docker-env)
docker build -t 002_imagepro-backend:latest --file Dockerfile_Backend .
  1. Create a Deployment for Backend
kubectl apply -f backend_kube_deployment.yaml
kubectl apply -f backend_kube_service.yaml
  1. Create A Volume for Persistent Storage
kubectl apply -f postgres_kube_persistantvolume.yaml
kubectl apply -f postgres_kube_persistantvolume_service.yaml
kubectl apply -f postgres_kube_persistantvolume_statefulset.yaml
kubectl apply -f postgres_kube_persistantvolumeclaim.yaml
kubectl apply -f postgres_kube_secrets.yaml
  1. To restart all pods and services
kubectl delete all --all -n default
  1. Testing Frontend and Backend Connection

To ensure that the frontend and backend pods are connected, you can go to minikube dashboard and enter the frontend pod and run the following command in the exec shell:

curl -X POST "http://backend-service:8000/login" \
     -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" \
     --data-urlencode "[email protected]" \
     --data-urlencode "password=abcdefg" \
     --cookie-jar cookie.txt \
     --cookie cookie.txt \
     --include

You should get a response with a 200 status code and an access token in it for a successful login If you go to the logs of the backend pod, you should see a successful POST /login request