0% found this document useful (0 votes)
7 views33 pages

Devops File

The document outlines the fundamentals of DevOps, emphasizing its role in improving collaboration between development and operations teams to enhance software delivery speed and quality. It details the DevOps lifecycle, which includes phases such as planning, coding, building, testing, releasing, deploying, operating, and monitoring, alongside principles like automation and continuous feedback. Additionally, it introduces tools and practices for version control, CI/CD pipelines, and highlights the benefits of adopting a DevOps culture.

Uploaded by

akkhera37
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views33 pages

Devops File

The document outlines the fundamentals of DevOps, emphasizing its role in improving collaboration between development and operations teams to enhance software delivery speed and quality. It details the DevOps lifecycle, which includes phases such as planning, coding, building, testing, releasing, deploying, operating, and monitoring, alongside principles like automation and continuous feedback. Additionally, it introduces tools and practices for version control, CI/CD pipelines, and highlights the benefits of adopting a DevOps culture.

Uploaded by

akkhera37
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DEVOPS ON CLOUD LABORATORY GU-2023-3513

PRACTICAL-1
➢ DevOps Fundamentals and Lifecycle Exploration.
❖ What is DevOps?

DevOps is a combination of Development (Dev) and Operations (Ops).


It is a set of practices, culture, and tools that aims to shorten the software development
lifecycle while delivering high-quality software continuously.

In simple words:
DevOps helps developers and operations teams work together, instead of working in
isolation.

❖ Why DevOps is Needed?


Traditional software development had problems like:

• Slow software releases

• Poor communication between teams


• Late bug detection

• Difficult deployments

DevOps solves these by:

• Automating processes

• Enabling continuous integration & delivery

• Improving collaboration
• Making systems more reliable and scalable

❖ Core Principles of DevOps

DevOps is often explained using CALMS:

• C – Culture: Collaboration and shared responsibility

• A – Automation: Automating builds, tests, deployments

• L – Lean: Reducing waste, faster feedback

• M – Measurement: Monitoring performance and failures


• S – Sharing: Sharing knowledge and responsibility
1
DEVOPS ON CLOUD LABORATORY GU-2023-3513

❖ DevOps Lifecycle

The DevOps lifecycle is a structured approach that integrates development (Dev) and operations
(Ops) teams to streamline software delivery. It focuses on collaboration, automation, and
continuous feedback across key phases planning, coding, building, testing, releasing, deploying,
operating, and monitoring executed in a continuous loop.

Phases of DevOps Lifecycle


1. Plan: This phase focuses on understanding the business needs and gathering feedback
from end-users. Teams create a plan that aligns the project with business goals and
ensures the right results are delivered.

2. Code: In this phase, developers write the actual code for the software. Tools like Git help
manage the code, making sure that the code is well-organized and free from security
issues or bad coding practices.

3. Build: Once the code is written, it is submitted to a central system using tools like
Jenkins. This step ensures the code is compiled, and all components are integrated
together smoothly.

4. Test: The software is then tested to ensure it works properly. This includes different types
of tests like security, performance, and user acceptance. Tools like JUnit and Selenium
are used to automate these tests and verify the software’s integrity.
5. Release: After testing, the software is ready to be released to production. The DevOps
team ensures that all checks are passed and then sends the latest version to the production
environment.

6. Deploy: Using Infrastructure-as-Code (IaC) tools like Terraform, the necessary


infrastructure (servers, networks, etc.) is automatically created. Once the infrastructure is
set up, the code is deployed to various environments in an automated and repeatable way.

7. Operate: Once deployed, the software is available for users. Tools like Chef help manage
the configuration and ongoing deployment of the system to ensure it operates smoothly.

8. Monitor: This phase involves observing how the software is performing in the real
world. Data about user behaviour and application performance is collected to identify any
issues or bottlenecks. By monitoring the system, the team can quickly spot and fix
problems that may affect performance.
o 7 Cs of DevOps

The 7 Cs of DevOps are core principles that help make DevOps successful. They guide how
teams work together, build, test, and deliver software faster and more reliably. Each of these

2
DEVOPS ON CLOUD LABORATORY GU-2023-3513

Cs contributes to a workflow that enhances the quality, speed, and reliability of delivering
software products:

1. Continuous Development

2. Continuous Integration

3. Continuous Testing

4. Continuous Deployment/Continuous Delivery

5. Continuous Monitoring
6. Continuous Feedback

7. Continuous Operations

3
DEVOPS ON CLOUD LABORATORY GU-2023-3513

1. Continuous Development
Continuous Development involves the iterative and incremental approach to software creation,
where development teams plan, code, and prepare software features in small, manageable units.
This methodology enables rapid feedback, early detection of issues, and swift delivery of value
to end-users. It integrates closely with version control systems and automation tools to streamline
the development process.

Example:

Imagine a team building a food delivery app. Instead of waiting to finish the whole app and
testing it later, the team adds features one by one:

• On Monday, they add a "Login" feature and test it immediately.

• On Tuesday, they add the "Search for restaurants" feature and test that too.
Each feature is checked and added to the live app as soon as it's ready. This way, if there's a
problem in the "Login" part, they can fix it right away without affecting other parts.

(Continuous Development)

2. Continuous Integration

Continuous Integration (CI) in DevOps ensures that code changes made by developers are
automatically built, tested, and integrated into the main codebase. This process typically involves
four key stages:

4
DEVOPS ON CLOUD LABORATORY GU-2023-3513

1. Source Code Management (SCM): Developers push their code from local machines to a
remote repository such as GitHub. This allows teams to collaborate, review, and manage code
versions easily.

2. Build Process: The source code is then compiled using tools like Maven, which packages the
application into artifacts such as .jar, .war, or .ear files.

3. Code Quality Check: Tools like SonarQube analyze the code for bugs, code smells, and
security issues. It generates detailed reports (HTML or PDF) to maintain code quality standards.
4. Artifact Repository: The generated build artifacts are stored in a repository manager like
Nexus, which serves as a central storage for future deployment.
All these steps are automated using Jenkins, a popular CI tool that orchestrates the complete
flow, from fetching code to storing the final build artifact.

Example:
Let's say your team adds a new feature: "Track Delivery Person on Map."

• Developer Meena writes code for the tracking feature and pushes it to GitHub.

• As soon as the code is pushed, Jenkins picks it up and uses Maven to build the app and
test it using JUnit.

• The code goes through SonarQube, which finds a few duplicate lines and suggests better
practices.

• Once everything is okay, the final app version (with the new feature) is saved in Nexus as
a .jar file.

This way, every small change is tested, verified, and saved automatically without manual
effort.

5
DEVOPS ON CLOUD LABORATORY GU-2023-3513

3. Continuous Testing
Continuous Testing means testing the code automatically every time there is a change. This
helps catch bugs early before the app goes live. With DevOps and Agile methods, companies can
use tools like Selenium, Testsigma, or LambdaTest to test their applications automatically.
These tools run tests faster and smarter than manual testing.

Using a tool like Jenkins, we can set up the entire testing process to run automatically after
every code change. This saves time and reduces human errors.

Example:
Let’s say your team adds a new feature: "Apply Coupon at Checkout."

After the developer pushes this new feature to GitHub, Jenkins automatically starts the testing
process. Tools like Selenium or Testsigma test:
• Does the coupon code apply correctly?

• Does the final price update as expected?

• Does the checkout process still work?

If a problem is found, for example, the app crashes when a wrong coupon is entered the test
will fail, and the developer will be notified immediately to fix it. This way, the team avoids
pushing broken features to production and ensures the app remains reliable.

4. Continuous Deployment/ Continuous Delivery


Continuous Deployment: Continuous Deployment is the process of automatically deploying an
application into the production environment when it has completed testing and the build stages.
Here, we'll automate everything from obtaining the application's source code to deploying it.

