Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
9250877
updated mongodb values file as of 03/29/24
Ohubabs Mar 29, 2024
13f9598
helm release for spring-mongo chart with secret keys
Ohubabs Mar 29, 2024
6a4adf3
terraform provider credentials
Ohubabs Mar 29, 2024
74ee911
Create spring-mongo.tf
Ohubabs Mar 29, 2024
3fff1f0
Values file for spring-mongo chart
Ohubabs Mar 29, 2024
257927f
Helm Release for spring-mongo chart of sample java spring app connect…
Ohubabs Mar 29, 2024
0bace86
Create Jenkinsfile
Ohubabs Apr 2, 2024
8cf1c25
Update Jenkinsfile
Ohubabs Apr 2, 2024
f8a909a
Added nodeselector label
Ohubabs Apr 2, 2024
5688541
Update Jenkinsfile
Ohubabs Apr 2, 2024
91176fb
Update github repo url in CI/CD pipeline
Ohubabs Apr 2, 2024
03e7358
Update Jenkinsfile
Ohubabs Apr 2, 2024
fc3c553
Create Jenkinsfile_destroy
Ohubabs Apr 2, 2024
0577210
Update mongodb.tf
Ohubabs Apr 2, 2024
c629ef6
Update spring-mongo.yml
Ohubabs Apr 4, 2024
9356fbb
Update spring-mongo.yml
Ohubabs Apr 4, 2024
6f91c03
Update and rename Jenkinsfile to Jenkinsfile_Konoha
Ohubabs Apr 25, 2024
3215894
Destroy konoha website
Ohubabs Apr 25, 2024
392cb90
Delete mongodb.tf
Ohubabs Apr 25, 2024
a132080
Delete mongo.yml
Ohubabs Apr 25, 2024
bdf637f
Update provider.tf
Ohubabs Apr 25, 2024
668f47e
Update Jenkinsfile_destroy
Ohubabs Apr 25, 2024
ddee9f8
Update spring-mongo.yml
Ohubabs Apr 26, 2024
6b7b1a6
Update spring-mongo.yml
Ohubabs Apr 26, 2024
057c733
Update spring-mongo.yml
Ohubabs Apr 26, 2024
58af585
Update spring-mongo.yml
Ohubabs Apr 26, 2024
49131bf
changed image name after test. Due for CI/CD test
Ohubabs Apr 26, 2024
80cca83
Update spring-mongo.yml
Ohubabs Apr 30, 2024
a6f2af8
Update spring-mongo.yml
Ohubabs Apr 30, 2024
75b97ad
Update spring-mongo.yml
Ohubabs Apr 30, 2024
4983884
Update spring-mongo.yml
Ohubabs Apr 30, 2024
8c5b4c7
Create Jenkinsfile_Status
Ohubabs May 2, 2024
6c6e4b2
Update spring-mongo.yml
Ohubabs May 2, 2024
af2c2d1
Create tien.tf
Ohubabs Jun 24, 2024
87547a2
Create var.tf
Ohubabs Jun 24, 2024
5927a46
changed secret name
Ohubabs Jun 24, 2024
510667f
Update and rename tien.tf to krillin.tf
Ohubabs Jun 24, 2024
e8732e2
Update spring-mongo.yml
Ohubabs Jun 24, 2024
d5e4566
Update and rename krillin.tf to krillin-1.tf
Ohubabs Jun 24, 2024
69b2f3e
Cluster issuer to secure springapp-ingress
Ohubabs Jun 24, 2024
927efaa
Create springapp-ingress.tf
Ohubabs Jun 24, 2024
6f1b0ec
Update springapp-issuer.yml
Ohubabs Jun 24, 2024
6e19552
Rename Jenkinsfile_Konoha to Jenkinsfile_Springapp
Ohubabs Jun 24, 2024
da17eb3
removed password
Ohubabs Jun 24, 2024
b2cdd50
removed username
Ohubabs Jun 24, 2024
e92ceb7
Update var.tf
Ohubabs Jun 25, 2024
8769c87
Update krillin-1.tf
Ohubabs Jun 25, 2024
f828edc
Update krillin-1.tf
Ohubabs Jun 25, 2024
4b5fdf2
Update krillin-1.tf
Ohubabs Jun 25, 2024
dd1573c
Update provider.tf
Ohubabs Jun 25, 2024
ca56fb0
Update spring-mongo.tf
Ohubabs Jun 25, 2024
5313e7b
Update Jenkinsfile_Springapp
Ohubabs Jun 25, 2024
6dee493
Rename Jenkinsfile_destroy to Jenkinsfile_Destroy
Ohubabs Jun 25, 2024
9804eac
Update Jenkinsfile_Destroy
Ohubabs Jun 25, 2024
744acdf
Update var.tf
Ohubabs Jun 25, 2024
e6082b9
Update springapp-issuer.yml
Ohubabs Jun 25, 2024
f7a3d0b
Update krillin-1.tf
Ohubabs Jun 25, 2024
d04e009
temporarily added password
Ohubabs Jun 25, 2024
71ae3a8
Changed mongodb secret name
Ohubabs Jun 25, 2024
85c2a63
Update spring-mongo.yml
Ohubabs Jun 25, 2024
ad1ed82
Update springapp-issuer.yml
Ohubabs Jun 25, 2024
65a1979
Update springapp-ingress.tf
Ohubabs Jun 25, 2024
332ad42
Update spring-mongo.yml
Ohubabs Jun 25, 2024
c7dd598
Update spring-mongo.yml
Ohubabs Jun 25, 2024
1fb96ee
Update springapp-ingress.tf
Ohubabs Jun 25, 2024
6d92035
Update Jenkinsfile_Springapp
Ohubabs Jun 25, 2024
e991ffc
Update var.tf
Ohubabs Jun 26, 2024
367fda7
Update springapp-ingress.tf
Ohubabs Jun 26, 2024
ba8f443
Update Jenkinsfile_Destroy
Ohubabs Jun 26, 2024
55859fc
Update Jenkinsfile_Destroy
Ohubabs Jun 26, 2024
1bc2c60
Update Jenkinsfile_Springapp
Ohubabs Jun 26, 2024
f191286
Update Jenkinsfile_Springapp
Ohubabs Jun 26, 2024
a15a293
Update Jenkinsfile_Springapp
Ohubabs Jun 26, 2024
173e89c
Update var.tf
Ohubabs Jun 26, 2024
6b6b024
Update var.tf
Ohubabs Jun 26, 2024
e99f152
Update springapp-issuer.yml
Ohubabs Jun 26, 2024
eae553d
Set create namespace to true
Ohubabs Jun 27, 2024
58207bd
Update README.md
Ohubabs Oct 3, 2024
efc4cbf
Update README.md
Ohubabs Oct 3, 2024
c4a5ae0
Update README.md
Ohubabs Oct 3, 2024
7522308
Update README.md
Ohubabs Oct 3, 2024
8f8c41d
Update README.md
Ohubabs Oct 7, 2024
33ae729
Update README.md
Ohubabs Oct 7, 2024
098149b
Update README.md
Ohubabs Oct 7, 2024
2ea9475
Update README.md
Ohubabs Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Jenkinsfile_Destroy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pipeline{
agent {
label 'kubernetes'
}
stages{
stage('Destroy arsenalspring.devopsnetwork.net Website'){
steps{
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'aws_cred', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh "echo 'Destroy arsenalspring.devopsnetwork.net Website'"
sh "terraform init"
sh "terraform validate"
sh "terraform plan"
sh "terraform destroy --auto-approve"
}
}
}
}
}
32 changes: 32 additions & 0 deletions Jenkinsfile_Springapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pipeline{
agent {
label 'kubernetes'
}
stages{
stage('Provision springapp-issuer to acquire a certificate to secure the arsenalspring.devopsnetwork.net'){
steps{
sh "echo cloning code"
sh "kubectl apply -f springapp-issuer.yml"
}
}
stage('Deploy arsenalspring.devopsnetwork.net'){
steps{
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'aws_cred', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh "echo 'Create arsenalspring.devopsnetwork.net'"
sh "terraform init"
sh "terraform validate"
sh "terraform plan"
sh "terraform apply --auto-approve"
}
}
}
stage('Show Arsenal Java Springapp Running on Fargate Node'){
steps{
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'aws_cred', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh "echo 'Show arsenal java springapp container running on fargate nodes'"
sh "kubectl get po -o wide -n springapp"
}
}
}
}
}
38 changes: 38 additions & 0 deletions Jenkinsfile_Status
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
pipeline{
agent {
label 'kubernetes'
}
stages{
//stage('Clone Code'){
//steps{
//sh "echo cloning code"
//sh "echo clone code complete"
//git 'https://github.com/Konoha-23/Konoha_WP.git'
//}
//}
stage('Get Pods in Konoha Namespace'){
steps{
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'aws_cred', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh "echo 'Get Pods in Konoha namespace'"
sh "kubectl get po -o wide -n konoha"
}
}
}
stage('Describe Pods in Konoha Namespace'){
steps{
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'aws_cred', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh "echo 'Describe Pods in Konoha Namespace'"
sh "kubectl describe po -n konoha"
}
}
}
//stage('Check Logs'){
// steps{
// withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'aws_cred', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
// sh "echo 'Check Logs'"
// sh "kubectl logs wordpress-849fc57f7f-xnf9q -n robot-shop"
// }
// }
//}
}
}
55 changes: 53 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
# DB-Springapp
Deploy Java Springapp connected to mongodb nosql database into the DB cluster running on a Fargate node, using Jenkins
# DB-CD

