Skip to content

Setup an EKS Kubernetes Cluster named "DB" using Terraform and deploy Jenkins using Helm Charts. Once Jenkins is running, setup your host server as a worker node running Terraform.

Notifications You must be signed in to change notification settings

Ohubabs/DB-Pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DB-Pipeline

DragonBall Project 1

Background

This is the first portion of a 7-part project series to launch the following stateless and stateful application below in an EKS cluster with Fargate and Managed Nodes using a CI/CD pipeline setup in Jenkins named DB:

  1. A Login SpringBoot Java Application
  2. A MongoDB database

In addition, you will provision an EC2 instance using terraform that will have Docker installed then connected to Jenkins as a Worker Node and deploy SonarQube in the DB cluster to perform code quality testing on the Springboot application. Finally, you will launch monitoring tools Prometheus and Grafana to track the performance of all active applications in the DB cluster

Project 1 Scenario

For this project, perform the following tasks:

  1. Setup an EKS Cluster named “DB”
  2. Deploy a Jenkins application into the cluster
  3. Configure the Jenkins application with persistent storage
  4. Create a custom url for your Jenkins application that’ll be registered to AWS via External DNS connected to Route 53
  5. Encrypt your site using Cert-Manager and Let’s Encrypt
  6. Expose your application securely to the internet with SSL encryption using a NGINX ingress behind an Application LoadBalancer.
  7. Login to Jenkins from a browser and install necessary plugins such as SSH server, Publish Over SSH, Pipeline Stage View, Docker, etc…
  8. Edit the Jenkins system to be monitored by Prometheus and add tools such as Maven for your project.
  9. Add credentials for your Worker Node Server
  10. Add your host server, with Terraform, Kubernetes, and Java, installed to your Jenkins server as a worker node to remotely run tasks on it.

Prerequisites

  • Visual Studio Code
  • Knowledge on Kubernetes, Terraform, Helm Charts, AWS, CI/CD pipelines and Visual Studio Code/IDEs

Setup Jenkins in EKS Cluster

Step 1: Create a Non-root user with Sudo privileges and install: AWS CLI v2, Terraform, Kubectl, and Java by running the shell script.

      sh db.sh

Afterwards switch into the new user and clone this repository

Step 2: Deploy DB EKS Cluster and VPC with necessary permissions via IAM Service accounts to configure pods with access to EBS storage, VPC networking, and Application LoadBalancer Network Trafficking to expose deployed applications to the internet. Note:- It will take 10 – 20 mins for your cluster to be deployed.

  • Enter the eks/ directory

  • Execute the following commands:

    terraform init
    

    Screenshot 2024-10-02 at 12 23 04 PM

    Screenshot 2024-10-02 at 12 23 17 PM

    terraform validate
    

Screenshot 2024-10-02 at 12 23 38 PM

      terraform plan

Screenshot 2024-10-02 at 12 24 45 PM

    terraform apply --auto-approve

Screenshot 2024-10-02 at 12 27 12 PM

Screenshot 2024-10-02 at 12 44 22 PM

Step 3: Update Kubeconfig after cluster deployment by executing the aws commad:

    aws eks update-kubeconfig --name <name-of-cluster> --region <region-of-cluster-deployment

Screenshot 2024-10-02 at 12 45 05 PM

Check that your cluster is created by checking your EC2 managed nodes

    kubectl get nodes

Screenshot 2024-10-02 at 12 47 10 PM

Step 4: Setup Namespaces within DB Cluster.

  • Enter the namespace/ directory

  • Execute the following commands:

    terraform init
    

    Screenshot 2024-10-02 at 12 51 04 PM

    terraform apply --auto-approve
    

Screenshot 2024-10-02 at 12 51 22 PM

Step 5: Setup Secrets within DB Cluster.

  • Enter the Kamehouse / directory
  • Edit the var.tf file with your AWS credentials, which will be used for issuing certificates to SSL encrypt your websites, and Jenkins admin login details.

image

  • Execute the following commands:

    terraform init
    

    Screenshot 2024-10-02 at 12 55 11 PM

    terraform plan
    

    Screenshot 2024-10-02 at 12 55 34 PM

    terraform apply --auto-approve
    

Screenshot 2024-10-02 at 12 55 53 PM

Step 6: Deploy the External DNS helm chart for the application to handle setting up apps within the DB Cluster with domain names/url for easy access on the internet and the Cert-Manager Helm Chart to use the cert-manager application to issue and manage Lets Encrypt certificates.

  • Enter the cert-dns/ directory
  • Edit the dns-values.yml file by entering the arn for the IAM Service Account role you created for the External DNS to be launched in your cluster to register domains created in the cluster with your AWS Route 53 hosted zone.

image

  • Execute the following commands:

    terraform init
    

    Screenshot 2024-10-02 at 1 05 40 PM

    terraform plan
    

    Screenshot 2024-10-02 at 1 06 11 PM

    terraform apply --auto-approve
    

Screenshot 2024-10-02 at 1 07 23 PM

