Client → ALB → Email Checker (MS) → SQS → Queue Checker (MS) → S3
Components:
- Amazon VPC
- Amazon EKS
- AWS Load Balancer Controller (ALB)
- Amazon SQS
- Amazon IAM
- Amazon S3
- Amazon EC2 Instances
- AWS SSM Parameter Store
- Amazon ECR
- Terraform
- Jenkins
- HELM
REST API receiving POST requests and publishing validated payloads to SQS.
Worker that polls SQS and uploads messages to S3.
- AWS CLI
- HELM
- kubectl
Please change the CIDR block of the Jenkins ALB SG ingress before executing this code block. You can find it in terraform/jenkins-ec2/alb.tf. It mapped to my personal IP due to security reasons (Jenkins should be accessible to RnD teams only).
SERVICES=("remote-backend" "s3-buckets" "ssm" "sqs" "ecr" "vpc" "jenkins-ec2" "eks" "iam-roles" "jenkins-jobs")
cd terraform
for folder in $SERVICES; do
cd $folder
terraform init
terraform apply
cd ..
done
cd ..You can add/remove Jenkins agents by changing the local jenkins_agents inside jenkins-ec2/data.tf
and re-apply terraform for jenkins-ec2 folder.
aws eks update-kubeconfig --region eu-west-1 \
--name bensaada-home-assignment \
--alias bensaada-home-assignmenthelm upgrade --install aws-load-balancer-controller \
./k8s-configuration/charts/aws-load-balancer-controller \
-f ./k8s-configuration/charts/aws-load-balancer-controller/values.yaml \
-n kube-systemExecute the following command to get the DNS of Jenkins:
aws elbv2 describe-load-balancers --names 'jenkins-alb' \
--query "LoadBalancers[0].DNSName" --output textExecute the following command to get the admin user password:
aws ssm get-parameter --name '/jenkins/admin-password' --with-decryption \
--query "Parameter.Value" --output textIF JENKINS CAN'T DEPLOY TO KUBERNETES CLUSTER PLEASE TRY EXECUTE THE CODE BELOW AND RESTART YOUR JENKINS BUILD
cd ./terraform/eks
terraform apply -replace=aws_eks_access_entry.jenkinsEMAIL_CHECKER_DNS=$(kubectl get ingress email-checker -n microservices -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
TOKEN=$(aws ssm get-parameter --name '/email-checker/validation-token' --with-decryption --query "Parameter.Value" --output text)
curl -X POST "http://${EMAIL_CHECKER_DNS}/send" \
-H "Content-Type: application/json" \
-d '{"data":{"email_subject":"Happy new year!","email_sender":"John doe","email_timestream":"1693561101","email_content":"Just want to say... Happy new year!!!"},"token":"'"${TOKEN}"'"}'GRAFANA_ADMIN_PASSWORD=$(aws ssm get-parameter --name '/grafana/admin-password' --with-decryption --query "Parameter.Value" --output text)
helm dependency build ./k8s-configuration/charts/kube-prom-stack
helm upgrade --install kube-prometheus-stack ./k8s-configuration/charts/kube-prom-stack \
--namespace monitoring --create-namespace \
-f ./k8s-configuration/charts/kube-prom-stack/values.yaml \
-f ./k8s-configuration/values/kube-prom-stack.yaml \
--set kube-prometheus-stack.grafana.adminPassword="${GRAFANA_ADMIN_PASSWORD}"Get Grafana DNS from here:
kubectl get ingress kube-prometheus-stack-grafana \
-n monitoring \
-o jsonpath='{.status.loadBalancer.ingress[0].hostname}'Get Prometheus DNS from here:
kubectl get ingress kube-prometheus-stack-prometheus \
-n monitoring \
-o jsonpath='{.status.loadBalancer.ingress[0].hostname}'