6
DEVOPS ON CLOUD LABORATORY GU-2023-3513

Continuous Delivery: Continuous Delivery is the process of deploying an application into


production servers manually when it has completed testing and the build stages. Here, we will
automate the continuous integration processes, however, manual involvement is still required for
deploying it to the production environment.

Example:

Suppose the team adds a “Refer & Earn” feature.

• The code is developed, tested, and marked as ready to go live.

• However, the product team decides to launch it during a weekend campaign.


• Until then, the feature stays on standby in the staging area.

Once approved, the code is manually deployed to production using a single click.

So, Continuous Delivery ensures every update is deployable anytime, but the actual release
can be controlled.

5. Continuous Monitoring
DevOps lifecycle is incomplete if there was no Continuous Monitoring. Continuous Monitoring
can be achieved with the help of Prometheus and Grafana we can continuously monitor and can
get notified before anything goes wrong with the help of Prometheus we can gather many
performance measures, including CPU and memory utilization, network traffic, application
response times, error rates, and others. Grafana makes it possible to visually represent and keep
track of data from time series, such as CPU and memory utilization.
Example:

7
DEVOPS ON CLOUD LABORATORY GU-2023-3513

Let's say your app suddenly takes longer to load the “Order History” page.

• Prometheus tracks this slow response time and sends an alert to the team.

• Grafana shows a graph that spikes during dinner hours when traffic is high.

• The team uses this data to adjust the server settings or optimize the code.
This prevents crashes and keeps the app smooth for all users, especially during peak hours like
dinner time.

6. Continuous Feedback
Once the application is released into the market the end users will use the application and they
will give us feedback about the performance of the application and any glitches affecting the user
experience after getting multiple feedback from the end users' the DevOps team will analyze the
feedbacks given by end users and they will reach out to the developer team tries to rectify the
mistakes they are performed in that piece of code by this we can reduce the errors or bugs that
which we are currently developing and can produce much more effective results for the end users
also we reduce any unnecessary steps to deploy the application. Continuous Feedback can
increase the performance of the application and reduce bugs in the code making it smooth for
end users to use the application.

Example:

Suppose users complain that the live delivery tracking is not updating fast enough.

• The feedback is collected via app reviews, customer support, or feedback forms.
• The DevOps team analyzes the issue and works with developers to improve the tracking
speed.

• The next update includes a fix, and the user experience improves.
By responding to feedback, the app becomes more reliable and enjoyable to use.

7. Continuous Operations
We will sustain the higher application uptime by implementing continuous operation, which will
assist us to cut down on the maintenance downtime that will negatively impact end users'
experiences. More output, lower manufacturing costs, and better quality control are benefits of
continuous operations.

Example:
Let’s say you need to update the payment system.

8
DEVOPS ON CLOUD LABORATORY GU-2023-3513

• Instead of shutting the app down, Continuous Operations ensures the update happens in
the background.

• Users continue ordering food while the change is made without even noticing.

This keeps customers happy and business running 24/7, especially during peak times like lunch
and dinner.

❖ Popular DevOps Tools (Category-wise)


Category Tools

Version Control Git, GitHub, GitLab

CI/CD Jenkins, GitHub Actions

Configuration Management Ansible, Chef

Containers Docker

Orchestration Kubernetes

Monitoring Prometheus, Grafana

Cloud Platforms AWS, Azure

❖ Benefits of DevOps
✔ Faster delivery
✔ Improved software quality
✔ Better collaboration
✔ Reduced failures and downtime
✔ Continuous feedback and improvement

❖ Real-Life Example
Without DevOps:

New feature takes months to reach users.

With DevOps:

9
DEVOPS ON CLOUD LABORATORY GU-2023-3513

Feature is developed, tested, deployed, and monitored automatically within days or even
hours.

