About the Project - Udagram Microservices

Udagram is a simple cloud application developed alongside the Udacity Cloud Engineering Nanodegree. It allows users to register and log into a web client, post photos to the feed, and process photos using an image filtering microservice. Following are the services involved in this project:

Correspondingly, the project is split into following parts:

  1. The RestAPI Feed Backend, a Node-Express feed microservice.
  2. The RestAPI User Backend, a Node-Express user microservice.
  3. The Simple Frontend - A basic Ionic client web application which consumes the RestAPI Backend.
  4. Nginx as a reverse-proxy server, when different backend services are running on the same port, then a reverse proxy server directs client requests to the appropriate backend server and retrieves resources on behalf of the client.

Dependencies and tools

Tools: npm, Node, ionic cli, Docker, Kubernetes, kubectl, Dockerhub account, travis AWS: aws account, s3 bucket, aws rds postgress database, aws eks cluster

Config

  1. Add file config/configmap with example content
    AWS_BUCKET=your_aws_bucket_name
    AWS_PROFILE=your_aws_app_profile
    AWS_REGION=your_aws_region
    JWT_SECRET=your_jwt_secret
    POSTGRESS_DATABASE=your_db_name
    POSTGRESS_HOST=your_db_host
    POSTGRESS_DIALECT=postgres
    URL=http://localhost:8100 
  1. Add file config/dbusername.txt with content
    your_user_name
  1. Add file config/dbuserpassword.txt with content
    your_user_password
  1. Add file config/credentials - file with your aws credentials

Run application

1. Run with Docker

Build docker container

docker-compose -f deployment/docker/docker-compose-build.yaml build --parallel

Run docker container

docker-compose -f deployment/docker/docker-compose.yaml up

App is running at http://localhost:8100

2. Run with Kubernetes

Create database credentials (env-secret):

kubectl create secret generic env-secret --from-file=POSTGRESS_USERNAME=./config/dbusername.txt --from-file=POSTGRESS_PASSWORD=./config/dbuserpassword.txt

Create aws credentials (aws-secret):

kubectl create secret generic aws-secret --from-file=./config/credentials

Create configmap:

kubectl create configmap env-configmap --from-env-file=./config/configmap

Push all docker images to public Dockerhub account

Create Kubernetes deployments:

kubectl apply -f deployment/k8s/backend-feed-deployment.yaml
kubectl apply -f deployment/k8s/backend-feed-service.yaml
kubectl apply -f deployment/k8s/backend-user-deployment.yaml
kubectl apply -f deployment/k8s/backend-user-service.yaml
kubectl apply -f deployment/k8s/frontend-deployment.yaml
kubectl apply -f deployment/k8s/frontend-service.yaml
kubectl apply -f deployment/k8s/reverseproxy-deployment.yaml
kubectl apply -f deployment/k8s/reverseproxy-service.yaml

Check results:

kubectl get deployments
kubectl get services
kubectl get pods
kubectl get svc

Port forwarding:

kubectl port-forward service/frontend 8100:8100
kubectl port-forward service/reverseproxy 8080:8080

App is running at http://localhost:8100

3. A-B testing

git checkout app-v2

Create docker image:

docker build -t <docker_name>/udagram-frontend .

Push image to Dockerhub:

docker push <docker_name>/udagram-frontend

Create B deployment:

kubectl apply -f deployment/k8s/frontend-deployment.v2.yaml

Check results:

kubectl get deployments
kubectl get pods

4. Rolling updates

git checkout rolling-updates
kubectl apply -f deployment/k8s/frontend-deployment.yaml

Check results:

kubectl get deployments
kubectl get pods
kubectl describe deployment udagram-frontend