Skip to content

tycloud97/devops-exercise

Repository files navigation

DevOps Assessment



Context

  1. Build a secure and small dockerized hello world Laravel app which can be successfully connected to a MySQL server.
  2. Automate the process of building the app and pushing to a container registry using GitLab.
  3. Bring up an autoscale EC2 cluster as a worker node group of an EKS cluster (For this IaC is enough, no need to apply on real infra)
  4. Automate the deployment of built app on K8s cluster (locally you can use minikube or kind for K8s)
  5. Add documentation of the whole procedure and how you made it well architected.

Tech Stack

  • GitLab: Code Repository for Laravel Application and CI/CD using self hosted runner in EKS (Autoscaling with Kubernetes)
  • Helm: Package and deploy application in K8S.
  • Terraform: Setup Network, provision AWS EKS Kubernetes Cluster, install EKS add-ons, managed some workloads in K8S.
  • AWS Services:
    • Route 53
    • EKS
    • ACM
    • ALB
    • VPC
    • IAM

Tasks

  • Setup EKS Cluster Terraform, structure module, install Helm, EKS add-ons.
  • Clone source code https://github.com/nahidulhasan/laravel-docker-k8s and running local test.
  • Install MySQL K8S, prepare script migrate DB for Laravel, automate pipeline migrate if necessary at the end stage.
  • Setup Helm repository in S3 using Terraform module, base helm chart application.
  • Using Helm app to deploy Dockerfile locally.
  • Using https://github.com/GoogleContainerTools/kaniko to Build Docker in Gitlab CI and publish to ECR.
  • Deploy and manage GitLab Runner in cluster EKS, make Gitlab Pipeline runnable.
  • Using Autoscaler to scale the cluster's worker nodes by number of pods and resources needed.
  • Document, draw architecture, explain how it work.

Architecture Overview

devops.drawio.png

AWS Well-Architected review

Operational Excellence Pillar

  • Almost workloads using Infrastructure as code, automate all tasks managed AWS resources via Terraform tool instead of change manual.

  • Containerize application using Docker, make consistent environment as much as possible, convenient to development and operation.

Security Pillar

  • Database layer deploy in K8S Private Subnet, data store in persistent EBS volumes, avoid missing data when MySQL workload shutdown.

  • Using RBAC to avoid leak AWS IAM access key.

Reliability Pillar

  • Using Helm with Gitlab CI, make manage application workload become fully automated, easy to deploy application with adapting to changing or recreating resources, make consistent between multiple enviroment.

Performance Efficiency Pillar

  • Allocate and utilize resources efficiently based on needed with K8S.

Cost Optimization Pillar

  • Autoscale based on workloads with Kubernetes Cluster Autoscaler.
  • Using spot instances for EKS worker node.

Sustainability Pillar

  • Using EKS managed, reduce task relative to master node K8S.

  • Using Add-ons/Plugin EKS to automatic create resources necessary, for example create Route53, create ALB, EBS...

Results

Link: https://bebi.store/

Account: typrone1@gmail.com | 123123

Repository:

Screenshot:

References

Useful CLI

helm s3 init s3://ty-helm/stable/myapp
helm repo add stable-myapp s3://ty-helm/stable/myapp/
helm repo add gitlab https://charts.gitlab.io
aws eks --region ap-southeast-1 update-kubeconfig --name ty-dev-eksdemo
kubectl get pods --all-namespaces | grep -i running | wc -l
helm upgrade --namespace default gitlab-runner -f gitlab-runner-values.yaml gitlab/gitlab-runner
php artisan key:generate
php artisan migrate
helm s3 push --force ./app-0.0.1.tgz stable-myapp
docker build -t laraveldemo .  --platform=linux/amd64\ndocker tag laraveldemo:latest 827539266883.dkr.ecr.ap-southeast-1.amazonaws.com/laraveldemo:latest\ndocker push 827539266883.dkr.ecr.ap-southeast-1.amazonaws.com/laraveldemo:latest
helm upgrade devops-laravel devops/app --install --force --namespace devops-laravel -f deployment/dev.yaml --set image.repository=${DOCKER_IMAGE},image.tag=${DOCKER_TAG} -->

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages