Phase 3
Phase 3
Members:
• Name: Kishor N
CAN ID Number: CAN_33717615
• Name: Henjesh K O
CAN ID Number: CAN_33716460
SOLUTION DEVELOPMENT:
Full Name: Bimmi Kumari
Email: [email protected]
Username: Bimmi Kumari
Account Type: Personal
DEVOPS ENGINEER
Phase 3
Billing Account: using feature-code
IBM Cloud Account ID: 8a4e35c671064604a56ac66de17fb9a1
1. Install Minikube
Installation Command:
https://storage.googleapis.com/minikube/releases/latest/minikube-installer.exe
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Kubernetes
Verify Installation:
minikube version
Expected Output:
minikube version:
v1.30.1 2.
Installation Command:
Dummy Installation Path:
C:\Users\ProgramData\kubectl\kubectl.exe
Verify Installation:
Output:
3. Install Docker
DEVOPS ENGINEER
Phase 3
Download URL:
Docker Desktop for Windows
Dummy Installation Path:
C:\Program Files\Docker\Docker.exe
Verify Installation:
docker --version
Output:
Command to Create Namespace :
Output:
OK
Command to Enable Image Vulnerability Scanning:
Output:
DEVOPS ENGINEER
Phase 3
1. Create Dockerfiles
FROM node:16-alpine
WORKDIR /app
COPY . .
EXPOSE 3000
FROM node:16-alpine
WORKDIR /app
COPY . .
EXPOSE 5000
DEVOPS ENGINEER
Phase 3
ibmcloud cr login
1. Start Minikube
minikube start
deployment.yaml):
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-deployment
spec:
replicas: 3 selector:
matchLabels:
DEVOPS ENGINEER
Phase 3
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: frontend
image: <region>.icr.io/<namespace>/frontend-app:1.0
ports:
- containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: frontend-service
spec:
type: NodePort
selector:
app: frontend
ports:
- port: 3000
targetPort: 3000
DEVOPS ENGINEER
Phase 3
apiVersion:
apps/v1 kind:
Deployment
metadata:
name: backend-deployment
spec:
replicas: 2
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: <region>.icr.io/<namespace>/backend-app:1.0
ports:
- containerPort: 5000
---
apiVersion: v1
kind: Service
DEVOPS ENGINEER
Phase 3
metadata:
name: backend-service
spec:
type: NodePort
selector:
app: backend
ports:
- port: 5000
targetPort: 5000
2. Check Services
3. Access Applications
Use Minikube service IP or tunnel to expose services:
o
To access the frontend
--url
o
To access the backend service:
DEVOPS ENGINEER
Phase 3
Example GitHub Actions YAML:
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
uses:
actions/checkout@v2
uses: docker/setup-buildx-action@v1
DEVOPS ENGINEER
Phase 3
Cloud run: |
images run: |
- name: Deploy to
Kubernetes run: |
backend-deployment.yaml
2. Automate Build, Test, and Deployment Stages Using Minikube and IBM Cloud CLI
Set up continuous build and deploy steps to trigger automatically when pushing changes
to GitHub.
For JMeter:
o
Create a test plan with multiple threads (users).
DEVOPS ENGINEER
Phase 3
o
Configure the HTTP requests to test your API endpoints.
o
Run the test and observe results like response times and throughput.
For Postman:
o
Create a collection for testing your APIs.
o
Use the built-in "Runner" feature to run the collection with multiple iterations.
o
Export the test results for analysis.
For Minikube Dashboard:
minikube dashboard
SECTION 3:
Autoscaler) Steps:
1. Ensure Minikube Cluster is Running: Ensure you have a Minikube cluster running and
that your deployments are configured properly.
sh CopyEdit
minikube start
2. Enable Metrics Server: To enable autoscaling, you'll need the Metrics Server, which
provides resource usage data (CPU and memory) for autoscaling.
o
Install Metrics Server:
sh CopyEdit
DEVOPS ENGINEER
Phase 3
3. Create a Horizontal Pod Autoscaler (HPA): Set up an HPA for your applications
(e.g., frontend or backend) to automatically scale the number of pods based on CPU
usage.
o
Example HPA for frontend deployment (frontend-hpa.yaml):
yaml
CopyEdit
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: frontend-hpa
spec:
scaleTargetRef:
apiVersion:
apps/v1 kind:
Deployment
name: frontend-deployment
minReplicas: 2
maxReplicas: 10
metrics:
- type:
Resource
resource:
name: cpu
target:
type: Utilization
DEVOPS ENGINEER
Phase 3
averageUtilization: 50
sh
CopyEdit
hpa.yaml
5. Monitor Autoscaling: You can monitor the scaling behavior by checking the HPA status:
sh
CopyEdit
o
Start a Jenkins instance within Minikube using the Kubernetes plugin or deploy it
with Helm:
sh
CopyEdit
o
In Jenkins, set up a pipeline to automate the build, test, and deployment process.
o
Example Jenkinsfile:
groovy
DEVOPS ENGINEER
Phase 3
CopyEdit
pipeline
agent any
stages {
{ steps
{ scrip
t{
app:1.0 ./backend'
{ steps
{ scrip
t{
stage('Deploy to Kubernetes')
DEVOPS ENGINEER
Phase 3
{ steps {
DEVOPS ENGINEER
Phase 3
script {
o
Trigger Jenkins builds on commits or pull requests.
o
Integrate automated tests to ensure quality and reliability before deployment.
o
Install Tekton on your Kubernetes cluster:
sh
CopyEdit
o
Define the pipeline resources (such as Docker images and Git repositories) and
steps (build, push, deploy).
o
Example Tekton pipeline:
yaml
CopyEdit
DEVOPS ENGINEER
Phase 3
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: ci-pipeline
spec:
resources:
- name: git-repo
type: git
tasks:
- name: build-and-push
taskRef:
name: build-and-push-task
resources:
inputs:
- name: git-repo
resource: git-repo
3. Automate Deployment:
o
Trigger Tekton pipelines based on GitHub commits or other Git events.
DEVOPS ENGINEER
Phase 3
o
IBM Cloud offers a Vulnerability Advisor to automatically scan Docker images
for vulnerabilities.
o
Configure your pipeline to trigger image scans using the IBM Cloud
Vulnerability Advisor during the build or push process.
o
Example of adding IBM Cloud vulnerability scanning within a Jenkins pipeline:
pipeline {
agent
any
stage
s
{
{ steps
{ scrip
t{
{ steps
{ scrip
t{
DEVOPS ENGINEER
Phase 3
{ steps
{ scrip
t{
stage('Deploy to Kubernetes')
{ steps
{ scrip
t{
o
Use Clair, Anchore, or Trivy for additional vulnerability scanning. Configure your
CI/CD pipeline to use these tools by scanning Docker images before they are
pushed to the registry.
DEVOPS ENGINEER
Phase 3
o
Example with Trivy:
image <region>.icr.io/<namespace>/backend-app:1.0
DEVOPS ENGINEER