Step 7: Issue Let’s Encrypt Certificates using Cert-Manager to securely expose our apps to the internet as websites with SSL encryption.

  • Enter the cert-issuer/ directory
  • Edit the pipeline-issuer.yml file with the custom url for your jenkins application to be accessed over the internet, email, private secret key name (this will be autogenerated), and registered hosted zone ID for your AWS registered domain name. This will ensure your custom Jenkins website is SSL encrypted.

image

  • Execute the following commands:

    Kubectl apply -f pipeline-issuer.yml
    

Screenshot 2024-10-02 at 1 11 57 PM

Step 8: Deploy the Application LoadBalancer Helm Chart to handle the traffic in and out to applications running within the DB Cluster:

  • Enter the alb/ directory
  • Edit the alb-values.yml file with the arn for the IAM Service Account you created to be able to launch an AWS ALB Loadbalancer.

image

  • Execute the following commands:

    terraform init
    

    Screenshot 2024-10-02 at 1 00 35 PM

    terraform plan
    

Screenshot 2024-10-02 at 1 01 33 PM

    terraform apply --auto-approve

Screenshot 2024-10-02 at 1 03 18 PM

Step 9: Deploy the Nginx-Ingress Helm Chart to expose your jenkins application to the internet at your custom website url:

  • Enter the nginx-ingress/ directory
  • Edit the pipeline-ingress.tf file with the custom url you entered in step 7.

image

  • Execute the following commands:

    terraform init
    terraform validate
    terraform plan
    

    Screenshot 2024-10-02 at 1 16 40 PM

    terraform apply --auto-approve
    

Screenshot 2024-10-02 at 1 18 52 PM

Step 10: Deploy the Jenkins Helm Chart to launch the CI/CD automation application:

  • Enter the pipeline/ directory
  • If you change the name for the secret that holds you Jenkins authentication info, you must also edit the admin section of the jenkins-values.yml file.

image

  • Execute the following commands:

    terraform init
    

    Screenshot 2024-10-02 at 1 23 23 PM

    terraform plan
    

    Screenshot 2024-10-02 at 1 24 21 PM

    terraform apply --auto-approve
    

Screenshot 2024-10-02 at 2 19 56 PM

Configure Jenkins

Step 1: Login to Jenkins

Screenshot 2024-06-24 at 11 34 42 AM

Screenshot 2024-06-24 at 11 35 03 AM

Step 2: Go to “Manage Jenkins” and select “Plugins”, Update existing plugins, and install necessary plugins such as SSH server, SSH Build Agents, Publish Over SSH, Prometheus, AWS credentials, Maven, SonarQube Scanner, etc…

Screenshot 2024-06-24 at 11 35 23 AM

Screenshot 2024-10-02 at 6 07 00 PM

Screenshot 2024-10-02 at 6 07 12 PM

Screenshot 2024-10-02 at 6 07 40 PM

Screenshot 2024-10-02 at 6 07 57 PM

Screenshot 2024-10-02 at 6 08 14 PM

Screenshot 2024-06-24 at 11 45 23 AM

Screenshot 2024-06-24 at 11 45 55 AM

Step 3: Go to “Manage Jenkins”, select “System”, Edit the Jenkins URL, and adjust the Prometheus settings as needed.

Screenshot 2024-06-24 at 11 46 35 AM

Screenshot 2024-06-24 at 11 46 52 AM

Step 4: Go to “Manage Jenkins”, Select “Tools”, and Install Git, SonarQube, and Maven

Screenshot 2024-06-24 at 11 47 19 AM

Screenshot 2024-06-24 at 11 47 19 AM

Screenshot 2024-06-24 at 11 47 51 AM

Step 4: Go to “Manage Jenkins”, Select “Add Credentials”, and setup the SSH login details for your Host server to be set up as a Worker Node, Docker server, DockerHub, and GitHub.

Screenshot 2024-06-24 at 11 53 18 AM

Screenshot 2024-06-24 at 11 53 24 AM

Screenshot 2024-10-02 at 7 38 21 PM

image

Screenshot 2024-06-24 at 12 07 33 PM

Screenshot 2024-06-24 at 12 09 30 PM

Screenshot 2024-06-24 at 12 12 45 PM

Step 5: Go to “Manage Jenkins”, Select “Nodes”, and connect your Jenkins controller to your host server.

Screenshot 2024-06-25 at 3 59 07 PM

Screenshot 2024-06-24 at 1 48 55 PM

Screenshot 2024-06-24 at 1 49 51 PM

Screenshot 2024-06-24 at 1 49 59 PM

Screenshot 2024-06-24 at 1 50 26 PM

Screenshot 2024-06-24 at 6 03 09 PM

Screenshot 2024-06-24 at 6 04 15 PM

Screenshot 2024-06-24 at 1 51 50 PM

image

About

Setup an EKS Kubernetes Cluster named "DB" using Terraform and deploy Jenkins using Helm Charts. Once Jenkins is running, setup your host server as a worker node running Terraform.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published