The following tools need to be installed on your local machine
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.
The project is split into three parts:
A basic Ionic client web application which consumes the RestAPI Backend.
clone the repository
git clone git@github.com:boraoren/microservice-nodejs.git
touch ~/.profile
- add texts below to
~/.profile
POSTGRESS_USERNAME=udagram
POSTGRESS_PASSWORD=password
POSTGRESS_DB=udagram
POSTGRESS_HOST=postgresql
- go to udacity-c3-deployment/docker directory
- run
docker-compose up
command
- run
The application is running in a Kubernetes Cluster on AWS.
-
AWS S3
- Create an AWS/S3 bucket which name is {YOUR_NAME}-udacity-microservice-bucket
- give permission
{ "Version": "2012-10-17", "Id": "Policy1565786082197", "Statement": [{ "Sid": "Stmt1565786073670", "Effect": "Allow", "Principal": { "AWS": "__YOUR_USER_ARN__" }, "Action": [ "s3:GetObject", "s3:PutObject" ], "Resource": "__YOUR_BUCKET_ARN__/*" }] }
- CORS configuration
<?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>POST</AllowedMethod> <AllowedMethod>DELETE</AllowedMethod> <AllowedMethod>PUT</AllowedMethod> <MaxAgeSeconds>3000</MaxAgeSeconds> <AllowedHeader>Authorization</AllowedHeader> <AllowedHeader>Content-Type</AllowedHeader> </CORSRule> </CORSConfiguration>
-
Kubernetes Cluster
- add texts below to
~/.profile
AWS_REGION=${YOUR_AWS_REGION} AWS_PROFILE=${YOUR_AWS_PROFILE} AWS_BUCKET=${__YOUR_NAME-udacity-microservice-bucket} URL=http://localhost:8100 JWT_SECRET=${YOUR_JWT_SECRET}
- terraform
- go to
terraform/aws
directory - run
terraform init
command - set values
- variables.tf line 59
default
to your AWS region - variables.tf line 33
default
to your SSH public key file path
- variables.tf line 59
- run
terraform plan
command to confirm- enter a value: udagram
- run
terraform apply
command to execute for AWS- enter a value: udagram
- enter
yes
after running the command.
- run
terraform output -json > tf.json
to create state that will be used by kubeone
- go to
- kubernetes
- go to
terraform/aws
directory - run in terminal
export AWS_ACCESS_KEY_ID=${YOUR_AWS_ACCESS_KEY_ID}"
- run in terminal
export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}"
- run
kubeone install config.yml --tfjson tf.json
command- if
Error: failed to install prerequisites: at least one of the tasks has encountered an error
occurs,
- if
- set environment for kubeone
KUBECONFIG=$PWD/udagram-kubeconfig
- go to
- add texts below to
-
Postgresql Database
- Create AWS/RDS/Postgresql instance which name is
udagram
- Terraform step created security group automatically
so you should add
udagram_common
security group to your Postgresql database instance to let services access to your database.
- Create AWS/RDS/Postgresql instance which name is
-
Deploy Application
- replace
.profile
filePOSTGRESS_HOST
key
withEndpoint
(you can find endpoint from AWS Web Dashboard RDS Panel Connectivity & Security Tab) - go to
udacity-c3-deployment/docker
directory - find and replace
borasmus
container image names at below by your own docker hub name;- backend-user-deployment.yaml
- backend-feed-deployment.yaml
- frontend-deployment.yaml
- reverseproxy-deployment.yaml
- docker-compose-build.yaml
- docker-compose.yaml
- login to your dockerhub
docker login --username=__YOUR_USER_NAME__ --email=__YOUR_EMAIL__
- build your images
docker-compose -f docker-compose-build.yaml build --parallel
- push your builded images to dockerhub
docker-compose -f docker-compose-build.yaml push
- go to
udacity-c3-deployment/k8s
directory - run
deploy_services.sh
command - run
deploy.sh
command - add CloudWatch agent
- go to
udacity-c3-deployment/k8s/fluentd
directory - run
deploy_fluentd.sh
command
- go to
- replace
- go to
terraform/aws
directory - run
kubeone reset config.yml
command - run
terraform destroy