# DragonBall Project Part 6

## Project Objective

For this project, set up a pipeline to deploy a stateless Java Springboot app connected to MongoDB NoSQL database into the DB cluster running on a Fargate node using Terraform with the Kubernetes and Helm Providers.

## Prerequisites

- MongoDB deployed in DB Cluster (To set MongoDB in the DB cluster, check Project part 5: https://github.com/Ohubabs/DB-Mongo.git).
- Prior knowledge of Terraform, Kubernetes, and Helm, application deployment, charts.

### Step 1: Go to New Item” from the Dashboard, select “Pipeline”, and name it “Springapp”.

![Screenshot 2024-06-24 at 3 04 32 PM](https://github.com/user-attachments/assets/718a3ff0-fa52-4eab-a937-3c7dc8997c6c)

### Step 2: Go to “Configuration”, Select “Poll SCM” and Enter the details for your GitHub repo & Jenkinsfile or copy and paste the Jenkinsfile in this repo.

![image](https://github.com/user-attachments/assets/e74fe561-2e4b-42b3-8843-e2d8446692a0)

#### Notes: -

- To enter details for your MongoDB database, edit the var.tf file to fill in the secret in the krillin.tf file.
- If you change the name for the secret with your MongoDB credentials, you must also change it in the values file for the customized helm chart via the spring-mongo.yml file.
- To expose your application with SSL encryption to the internet, you must edit the spring-issuer.yml file with your email, custom URLs for your site with your AWS registered domain name, and your AWS hosted zone ID. In addition, you will need your AWS credentials, which were saved in a secret made during Project Part 1 (ref: https://github.com/Ohubabs/DB-Pipeline.git)

### Step 3: Click “Build now” to run your pipeline with Maven, SonarQube, and Docker to Build, Test, Containerize, and Push your Java Springboot Web app to DockerHub.

![Screenshot 2024-06-24 at 6 27 18 PM](https://github.com/user-attachments/assets/24e6bbd6-5375-479a-8718-76b1d41e081e)

![Screenshot 2024-06-24 at 6 27 26 PM](https://github.com/user-attachments/assets/6de298f5-c8c2-4c76-9206-f1b38f2e7d2f)

![Screenshot 2024-06-24 at 6 27 32 PM](https://github.com/user-attachments/assets/45269973-6fa4-44de-839f-5928f30b1421)

![Screenshot 2024-06-24 at 6 28 58 PM](https://github.com/user-attachments/assets/564b287b-514d-436a-bbea-1a9a960c5eec)

![Screenshot 2024-06-24 at 6 38 11 PM](https://github.com/user-attachments/assets/8d5c4460-7d03-4784-9c3e-70593cca0580)

![Screenshot 2024-06-24 at 6 38 28 PM](https://github.com/user-attachments/assets/28ab1f83-1e4f-419a-9ad7-63fbd6b59bf9)

![Screenshot 2024-06-24 at 6 39 00 PM](https://github.com/user-attachments/assets/b1774b9b-b3ba-4040-aa4d-dd33111d73b0)

![Screenshot 2024-06-25 at 7 10 13 PM](https://github.com/user-attachments/assets/4f8aa4f2-5344-4936-8996-3b231837189d)

![Screenshot 2024-06-25 at 7 24 43 PM](https://github.com/user-attachments/assets/abba8171-359e-4c1a-ae42-5af367d27c72)


![Screenshot 2024-06-25 at 6 42 42 PM](https://github.com/user-attachments/assets/b37090d8-78f5-4ce0-a12b-bfe7127e1006)




12 changes: 12 additions & 0 deletions krillin-1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "kubernetes_secret_v1" "springapp-mongodb-auth" { #do not name krillin so it won't crash with the secret for mongodb
metadata {
name = "springapp-mongodb-auth"
namespace = "springapp"
}

data = {
MONGO_DB_USERNAME = var.krillin
MONGO_DB_PASSWORD = var.destructodisk
}
}

32 changes: 32 additions & 0 deletions provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
terraform {
required_version = "~> 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}

kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.10"
}
helm = {
source = "hashicorp/helm"
version = ">= 2.4.1"
}
}
}

provider "aws" {
region = "us-west-2"
}

provider "helm" {
kubernetes {
config_path = "/home/terra/.kube/config" #changed user needed to correspond with production cluster deploying applications.
}
}

provider "kubernetes" {
config_path = "/home/terra/.kube/config"
}
19 changes: 19 additions & 0 deletions spring-mongo.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "helm_release" "spring-mongo" {
name = "springapp"
create_namespace = true
namespace = "springapp"
repository = "https://konoha-23.github.io/springapp-mongo/"
chart = "spring-mongo"
values = [
"${file("spring-mongo.yml")}"
]
}

#


/*1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=spring-mongo,app.kubernetes.io/instance=spring-mongo" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT*/
147 changes: 147 additions & 0 deletions spring-mongo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Default values for spring-mongo.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
metadata:
labels:
app: springapp

replicaCount: 1

selector:
matchLabels:
app: "springapp"

strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1

image:
repository: princebabs/arsenalspringapp #princebabs/springapp
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v1" #v2
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}
podLabels:
app: springapp

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 8080
targetPort: 8080

serviceSelector:
app: springapp

ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
ingress:
ClassName: nginx-example
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

#livenessProbe:
# httpGet:
# path: /
# port: 8080
#readinessProbe:
# httpGet:
# path: /
# port: 8080

#1. Get the application URL by running these commands:
# export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=spring-mongo,app.kubernetes.io/instance=spring-mongo" -o jsonpath="{.items[0].metadata.name}")
# export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
# echo "Visit http://127.0.0.1:8080 to use your application"
# kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
#mongodb-0.mongodb-headless.konoha.svc.cluster.local:27017

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false

# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true

nodeSelector: {}

tolerations: []

affinity: {}

#Mongo DB credentials

#Enter the name for an existing mongo secret
mongodbsecretName: springapp-mongodb-auth

#Enter the name for an existing secret key for mongo root user
mongodbrootuserkey: MONGO_DB_USERNAME


#Enter the name for an existing secret key for mongo root password
mongodbrootpasswordkey: MONGO_DB_PASSWORD

#Enter the name for mongo db hostname
mongodbhostname: mongodb
Loading