Phase 2
Phase 2
Group Members:
• Name: AAA
CAN ID Number: BBB
• Name: XXX
CAN ID Number: YYY
SOLUTION ARCHITECTURE
To streamline the deployment process for the Dockerized e-commerce application, we will set up
version control, automate code commits, and establish a CI/CD pipeline. The solution architecture
will leverage a well-defined directory structure, and tools like Jenkins, GitHub Actions, and IBM
Cloud Kubernetes Service.
In Windows Command Prompt, we can use the mkdir command to create directories for the
application. Here’s how you can set up the project structure for the ecommerce-app:
mkdir ecommerce-app
cd ecommerce-app
mkdir public
mkdir public\css
mkdir public\js
DEVOPS ENGINEER
PHASE 2
mkdir server
mkdir server\controllers
mkdir server\models
mkdir server\routes
After executing the above commands, your directory structure should look as follows:
ecommerce-app/
├── public/
│ ├── css/
│ │ └── style.css
│ ├── js/
│ │ └── app.js
│ └── index.html
├── server/
│ ├── controllers/
│ │ └── productController.js
DEVOPS ENGINEER
PHASE 2
│ ├── models/
│ │ └── productModel.js
│ ├── routes/
│ │ └── productRoutes.js
│ └── server.js
├── package.json
└── README.md
To ensure that the development team is working collaboratively and tracking changes efficiently, we
will set up a GitHub repository for version control.
git init
git add .
DEVOPS ENGINEER
PHASE 2
To automate the build, test, and deployment processes, we will design a CI/CD pipeline using
Jenkins.
1. Jenkins Setup
o Set up a Jenkins job that triggers on code changes pushed to the GitHub repository.
o Create a Jenkinsfile in the root of the project, which will define the steps to build,
test, and deploy the application.
▪ Build: Build the Docker image for both frontend and backend services.
▪ Test: Run unit and integration tests to ensure the code is stable.
▪ Push to IBM Cloud Container Registry: Push the built Docker image to
IBM Cloud Container Registry for centralized storage and management.
▪ Deploy: Deploy the updated Docker image to the Kubernetes cluster on IBM
Cloud Kubernetes Service using kubectl commands.
3. Jenkinsfile Example:
pipeline {
agent any
environment {
DOCKER_IMAGE = 'my-app'
REGISTRY_URL = '<IBM_Container_Registry_URL>'
CLUSTER_NAME = '<CLUSTER_NAME>'
}
stages {
stage('Checkout') {
DEVOPS ENGINEER
PHASE 2
steps {
git 'https://github.com/<username>/ecommerce-app.git'
}
}
stage('Build Docker Image') {
steps {
script {
sh 'docker build -t $REGISTRY_URL/$DOCKER_IMAGE .'
}
}
}
stage('Push Docker Image to IBM Cloud Container Registry') {
steps {
script {
sh 'docker push $REGISTRY_URL/$DOCKER_IMAGE'
}
}
}
stage('Deploy to Kubernetes') {
steps {
script {
sh '''
ibmcloud login --apikey <API_KEY> -r <REGION> -g <RESOURCE_GROUP>
ibmcloud ks cluster config --cluster $CLUSTER_NAME
kubectl apply -f k8s/deployment.yaml
'''
}
}
}
}
post {
success {
echo 'Pipeline executed successfully.'
}
DEVOPS ENGINEER
PHASE 2
failure {
echo 'Pipeline failed. Please check the logs.'
}
}
}
FUTURE PLAN:
o Utilize IBM Cloud Container Registry for storing and managing Docker images.
This will provide a secure and centralized storage for the container images, enabling
streamlined deployments.
o Build the Docker image for the frontend and backend services and push them to IBM
Cloud Container Registry for storage and future deployments.
o Implement OpenSSL for secure image management and encryption. This will include
vulnerability scanning and signing the Docker images to ensure that only trusted
versions are deployed, improving the security of the deployment pipeline.
o Automate the build, test, and deployment process by integrating IBM Cloud
Continuous Delivery, Jenkins, or GitHub Actions with the Kubernetes deployment
pipeline, ensuring rapid and consistent updates.
DEVOPS ENGINEER