phanhuutoan / udacity-devops-capstone

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Udacity Capstone project: K8S-TODO LIST APP

Using AWS, K8S (EKS), cloudformation and circleCI to build it.

Table of content

  1. Proposal
    1. AWS architecture
    2. K8S cluster
    3. AWS CICD solution
  2. Presetup
    1. Setup AWS network
    2. Setup EKS Cluster
    3. Running k8s cluster locally
    4. Deploy our cluster to EKS
  3. Project brochure

1. Proposal

1.1 AWS architecture

  • Using VPC, Subnet, SG, EKS, RDS, Cloudformation
  • Diagram: AWS architect
  • images:

1.2 K8S cluster

1.3 CI/CD process

2 Pre-setup

Before we bring the CICD pipeline we need to presetup the infra

2.1 Prepare network infra by running:

# Create infra
IaC/script/deploy-network.sh create false

# Update infra
IaC/script/deploy-network.sh udpate false

2.2 Prepare eks cluster (AWS cluster) by running:

# Create infra
IaC/script/deploy-eks.sh create false

# Update infra
IaC/script/deploy-eks.sh update false

2.3 Running the project locally:

  1. You need to install kubectl using Docker Desktop or minikube
# Create secret using kubectl name DB_PASSWORD
kubectl create secret generic database-credential --from-literal DB_PASSWORD=abc
  1. Running everything up using: kubectl apply -f k8s/local
  2. Change your /etc/host file to point local-capstone.com to 127.0.0.1
  3. After running the project success fully you can run kubectl get pods to check if there are 2 deployments todo-be and todo-fe, you also need to update env file of todo-fe for proper domain (local-capstone.com) or whatever you setup.
  4. Go to local-capstone.com and enjoy the result

2.4 Deploy to EKS

1 .You have to install and config IAM role for ACK using this instruction: https://aws-controllers-k8s.github.io/community/docs/user-docs/install/

# Create secret using kubectl name DB_PASSWORD
kubectl create secret generic database-credential --from-literal DB_PASSWORD=abc

=> You need to update your kubeconfig file using this instruction in order to connect EKS cluster: aws eks update-kubeconfig --region region-code --name my-cluster 2. Install rds using this instruction: https://aws-controllers-k8s.github.io/community/docs/tutorials/rds-example/ (Sometimes ACK is not stable so instead of using ACK you still can create RDS manually and push DB credential to Configmap named rds-configmap)

  1. By this way, we are able to create RDS via k8s cluster (EKS).
  2. Go to your cloudformation output to check and change the value insde file k8s/prod/db-instance.yml
  3. Deploy everything to EKS by using kubectl apply -f k8s/prod
  4. install ingress-nginx using this instruction: https://kubernetes.github.io/ingress-nginx/deploy/#aws
  5. Deploy ingress controller using kubectl apply -f ingress.yml
  6. You will reveive a load-balancer link:

in my case: [a0d120f18bc6b4653b9f5013cf30053e-6c146ae369ac8bdc.elb.us-east-1.amazonaws.com] 9. I bought a cheap domain named **schoolx.host** and add an CNAME to it so from now we can use schoolx.host to refer to LB domain above. To see how the website look like:

3. Project brochure

About


Languages

Language:TypeScript 66.4%Language:Shell 20.6%Language:HTML 7.1%Language:JavaScript 3.1%Language:CSS 1.5%Language:Berry 1.3%