This is the Udagram, second project of Udacity Cloud Developer Nanodegree, refactored from monolith to microservices using Docker containers and CI/CD pipelines with Travis and Kubernetes.
Users will be able to post photos to a feed and process it using an image filtering.
These are the components that compose the complete solution:
- A Kubernetes cluster deployed in AWS containing:
- An Ionic frontend UI on it's own pod/container;
- A Node-Express backend REST API for user endpoint on it's own pod/container;
- A Node-Express backend REST API for feed endpoint on it's own pod/container;
- A reverse proxy sitting in front of the REST APIs;
- A Node-Express image filtering microservice on it's own pod/container;
- AWS S3 file store;
- AWS RDS database;
The Ionic frontend consumes the Node-Express REST APIs through the reverse-proxy API Gateway.
The REST APIs communicates with the Ionic Frontend, a S3 file store, the RDS database and with the image filtering microservice.
As per Udacity project evaluation a screenshots folder was created containing all required images of each step of a working project.
The Kubernetes application configuration files are located in kubernetes folder in project root.
- k8s.udagram-dtm.yml - specifies all application services and deployments;
- k8s.configMap.yml - a k8s ConfigMap containing the project environment variables;
- k8s.secrets.yml - a k8s secrets containing the project sensitive environment variables;
- k8s.autoscaler.yml - the horizontal pod autoscaler configuration file;
- k8s.networkPolicy.yml - the ingress network policy for all required pods in the application;
Current Kubernetes Ionic frontend endpoint: Udagram Microservices.
The project is deployed in the AWS cloud, but if you want to try by your own please check the instructions below.
-
Requirements:
- A provisioned AWS S3 file store;
- A provisioned AWS RDS PostgreSQL database;
- Install Node.js (tested with Node.Js 14);
- Install AWS cli;
- Install kubectl;
-
Create an AWS IAM profile or use an existing one for this project;
-
Create an EKS Cluster in AWS with the chosen IAM profile.
- The cluster can be created with a different IAM profile than the actual user that will access and use it. In this case additional steps should be taken. Reference - Managing users or IAM roles for your cluster - To add an IAM user or role to an Amazon EKS cluster section;
- configure the IAM user who created the cluster locally with aws configure;
- use this user to edit the aws-auth ConfigMap
- add the IAM user who will work in the cluster afterwards inside the aws-auth mapUsers section of the ConfigMap;
- The cluster can be created with a different IAM profile than the actual user that will access and use it. In this case additional steps should be taken. Reference - Managing users or IAM roles for your cluster - To add an IAM user or role to an Amazon EKS cluster section;
-
Create a Node Group inside the EKS Cluster with the chosen IAM profile;
-
Update the IAM profile to have access to EKS resources;
-
Configure your local AWS profile with the IAM to be used for this project;
-
Create your k8s.secrets.yml inside kubernetes folder. This secrets should contain the sensitive environment variables necessary to the project:
- RESTAPI_FEED_CLIENT_ID - restapi server client id for server-server jwt token authentication;
- RESTAPI_FEED_PRIVATE_KEY - restapi server private key for server-server jwt token authentication;
- IMG_JWT_SECRET - image filtering microservice secret to generate the jwt server-server access token;
- POSTGRESS_USERNAME - AWS RDS database username;
- POSTGRESS_PASSWORD - AWS RDS database password;
- POSTGRESS_DATABASE - AWS RDS database db name;
- POSTGRESS_HOST - AWS RDS database host address;
- JWT_SECRET - secret to generate the jwt authorization token for frontend;
- AWS_REGION - AWS deployed resources region;
- AWS_PROFILE - AWS IAM profile that has permissions to the project resources;
- AWS_MEDIA_BUCKET - AWS S3 bucket endpoint.
-
To deploy all components in EKS run the command in your terminal:
npm run udagram-dtm
-
Get the reverse-proxy external IP:
kubectl get service -l app=reverse-proxy
-
Update the frontend environment.prod.ts API host with the reverse-proxy external IP;
-
Update the git repository with the new code and trigger Travis CI process;
-
Update kubernetes frontend pod with the latest image;
-
Get your frontend endpoint and access the Udagram app from the browser:
kubectl get service -l app=frontend-ionic