Udacity Microservices Project
In this repo, there are 4 services with containerization and kubernetes incorporated.
They are:
- Frontend application
- Backend user service
- Backend feed service
- Reverse Proxy
Travis CI Screenshot can be found here
Getting Started
- Clone the github project by running:
git clone [email protected]:makinwab/microservice-project-udacity.git
- Update the following configuration files
- Update your .profile or .bash_profile with the values for the following environment variables
- POSTGRESS_USERNAME
- POSTGRESS_PASSWORD
- POSTGRESS_DB
- POSTGRESS_HOST
- URL=http://localhost:8100
- AWS_REGION
- AWS_PROFILE
- AWS_BUCKET
- JWT_SECRET
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
Running the application
-
Change working directory to the application e.g.
cd udacity-restapi-feed
-
Install the dependencies for each project
npm install
Using docker
NB: The necessary docker images are available on docker hub under my profile.
- Build the docker images
docker-compose -f udacity-c3-deployment/docker/docker-compose-build.yaml build --parallel
- Run the container
docker-compose up
Access the frontend in the browser with url http://localhost:8100
Access the API via postman using http://localhost:8080/api/v0
Using kubernetes
-
Follow the instructions here get set up with kubernetes and ensure
kubectl get nodes
works as expected -
Apply each .yaml configuration file in the k8s folder
kubectl apply -f aws-secret.yaml
kubectl apply -f backend-feed-deployment.yaml
Do the same for the rest ensuring the secret files are applied first then the backend and front end service and deployments followed by the reverse proxy service and deployment files
- Start the reverseproxy service
kubectl port-forward service/reverseproxy 8080:8080
- Start the frontend service
kubectl port-forward service/frontend 8100:8100
Access the frontend in the browser with url http://localhost:8100
Access the API via postman using http://localhost:8080/api/v0
Scaling the application
Scaling the app up/down can be done using
kubectl scale deployment/backend-feed --replicas 1