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.
- Frontend - Angular web application built with Ionic Framework
- Backend RESTful API - Node-Express application
Refactoring the Udagram Backend API
The Backend API was separeated into two microservices API as independent services.
The project includes Dockerfiles to successfully create Docker images for /feed, /user backends, project frontend, and reverse proxy.
- Backend Images
Fig 1.0: NodeJs Base Image
Fig 1.1: Backend Users Docker Image
Fig 1.2: Backend Feed Docker Image
Reverse-Proxy
Fig 1.3: Reverse Proxy Docker Image
Fig 1.4: Frontend Docker Image
- Travis Config File
With Travis CI, the independent releases and deployment was automated following DevOps and Security best practices.
The configuration file .travis.yml can be found in the Monolith-Microservices source repo.
Fig 1.5: Travis Configuration File
- Travis Interface - Deployment Status
Fig 1.6: Travis Interface
- Create ConfigMap
Config file or Config.yaml file
POSTGRES_HOST: host_address
POSTGRES_DB: database_name
AWS_BUCKET: bucket_name
AWS_REGION: region
AWS_PROFILE: profile_name
JWT_SECRET: jwt_token
URL: http:
kubectl create -f confimap <name.yaml>
or
kubectl create configmap <configmap_name> --from-file config
- Create Secret
Encode the Data
base64 login_credentials
Create the secret.yaml file
kind: Secret
metadata:
name: env-secret
type: Opaque
data:
POSTGRES_USERNAME: <your_base64_encoded_data>
POSTGRES_PASSWORD: <your_base64_encoded_data>
-
Deployed Microservices using a Kubernetes cluster on AWS
kubectl get pods
Fig 2.1: Deployed Resources
kubectl describe services
Fig 2.2: Sensitive Data Not Expose
- Reverse proxy to direct requests to the appropriate backend
Fig 2.3: Reverse Proxy
-
Scaling and Self-healing for each service
- Replicas Defined in Deployment.yaml
Fig 2.4: Deployment File with 2 Replicas
kubectl apply -f deployment.yaml
kubectl get pods
Fig 2.5: Deployment Status
Note: The next steps depends on Metric Server
Installing metric server can be done in one of the following
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
- Helm charts
Note: Previous Metric Server on helm is deprecated, use the prometheus adaptor instead.
helm install --name my-release stable/prometheus-adapter
-
Autoscaling with CPU Metrics
kubectl describe hpa backend-api
Fig 2.6: Autoscaling with CPU Metrics
Fig 2.7: Debugging DB Connection Request