❖ Conclusion
DevOps is not just tools, but a mindset and culture that promotes automation, collaboration,
and continuous improvement.
The DevOps lifecycle ensures faster, reliable, and scalable software delivery.

10
DEVOPS ON CLOUD LABORATORY GU-2023-3513

PRACTICAL-2
➢ Mastering Git Versioning Control Essentials
Step 1: Check if Git is installed
1. Git -version

Step 2: Create a Local Repository


2. Mkdir git-lab

3. Cd git-lab
4. Git init

5. Git status

11
DEVOPS ON CLOUD LABORATORY GU-2023-3513

Step 3: Create & Commit Files


6. Echo “Hello Git” > [Link]
7. Git status

8. Git add [Link]

9. Git commit -m “Initial commit”

Step 4: Connect to Remote Repository (GitLab)


10. Create a GitLab account and an empty repository.

12
DEVOPS ON CLOUD LABORATORY GU-2023-3513

11. Check the repo and add the GitLab repo.

12. Verify using : git remote -v

Step 5: Push Code to Remote


13. First pull any changes : git pull gitlab main –allow-unrelated-histories

14. Git push -u gitlab main

15. Login page will appear for GitLab, Log-in to your GitLab account.

13
DEVOPS ON CLOUD LABORATORY GU-2023-3513

16. Git push -u gitlab main

Step 6: Create and work with Branches


17. git branch feature-branch (Create a new branch named "feature")
18. git checkout feature-branch (switch to a new branch named "feature”)

19. git branch (for verifying the branch)

Step 7: Make Changes in Feature Branch


20. echo “Feature work” >> [Link]

21. git status

14
DEVOPS ON CLOUD LABORATORY GU-2023-3513

22. git add .

23. git commit -m “Added feature changes”

24. git push gitlab feature-branch

Step 8: Create a Merge Conflict


25. git checkout main

26. echo “Main branch change” >> [Link]

27. git add .

28. git commit -m “Main Branch edit”

15
DEVOPS ON CLOUD LABORATORY GU-2023-3513

NOTE: The above commands are only for main branch

29. git checkout feature-branch

30. echo “Feature branch change” >> [Link]

31. git add .

32. git commit -m “Feature Branch edit”

NOTE: the above commands are only for feature branch

Step 9: Merge Conflict occurs


33. git checkout main

34. git merge feature-branch

16
DEVOPS ON CLOUD LABORATORY GU-2023-3513

Step 10: Resolve Merge Conflict


35. cat [Link] (Open the conflicted file to read)

36. Manually edit file (keep required changes) : notepad [Link]

37. git add [Link] (Mark conflict as resolved)


38. git commit -m "Conflict Resolved" (Complete merge)

Step 11: Delete Branch


39. git branch -d feature-branch (Delete local branch)

17
DEVOPS ON CLOUD LABORATORY GU-2023-3513

40. git push origin --delete feature-branch (Delete remote branch)

41. git log (to view history & Logs)

18
DEVOPS ON CLOUD LABORATORY GU-2023-3513

PRACTICAL-3
➢ Build CI-CD pipelines with git-hub actions
• Create an empty repository and clone it to your local device.

• Create any simple executable file.

• Create a “.yml” file in a separate path “.github/workflows/”.

19
DEVOPS ON CLOUD LABORATORY GU-2023-3513

• In the file write the following code.

20
DEVOPS ON CLOUD LABORATORY GU-2023-3513

• Using “Find .” command check whether the file is created or no.

21
DEVOPS ON CLOUD LABORATORY GU-2023-3513

• Use git status command to check how many untracked files are there.

• Push to origin then.

22
DEVOPS ON CLOUD LABORATORY GU-2023-3513

• After pushing to origin, open Git-hub and in your repo, go to Actions tab and click on
your action.
• After clicking click on “Run excutable” and your output would be there.

23
DEVOPS ON CLOUD LABORATORY GU-2023-3513

PRACTICAL-4
➢ DOCKER containerization Hands-on.
1. Check Docker
docker –version (Displays the installed Docker version to confirm Docker is available on
the system.)

2. Run Test Container


docker run hello-world (Downloads the hello-world image from Docker Hub, creates a
container, runs it, and prints a confirmation message to verify Docker is working.)

3. Pull Base Image


docker pull ubuntu (Downloads the official Ubuntu image from Docker Hub to the local
system for use in creating containers.)

24
DEVOPS ON CLOUD LABORATORY GU-2023-3513

4. List Images
Docker images (Displays all Docker images currently available on the local machine.)

5. Run Ubuntu Container


docker run -it ubuntu /bin/bash (Creates and runs a new Ubuntu container in interactive
mode and opens a Bash shell inside it.) (-i stands for interactive and -t stands for
terminal)
6. Exit
Exit (Exits from the running container and returns to the host terminal.)

7. Create Dockerfile
Write the following in a file named “Dockerfile”:
FROM ubuntu
RUN apt update
CMD ["echo","Hello"]

(Creates a file named Dockerfile which defines instructions to build a custom Docker image.

FROM ubuntu → base image


RUN apt update → runs command during build

CMD → default command when container runs)


8. Verify Dockerfile
cat Dockerfile (Displays the contents of the Dockerfile to verify it was created correctly.)

25
DEVOPS ON CLOUD LABORATORY GU-2023-3513

9. Build Docker Image


docker build -t pwdimage . (Builds a Docker image using the Dockerfile in the current
directory. -t pwdimage → assigns name to image and . → current directory as build
context)

10. Run Custom Image


docker run pwdimage (Creates and runs a container from the custom image and executes
the command defined in the Dockerfile.)

11. Login to Docker Hub


Winpty docker login (Authenticates the user with Docker Hub so that images can be
pushed to the online repository.)

26
DEVOPS ON CLOUD LABORATORY GU-2023-3513

12. Tag Image for Docker Hub


Before tagging and pushing the image make sure you have created a repository in docker
website.
docker tag pwdimage username/pwdimage (Creates a new name for the image in the
format required by Docker Hub.)

27
DEVOPS ON CLOUD LABORATORY GU-2023-3513

13. Push Image to Docker Hub


docker push username/pwdimage (Uploads the tagged image from local system to
Docker Hub repository.)

14. Pull Image from Docker Hub


docker pull username/pwdimage (Downloads the image from Docker Hub to verify it was
uploaded successfully.)

15. Run Pulled Image


docker run username/pwdimage (Runs a container from the image pulled from Docker
Hub.)

28
DEVOPS ON CLOUD LABORATORY GU-2023-3513

16. List Containers


docker ps (Shows all currently running containers.)
docker ps -a (Shows all containers including stopped ones.)

29
DEVOPS ON CLOUD LABORATORY GU-2023-3513

PRACTICAL-5
➢ Run a python image in DOCKER.
1. Pull Base Image
docker pull python:3.10 (Downloads the official python image from Docker Hub to the
local system for use in creating containers.)

2. Run Python Container


Winpty docker run -it python:3.10 python

3. Create a python program


print("Hello from Python Docker") , name the file : [Link]

30
DEVOPS ON CLOUD LABORATORY GU-2023-3513

4. Create a Dockerfile
FROM python:3.10
WORKDIR /app
COPY [Link] .
CMD ["python", "[Link]"]

5. Build Image
docker build -t pyimage .

6. Run Container
Winpty docker run -it python:3.10 python

31
DEVOPS ON CLOUD LABORATORY GU-2023-3513

7. Push to Docker Hub


Winpty docker login

32
DEVOPS ON CLOUD LABORATORY GU-2023-3513

8. Tag and push the docker image


Before doing make sure a repository with the same name as your image is created in your
docker.

docker push demonslayer5498/pyimage

9. Pull and Run


docker pull demonslayer5498/pyimage

docker run demonslayer5498/pyimage

33

You might also like