DevOps Tutorial: Docker, Kubernetes, and Azure DevOps
In this article, we break down everything you need to know about DevOps, so that you can get started building your own CI/CD pipeline.
Join the DZone community and get the full member experience.
Join For FreeIn this article, we will learn about DevOps and how it is different from the Agile methodology. We will also cover some popular DevOps tools and their roles in the DevOps lifecycle.
You Will Learn
- What is Docker, Kubernetes, and Azure DevOps
- What is DevOps and why do we need it?
- How is DevOps different from Agile?
- What are some important DevOps tools?
- How does Docker help DevOps?
- How does Kubernetes help DevOps?
- How does Azure DevOps help DevOps?
- What is Continuous Integration and Continuous Delivery (CI/CD)?
- What is Infrastructure as Code?
- How do Terraform and Ansible help DevOps?
Docker
Docker is an open-source software tool that is used to build, test, and deploy containerized applications. What is Containerization, by the way? Containerization is the concept of bundling all the libraries and files along with the application code in a single unit called a "Container" so that it can run on any infrastructure.
Kubernetes
Kubernetes is a container orchestration system that manages containerized applications and services. It takes care of the tasks performed in the containerized environment such as scaling, deployment, load balancing, etc. Kubernetes is portable, efficient, and cost-effective, and offers features like system integrations, API-based support, etc.
Azure DevOps
Azure DevOps is a Microsoft product that provides a wide range of tools and features that make the process of software development and deployment faster and more organized. It offers a set of processes that allows software developers, project managers, and other contributors to work together to develop software. It can be added to the existing editors or IDEs to allow the team to work effectively on projects of all sizes.
Let’s get started with a simple use case.
Free Courses — Learn in 10 Steps
What Is DevOps?
As with most buzzwords around software development, there is no accepted definition for DevOps.
Definitions vary from simple, like the one below, to complex, which can span the complete page of a book.
DevOps is the combination of cultural philosophies, practices, and tools that increases an organization’s ability to deliver applications and services at high velocity — Amazon Web Services (AWS)
Instead of trying to define DevOps, let’s understand how software development evolved to DevOps.
Waterfall Model
The Waterfall Model is a methodology that follows a structured approach. It consists of six phases: Requirements, Design, Implementation, Testing, Deployment, and Maintenance. Each phase builds upon the completion of the previous one. It progresses through these stages without revisiting earlier processes, making it a linear process.
The first few decades of software development were centered around the Waterfall model, and it approached software development the same way that you would approach building a real estate project — for example, building a bridge.
You will build software in multiple phases that can go anywhere from a few weeks to a few months.
In most waterfall projects, it would be months before the business sees a working version of an application.
Key Elements to Build Great Software
While working in the waterfall model for a few decades, we understand a few key elements around developing great software:
- Communication
- Feedback
- Automation
Importance of Communication
Communication between people is essential for the success of a software project.
In the Waterfall model, we tried to enhance communication by preparing 1000-page documents on Requirements, Design, Architecture, and Deployment.
But, over time, we discovered that:
- The best way to enhance communication within a team is to get them together. And get a variety of skills in the same team.
- Cross-functional teams — with a wide range of skills — work great.
Importance of Early Feedback
Getting feedback quickly is important. Building great software is all about getting quick feedback.
- Are we building an application that meets business expectations?
- Will your application have problems if it is deployed to production?
You don’t want to know it after a few months. You want to find it out as early as possible because the earlier we find a problem, the easier it is to fix it.
We found that the best software teams are structured to enable quick feedback.
Importance of Automation
Automation is critical. Software development involves a wide range of activities. Doing things manually is slow and error-prone. We understand that it’s essential to always look for opportunities to introduce automation.
Having understood the key elements to develop great software, let's look at how we evolved to Agile and DevOps.
Evolution to Agile
Agile is an approach that emphasizes incremental progress, frequent feedback, and the ability to respond to changing requirements through the development lifecycle. Agile promotes cross-functional teams to work in short development cycles, which fosters continuous improvement and delivers value to end users quickly. It was the first step in the evolution towards implementing our learnings with enhanced communication between teams, getting feedback, and bringing in automation.
Agile brought the business and development teams together into one team, which works to build great software in small iterations called Sprints.
Instead of spending weeks or months on each phase of development, Agile focuses on taking small requirements called user stories through the development cycle within a few days, sometimes within the same day.
How Did Agile Enhance Communication Between Teams?
Agile brought business and development teams together.
- Businesses are responsible for defining what to build. What are the requirements?
- Development is responsible for building a product that meets requirements. Development includes everybody involved in the design, coding, testing, and packaging of your software.
In Agile, a representative from the business, called a Product Owner, is always present with the team, and the team understands the business objectives clearly.
When the development team does not understand the requirements and is going down the wrong path, the Product Owner helps them do a course correction and stay on the correct path.
Result: The final product the team builds is something that the business wants.
Another important factor is that agile teams have cross-functional skills: coding skills (frontend, API, and databases), testing skills, and business skills. This enhances communication between people that have to work together to build great software.
Agile and Automation
What are the automation areas that agile teams focus on?
Software products can have a variety of defects:
- Functional defects mean the product does not work as expected.
- Technical defects make the maintenance of the software difficult. For example, code quality problems.
In general, agile teams are focused on using automation to find technical and functional defects as early as possible.
Agile teams also focus extensively on code quality. Tools like SONAR are used to assess the code quality of applications.
Is it sufficient if you have great automation tests and great code quality checks? The key is to run these processes frequently. Agile teams emphasize Continuous Integration, where commits to version control trigger a series of actions. This includes running Unit Tests, Automation Tests, and Code Quality Checks, all seamlessly integrated into a Continuous Integration Pipeline. Jenkins, a widely adopted CI/CD tool during the early Agile era, played a pivotal role in orchestrating these automated processes.
How Did Agile Promote Immediate Feedback?
The most important factor is that a business does not need to wait for months to see the final product. At the end of every sprint, the product is demoed to all stakeholders including architecture and business teams. All feedback is taken in while prioritizing user stories for the next sprint. Result: the final product the team builds is something that the business wants.
Another important factor that enables immediate feedback is continuous integration. Let’s say I commit some code into version control. Within 30 minutes, I get feedback if my code causes a unit test failure or an integration test failure. I will get feedback if my code does not meet code quality standards or does not have enough code coverage in the unit tests.
Was Agile successful? Yes. For sure. By focusing on improving the communication between business and development teams, and focusing on finding a variety of defects early, Agile took software development to the next level.
I had a wonderful experience working with some amazing teams using Agile. Software engineering, which for me represents all the efforts in building software from requirements to taking applications to live, for the first time, was as enjoyable as programming.
But does evolution stop? Nope.
New challenges emerged.
Evolution of Microservices Architectures
We started moving towards a microservices architecture, and we started building several small APIs instead of building large monolith applications.
What was the new challenge?
Operations have become more important. Instead of doing one monolith release a month, you are doing hundreds of small microservice releases every week. Debugging problems across microservices and getting visibility into what’s happening with the microservices became important.
It was time for a new buzzword in software development. DevOps.
Emergence of DevOps
What was the focus of DevOps?
The focus of DevOps was to enhance the communication between the development and operations teams.
- How do we make deployments easier?
- How do we make the work operations team does more visible to the development team?
How Did DevOps Enhance Communication Between Teams?
DevOps brought operations teams closer to development teams.
- In more mature enterprises, development and operations teams worked as one team. They started sharing common goals and both teams started to understand the challenges the other team faced.
- In enterprises, in the early stages of DevOps evolution, a representative from the operations team can be involved in the sprints — standups and retrospectives.
What Are the Automation Areas DevOps Teams Focus on?
In addition to the focus areas of Agile — Continuous Integration and test automation — DevOps teams were focused on helping automate several operations team's activities like provisioning servers, configuring software on servers, deploying applications, and monitoring production environments. A few key terminologies are continuous deployment, continuous delivery, and infrastructure as code.
Continuous deployment is all about continuously deploying a new version of software on test environments. In even more mature organizations like Google and Facebook, continuous delivery helps in continuously deploying software to production — maybe hundreds of production deployments per day.
Infrastructure as code is all about treating your infrastructure like you treat your application code. You create your infrastructure — servers, load balancers, and database — in an automated way using configuration. You would version control your infrastructure — so that you can track your infrastructure changes over some time.
How Did DevOps Promote Immediate Feedback?
DevOps brings operations and development teams together. Because operations and development are part of the same team, the entire team understands the challenges associated with operations and development.
- Any operational problems get quick attention from developers.
- Any challenges in taking software live to get the early attention of the operations team.
DevOps encouraged continuous integration, continuous delivery, and infrastructure as code.
- Because of continuous delivery, if I make a code change or a configuration change that might break a test or a staging environment, I would know it within a few hours.
- Because of Infrastructure as Code, developers can self-provision environments, deploy code, and find problems on their own without any help from the operations team.
I see Agile and DevOps as two phases that help us improve how we build great software. They don’t compete against each other, but together they help us build amazing software products.
As far as I am concerned, the objective of Agile and DevOps together is to do things that:
- Promote communication and feedback between business, development and operations teams
- Ease the pain points with automation.
A DevOps Story
Here’s an example story:
- You are the star developer in a team, and you need to make a quick fix.
- You go to a GitHub repository.
- You quickly check out the project.
- You quickly create your local environment.
- You make a change. You test it. You update the unit and automation tests.
- You commit it.
- You get an email saying it is deployed to QA.
- A few integration tests are automatically run.
- Your QA team gets an email asking for approval. They do a manual test and approve.
- Your code is live in production in a few minutes.
- You might think this is an ideal scenario. But, do you know that this is what is happening in innovative enterprises like Netflix, Amazon, and Google day in and day out?
This is the story of DevOps.
DevOps = Development + Operations
DevOps is a natural evolution of software development. DevOps is NOT JUST a tool, a framework, or just automation. It is a combination of all these.
DevOps focuses on people, processes, and products. The people part of DevOps is all about culture and creating a great mindset — a culture that promotes open communication and values quick feedback, a culture that values high-quality software.
Agile helped in bridging the gap between business and development teams. Development teams understood the priorities of the business and worked with the business to deliver the stories providing the most value first; however, the dev and ops teams were not aligned.
They had different goals.
- The goal of the dev team is to take as many new features to production as possible.
- The goal of the ops team was to keep the production environment as stable as possible.
As you can see, if taking things to production is difficult, dev and ops are unaligned.
DevOps aims to align the dev and ops teams with shared goals.
The dev team works with the ops team to understand and solve operational challenges. The ops team is part of the scrum team and understands the features under development.
How can we make this possible? Break down the wall between dev and ops!
Getting Dev and Ops Together
Option 1
In mature DevOps enterprises, dev and ops work as part of the same scrum team and share each other's responsibilities.
Option 2
However, if you are in the early stages of DevOps evolution, how can you get dev and ops to have common objectives and work together?
Here are some of the things you can do:
- Have the development team share some of the responsibilities of the operation team. For example, the dev team can take responsibility for new releases for the first week after production deployment. This helps the development team understand the challenges faced by operations in taking new releases live and helps them come together and find better solutions.
- Another thing you can do is involve a representative of the operations team in the scrum activities. Involve them in standups and retrospectives.
- The next thing you can do is to make the challenges faced by the Operations team more visible to the Development team. When you face any challenges in operations, make development teams part of the teams working on solutions.
Whichever way you take, find ways of breaking the wall and get the development and operations team together.
Another interesting option emerges because of automation. By using Infrastructure as Code and enabling self-provisioning for developers, you can create a common language that operations and development teams understand — code.
A DevOps Use Case
Consider the picture below:
This picture showcases two simple workflows
- Infrastructure as Code using Terraform and Azure DevOps to provision Kubernetes clusters.
- Continuous Deployment of microservices using Azure DevOps to build and deploy Docker images for microservices into Kubernetes clusters.
Does this sound complex?
Let’s break it down and try and understand them.
Let’s start with #2 — Continuous Deployment first.
#2: DevOps Continuous Deployment With Azure DevOps and Jenkins
What is the use of having great tests and code quality checks if you don’t run them often?
What is the use of deployment automation if you don't deploy software often enough?
As soon as a developer commits code into the version control system, the following steps are executed:
- Unit Tests
- Code Quality Checks
- Integration Tests
- Application Packaging — Building a deployable version of the application. Tools — Maven, Gradle, Docker
- Application Deployment — Putting new applications or new versions of the application live
- An email to the testing team to test the application
As soon as there is approval from the test team, the app is immediately deployed to the next environment.
This is called continuous deployment. If you continuously deploy up to production, it is called continuous delivery.
The most popular CI/CD tools are Azure DevOps and Jenkins.
#1: DevOps Infrastructure as Code With Terraform
Back in the day, we used to create environments and deploy applications manually.
Every time you create a server, this needs to be done manually.
- The software version needs to be updated
- Security patches need to be installed manually
You do it manually, and the following are the results:
- High chance of errors
- Replication environments are difficult
Infrastructure as Code
Infrastructure as Code — treat infrastructure the same way as application code.
Here are some of the important things to understand with Infrastructure as Code:
- Infra team focuses on value-added work (instead of routine work)
- Fewer errors and quick recovery from failures
- Servers are consistent (avoids configuration drift)
The most popular IaC tools are Ansible and Terraform.
Typically these are the steps in IaC:
- Provision Servers (Enabled by Cloud) from a template
- Install software
- Configure software
Server Provisioning
Typically, provisioning tools are used to provision servers and get the new server ready with networking capabilities. The most popular provisioning tools are Cloud Formation and Terraform.
Using Terraform, you can provision servers and the rest of your infrastructure, like load balancers, databases, networking configuration, etc. You can create servers using pre-created images created using tools like Packer and AMI (Amazon Machine Image).
Configuration Management
Configuration management tools are used to:
- Install software
- Configure software
Popular configuration management tools are Chef, Puppet, Ansible, and SaltStack. These are designed to install and manage software on existing servers.
Role of Docker and Kubernetes in DevOps
In the microservices world, a few microservices might be built with Java, a few with Python, and a few with JavaScript.
Different microservices will have different ways of building applications and deploying them to servers. This makes the operations team’s job difficult. How can we have a similar way of deploying multiple types of applications? Enter containers and Docker.
Using Docker, you can build images of microservices — irrespective of their language. You can run these images the same way on any infrastructure. This simplifies operations.
Kubernetes adds on to this by helping to orchestrate different types of containers and deploying them to clusters.
Kubernetes also provides:
- Service discovery
- Load balancing
- Centralized configuration
Docker and Kubernetes make DevOps easy.
Important DevOps Metrics
The following are some of the important DevOps metrics you can track and improve over some time.
- Deployment Frequency — How often are applications deployed to production?
- Time to Market — How long do you need to take a feature from coding to production?
- Failure Rate of New Releases — How many of your releases fail?
- Lead Time to Fixes — How long do you need to make a production fix and release it to production?
- Mean Time to Recovery — How long do you take to recover your production environment from a major issue?
DevOps Best Practices
Agile Project Management
Agile project management is an iterative approach to developing software applications. Through this practice, teams can enhance development speed, and respond well to varying customer needs. Agile methodology is different from the traditional Waterfall method wherein there were long release cycles. Agile uses Scrum and Kanban frameworks to deliver the software as per client's needs.
Using the Right Set of Tools
Software developers and system administrators need to pick up and use the right set of DevOps tools in each stage of the DevOps lifecycle to build high-value applications.
Below are some of the examples of tools DevOps engineers, system admins, and other stakeholders can use:
- Tools like Jira can help the team to segregate tasks into smaller and more manageable pieces and hence helps in increasing the productivity of the team.
- Tools like Jenkins and Bitbucket can help you automate code flows right from the testing to the deployment phase.
- Tools like Slack, GetFeedback, etc. can help DevOps teams to integrate chat tools with the survey platforms to collect and review real-time feedback.
Continuous Integration/Continuous Delivery
Continuous Integration (CI) and Continuous Delivery (CD) are modern software development practices that help organizations ship software quickly and effectively. With CI, developers continuously commit the application code into a shared repository several times. With CD, the code gets delivered to production quickly and seamlessly. CD also ensures the integration happens without any delays or glitches.
Integrating Security
Security is an important part of the software development process. In the present world, where cyber crimes and data breach incidents are on the rise, organizations are realizing the importance of integrating securities into their systems. In the past, security was generally considered in the last phases of the software development lifecycle but with the advent of DevSecOps, security is being considered and integrated right from day one of the application development.
Observability
Observability is important while developing complex applications that use microservice and cloud architectures. Observability helps DevOps teams understand the complex structure of different applications (microservices, cloud apps, etc.) and helps address the environment's future needs. Kubernetes observability and Splunk are some of the best observability platforms.
DevOps Maturity Signals
How do you measure the maturity of your DevOps implementations?
- The time taken from the development process to the deployment should be overall satisfactory
- Determining the frequency of the new code deployment
- Mean Time to Recovery (MTTR) from an incident or unexpected event should be as low as possible
- Successful deployments should outgrow failure deployments
- Faster and reliable releases should yield high Return on Investment (ROI).
DevOps Transformation Best Practices
- Leadership buy-in is critical
- Involves upfront costs
- Setup COEs to help teams
- Choose the right application and team
- Start small
- Sharing learnings (newsletters, communication, COEs)
- Encourage people with exploration and automation mindset
- Recognize DevOps teams
Published at DZone with permission of Ranga Karanam, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments