Devops Interview Questions and Answers
1. What are Containers?
Answer: Containers are a form of lightweight virtualization, heavier than ‘chroot’ but lighter than ‘hypervisors’. They provide isolation among processes while using the same kernel as the host machine, and ‘groups’ functionality within the kernel.
2. What is Continuous Delivery?
Answer: It is the practice of delivering the software for testing as soon as it is built by CI (Continuous Integration) servers.
3. What is your favorite scripting language for DevOps?
Answer: In DevOps, we use different scripting languages for different purposes. There is no single language that can work in all the scenarios. Some of the popular scripting languages that we use are as follows:
Bash: On Unix based systems we use Bash shell scripting for automating tasks.
Python: For complicated programming and large modules we use Python. We can easily use a wide variety of standard libraries with Python.
Groovy: This is a Java-based scripting language. We need JVM installed in an environment to use Groovy. It is very powerful and it provides very powerful features.
Perl: This is another language that is very useful for text parsing. We use it in web applications. Devops Training Free Demo
4. What is the need for DevOps?
Answer: According to me, this answer should start by explaining the general market trend. Instead of releasing big sets of features, companies are trying to see if small features can be transported to their customers through a series of release trains. This has many advantages like quick feedback from customers, the better quality of software, etc. which in turn leads to high customer satisfaction.
To achieve this, companies are required to:
Increase deployment frequency
The lower failure rate of new releases
Shortened lead time between fixes
Faster mean time to recovery in the event of new release crashing
DevOps fulfills all these requirements and helps in achieving seamless software delivery. You can give examples of companies like Etsy, Google, and Amazon which have adopted DevOps to achieve levels of performance that were unthinkable even five years ago. They are doing tens, hundreds or even thousands of code deployments per day while delivering world-class stability, reliability, and security.
5. How is DevOps different from Agile / SDLC?
Answer: I would advise you to go with the below explanation:
Agile is a set of values and principles about how to produce i.e. develop software. Example: if you have some ideas and you want to turn those ideas into working software, you can use the Agile values and principles as a way to do that. But, that software might only be working on a developer’s laptop or in a test environment. You want a way to quickly, easily and repeatably move that software into production infrastructure, in a safe and simple way. To do that you need DevOps tools and techniques.
You can summarize by saying Agile software development methodology focuses on the development of software but DevOps, on the other hand, is responsible for development as well as the deployment of the software in the safest and most reliable way possible. Here’s a blog that will give you more information on the evolution of DevOps.
6. Which are the top DevOps tools? Which tools have you worked on?
Answer: The most popular DevOps tools are mentioned below:
Git: Version Control System tool
Jenkins: Continuous Integration tool
Selenium: Continuous Testing tool
Puppet, Chef, Ansible: Configuration Management and Deployment tools
Nagios: Continuous Monitoring tool
Docker: Containerization tool
You can also mention any other tool if you want, but make sure you include the above tools in your answer.
The second part of the answer has two possibilities:
If you have experience with all the above tools then you can say that I have worked on all these tools for developing good quality software and deploying that software easily, frequently, and reliably.
If you have experience only with some of the above tools then mention those tools and say that I have specialization in these tools and have an overview of the rest of the tools.
7. How do all these tools work together?
Answer: Given below is a generic logical flow where everything gets automated for seamless delivery. However, this flow may vary from organization to organization as per the requirement.
Developers develop the code and this source code is managed by Version Control System tools like Git etc.
Developers send this code to the Git repository and any changes made in the code is committed to this Repository.
Jenkins pulls this code from the repository using the Git plugin and builds it using tools like Ant or Maven.
Configuration management tools like puppet deploys & provisions testing environment and then Jenkins releases this code on the test environment on which testing is done using tools like selenium.
Once the code is tested, Jenkins send it for deployment on the production server (even production server is provisioned & maintained by tools like a puppet).
After deployment It is continuously monitored by tools like Nagios.
Docker containers provide a testing environment to test the build features.
8. What is the most important thing DevOps helps us achieve?
Answer: According to me, the most important thing that DevOps helps us achieve is to get the changes into production as quickly as possible while minimizing risks in software quality assurance and compliance. This is the primary objective of DevOps. Learn more in this DevOps tutorial blog.
However, you can add many other positive effects of DevOps. For example, clearer communication and better working relationships between teams i.e. both the Ops team and Dev team collaborate together to deliver good quality software which in turn leads to higher customer satisfaction.
9. Explain with a use case where DevOps can be used in industry/real-life??
Answer: There are many industries that are using DevOps so you can mention any of those use cases, you can also refer the below example:
Etsy is a peer-to-peer e-commerce website focused on handmade or vintage items and supplies, as well as unique factory-manufactured items. Etsy struggled with slow, painful site updates that frequently caused the site to go down. It affected sales for millions of Etsy’s users who sold goods through the online market place and risked driving them to the competitor.
With the help of a new technical management team, Etsy transitioned from its waterfall model, which produced four-hour full-site deployments twice weekly, to a more agile approach. Today, it has a fully automated deployment pipeline, and its continuous delivery practices have reportedly resulted in more than 50 deployments a day with fewer disruptions.
10. Explain your understanding and expertise on both the software development side and the technical operations side of an organization you have worked with in the past?
Answer: For this answer, share your past experience and try to explain how flexible you were in your previous job. You can refer the below example:
DevOps engineers almost always work in a 24/7 business-critical online environment. I was adaptable to on-call duties and was available to take up real-time, live-system responsibility. I successfully automated processes to support continuous software deployments. I have experience with public/private clouds, tools like Chef or Puppet, scripting and automation with tools like Python and PHP, and a background in Agile.
11. What are the anti-patterns of DevOps?
Answer: A pattern is a common usage usually followed. If a pattern commonly adopted by others does not work for your organization and you continue to blindly follow it, you are essentially adopting an anti-pattern.
There are myths about DevOps. Some of them include:
DevOps is a process
Agile equals DevOps?
We need a separate DevOps group
Devops will solve all our problems
DevOps means Developers Managing Production
DevOps is Development-driven release management
DevOps is not development driven.
DevOps is not IT Operations driven.
We can’t do DevOps – We’re Unique
We can’t do DevOps – We’ve got the wrong people
12. What are the benefits of using version control?
Answer: I will suggest you include the following advantages of version control:
With the Version Control System (VCS), all the team members are allowed to work freely on any file at any time. VCS will later allow you to merge all the changes into a common version.
All the past versions and variants are neatly packed up inside the VCS. When you need it, you can request any version at any time and you’ll have a snapshot of the complete project right at hand.
Every time you save a new version of your project, your VCS requires you to provide a short description of what was changed. Additionally, you can see what exactly was changed in the file’s content. This allows you to know who has made what change in the project.
A distributed VCS like Git allows all the team members to have a complete history of the project so if there is a breakdown in the central server you can use any of your teammate’s local Git repository.
13. Describe the branching strategies you have used?
Answer: This question is asked to test your branching experience so tell them about how you have used branching in your previous job and what purpose does it serves, you can refer the below points:
Feature branching: A feature branch model keeps all of the changes for a particular feature inside of a branch. When the feature is fully tested and validated by automated tests, the branch is then merged into master.
Task branching: In this model, each task is implemented on its own branch with the task key included in the branch name. It is easy to see which code implements which task, just look for the task key in the branch name.
Release branching: Once the develop branch has acquired enough features for a release, you can clone that branch to form a Release branch. Creating this branch starts the next release cycle, so no new features can be added after this point, only bug fixes, documentation generation, and other release-oriented tasks should go in this branch. Once it is ready to ship, the release gets merged into master and tagged with a version number. In addition, it should be merged back into the develop branch, which may have progressed since the release was initiated.
In the end, tell them that branching strategies vary from one organization to another, so I know basic branching operations like delete, merge, checking out a branch, etc.
14. Which VCS tool you are comfortable with?
Answer: You can just mention the VCS tool that you have worked on like this: “I have worked on Git and one major advantage it has over other VCS tools like SVN is that it is a distributed version control system.”
Distributed VCS tools do not necessarily rely on a central server to store all the versions of a project’s files. Instead, every developer “clones” a copy of a repository and has the full history of the project on their own hard drive.
15. What is Git?
Answer: Git is a Distributed Version Control system (DVCS). It can track changes to a file and allows you to revert back to any particular change.
16. In Git how do you revert a commit that has already been pushed and made public?
Answer:
It can be done in two ways:
By removing or fixing the bad file in a new commit and pushing it to the remote repository. Once the necessary changes to the file have been made, commit it to the remote repository. Use: git commit -m “commit message”
By creating a new commit that undoes all changes that were made in the bad commit. To do this, use command: git revert
17. How do you squash the last N commits into a single commit?
Answer: There are two options to squash the last N commits into a single commit. Include both of the below-mentioned options in your answer:
If you want to write the new commit message from scratch use the following command
git reset –soft HEAD~N &&
git commit
If you want to start editing the new commit message with a concatenation of the existing commit messages then you need to extract those messages and pass them to Git commit for that I will use
git reset –soft HEAD~N &&
git commit –edit -m”$(git log –format=%B –reverse .HEAD@{N})”
18. How can we determine the commit that is the source of a bug in GIT?
Answer: In GIT we can use git bisect command to find the commit that has introduced a bug in the system.
GIT bisect command internally uses a binary search algorithm to find the commit that introduced a bug.
We first tell a bad commit that contains the bug and a good commit that was present before the bug was introduced.
Then git bisect picks a commit between those two endpoints and asks us whether the selected commit is good or bad.
It continues to narrow down the range until it discovers the exact commit responsible for introducing the bug.
19. What is Git rebase and how can it be used to resolve conflicts in a feature branch before the merge?
Answer: According to me, you should start by saying git rebase is a command which will merge another branch into the branch where you are currently working, and move all of the local commits that are ahead of the rebased branch to the top of the history on that branch.
Now once you have defined Git rebase time for an example to show how it can be used to resolve conflicts in a feature branch before merge, if a feature branch was created from master, and since then the master branch has received new commits, Git rebase can be used to move the feature branch to the tip of master.
The command effectively will replay the changes made in the feature branch at the tip of the master, allowing conflicts to be resolved in the process. When done with care, this will allow the feature branch to be merged into master with relative ease and sometimes as a simple fast-forward operation. (Interview Questions and Answers)
20. How do you configure a Git repository to run code sanity checking tools right before making commits, and preventing them if the test fails?
Answer: Now explain how to achieve this, this can be done with a simple script related to the pre-commit hook of the repository. The pre-commit hook is triggered right before a commit is made, even before you are required to enter a commit message. In this script, one can run other tools, such as lines and perform sanity checks on the changes being committed into the repository.
Finally, give an example, you can refer the below script:
#!/bin/sh
files=$(git diff –cached –name-only –diff-filter=ACM | grep ‘.go$’)
if [ -z files ]; then
exit 0
fi
unfmtd=$(gofmt -l $files)
if [ -z unfmtd ]; then
exit 0
fi
echo “Some .go files are not fmt’d”
exit 1
This script checks to see if any .go file that is about to be committed needs to be passed through the standard Go source code formatting tool gofmt. By exiting with a non-zero status, the script effectively prevents the commit from being applied to the repository. Devops Video Training
21. How do you find a list of files that have changed in a particular commit?
Answer: For this answer instead of just telling the command, explain what exactly this command will do so you can say that To get a list file that has changed in a particular commit use command
git diff-tree -r {hash}
Given the commit hash, this will list all the files that were changed or added in that commit. The -r flag makes the command list individual files, rather than collapsing them into root directory names only.
You can also include the below mention point although it is totally optional but will help in impressing the interviewer.
The output will also include some extra information, which can be easily suppressed by including two flags:
git diff-tree –no-commit-id –name-only -r {hash}
Here –no-commit-id will suppress the commit hashes from appearing in the output, and –name-only will only print the file names, instead of their paths.
22. How do you set up a script to run every time a repository receives new commits through push?
Answer: There are three ways to configure a script to run every time a repository receives new commits through push, one needs to define either a pre-receive, update or a post-receive hook depending on when exactly the script needs to be triggered.
Pre-receive hook in the destination repository is invoked when commits are pushed to it. Any script bound to this hook will be executed before any references are updated. This is a useful hook to run scripts that help enforce development policies.
Update hook works in a similar manner to pre-receive hook and is also triggered before any updates are actually made. However, the update hook is called once for every commit that has been pushed to the destination repository.
Finally, post-receive hook in the repository is invoked after the updates have been accepted into the destination repository. This is an ideal place to configure simple deployment scripts, invoke some continuous integration systems, dispatch notification emails to repository maintainers, etc.
Hooks are local to every Git repository and are not versioned. Scripts can either be created within the hooks directory inside the “.git” directory, or they can be created elsewhere and links to those scripts can be placed within the directory.
23. How will you know in Git if a branch has already been merged into master?
Answer: I will suggest you include both the below-mentioned commands:
git branch –merged lists the branches that have been merged into the current branch.
git branch –no-merged lists the branches that have not been merged.
24. What is meant by Continuous Integration?
Answer: I will advise you to begin this answer by giving a small definition of Continuous Integration (CI). It is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.
25. Why do you need a Continuous Integration of Dev & Testing?
Answer: Continuous Integration of Dev and Testing improves the quality of software, and reduces the time taken to deliver it, by replacing the traditional practice of testing after completing all development. It allows the Dev team to easily detect and locate problems early because developers need to integrate code into a shared repository several times a day (more frequently). Each check-in is then automatically tested.
26. What are the success factors for Continuous Integration?
Answer: Here you have to mention the requirements for Continuous Integration. You could include the following points in your answer:
Maintain a code repository
Automate the build
Make the build self-testing
Everyone commits to the baseline every day
Every commit (to baseline) should be built
Keep the build fast
Test in a clone of the production environment
Make it easy to get the latest deliverables
Everyone can see the results of the latest build
Automate deployment
27. Explain how you can move or copy Jenkins from one server to another?
Answer: I will approach this task by copying the jobs directory from the old server to the new one. There are multiple ways to do that; I have mentioned them below:
You can:
Move a job from one installation of Jenkins to another by simply copying the corresponding job directory.
Make a copy of an existing job by making a clone of a job directory by a different name.
Rename an existing job by renaming a directory. Note that if you change a job name you will need to change any other job that tries to call the renamed job.
28. Explain how can create a backup and copy files in Jenkins?
Answer: To create a backup, all you need to do is to periodically back up your JENKINS_HOME directory. This contains all of your build jobs configurations, your slave node configurations, and your build history. To create a back-up of your Jenkins setup, just copy this directory. You can also copy a job directory to clone or replicate a job or rename the directory.
29. Explain how you can setup Jenkins job?
Answer: My approach to this answer will be to first mention how to create a Jenkins job. Go to Jenkins top page, select “New Job”, then choose “Build a free-style software project”.
Then you can tell the elements of this freestyle job:
Optional SCM, such as CVS or Subversion where your source code resides.
Optional triggers to control when Jenkins will perform builds.
Some sort of build script that performs the build (ant, maven, shell script, batch file, etc.) where the real work happens.
Optional steps to collect information out of the build, such as archiving the artifacts and/or recording Javadoc and test results.
Optional steps to notify other people/systems with the build result, such as sending e-mails, IMs, updating issue tracker, etc..
30. Mention some of the useful plugins in Jenkins?
Answer: Below, I have mentioned some important Plugins:
Maven 2 project
Amazon EC2
HTML publisher
Copy artifact
Join
Green Balls
These Plugins, I feel are the most useful plugins. If you want to include any other Plugin that is not mentioned above, you can add them as well. But, make sure you first mention the above-stated plugins and then add your own.
31. How will you secure Jenkins?
Answer: The way I secure Jenkins is mentioned below. If you have any other way of doing it, please mention it in the comments section below:
Ensure global security is on.
Ensure that Jenkins is integrated with my company’s user directory with the appropriate plugin.
Ensure that the matrix/Project matrix is enabled to fine-tune access.
Automate the process of setting rights/privileges in Jenkins with custom version controlled script.
Limit physical access to Jenkins data/folders.
Periodically run security audits on same.
32. What is Continuous Testing?
Answer: Continuous Testing is the process of executing automated tests as part of the software delivery pipeline to obtain immediate feedback on the business risks associated with the latest build. In this way, each build is tested continuously, allowing Development teams to get fast feedback so that they can prevent those problems from progressing to the next stage of Software delivery life-cycle. This dramatically speeds up a developer’s workflow as there’s no need to manually rebuild the project and re-run all tests after making changes.
33. What is Automation Testing?
Answer: Automation testing or Test Automation is a process of automating the manual process to test the application/system under test. Automation testing involves the use of separate testing tools which lets you create test scripts which can be executed repeatedly and doesn’t require any manual intervention.
34. What are the benefits of Automation Testing?
Answer: I have listed down some advantages of automation testing. Include these in your answer and you can add your own experience of how Continuous Testing helped your previous company:
Supports execution of repeated test cases
Aids in testing a large test matrix
Enables parallel execution
Encourages unattended execution
Improves accuracy thereby reducing human-generated errors
Saves time and money
35. Why is Continuous Testing important for DevOps?
Answer: You can answer this question by saying, “Continuous Testing allows any change made in the code to be tested immediately. This avoids the problems created by having “big-bang” testing left to the end of the cycle such as release delays and quality issues. In this way, Continuous Testing facilitates more frequent and good quality releases.”
Devops Training Online From Real-Time Experts
36. What are the key elements of Continuous Testing tools?
Answer: Key elements of Continuous Testing are:
Risk Assessment: It Covers risk mitigation tasks, technical debt, quality assessment, and test coverage optimization to ensure the build is ready to progress toward the next stage.
Policy Analysis: It ensures all processes align with the organization’s evolving business and compliance demands are met.
Requirements Traceability: It ensures true requirements are met and rework is not required. An object assessment is used to identify which requirements are at risk, working as expected or require further validation.
Advanced Analysis: It uses automation in areas such as static code analysis, changes impact analysis and scope assessment/prioritization to prevent defects in the first place and accomplishing more within each iteration.
Test Optimization: It ensures tests yield accurate outcomes and provide actionable findings. Aspects include Test Data Management, Test Optimization Management, and Test Maintenance
Service Virtualization: It ensures access to real-world testing environments. Service visualization enables access to the virtual form of the required testing stages, cutting the waste time to test environment setup and availability.
37. What do you understand by “Infrastructure as code”? How does it fit into the DevOps methodology?
Answer: Infrastructure as Code (IAC) is a type of IT infrastructure that operations teams can use to automatically manage and provision through code, rather than using a manual process.
Companies for faster deployments treat infrastructure like software: as code that can be managed with the DevOps tools and processes. These tools let you make infrastructure changes more easily, rapidly, safely and reliably.
38. Which among Puppet, Chef, SaltStack, and Ansible is the best Configuration Management (CM) tool?
Answer: This depends on the organization’s need so mention few points on all those tools:
Puppet is the oldest and most mature CM tool. Puppet is a Ruby-based Configuration Management tool, but while it has some free features, much of what makes Puppet great is only available in the paid version. Organizations that don’t need a lot of extras will find Puppet useful, but those needing more customization will probably need to upgrade to the paid version.
The chef is written in Ruby, so it can be customized by those who know the language. It also includes free features, plus it can be upgraded from open source to enterprise-level if necessary. On top of that, it’s a very flexible product.
Ansible is a very secure option since it uses Secure Shell. It’s a simple tool to use, but it does offer a number of other services in addition to configuration management. It’s very easy to learn, so it’s perfect for those who don’t have a dedicated IT staff but still need a configuration management tool.
SaltStack is a python based open source CM tool made for larger businesses, but its learning curve is fairly low.
39. What is Puppet?
Answer: I will advise you to first give a small definition of Puppet. It is a Configuration Management tool which is used to automate administration tasks.
Now you should describe its architecture and how Puppet manages its Agents. Puppet has a Master-Slave architecture in which the Slave has to first send a Certificate signing request to Master and Master has to sign that Certificate in order to establish a secure connection between Puppet Master and Puppet Slave as shown in the diagram below. Puppet Slave sends a request to Puppet Master and Puppet Master then pushes configuration on Slave.
40. Before a client can authenticate with the Puppet Master, its certs need to be signed and accepted. How will you automate this task?
Answer: The easiest way is to enable auto-signing in puppet.conf.
Do mention that this is a security risk. If you still want to do this:
Firewall your puppet master – restrict port tcp/8140 to only networks that you trust.
Create puppet masters for each ‘trust zone’, and only include the trusted nodes in that Puppet masters manifest.
Never use a full wildcard such as *.
41. Which open source or community tools do you use to make Puppet more powerful?
Answer: Over here, you need to mention the tools and how you have used those tools to make Puppet more powerful. Below is one example for your reference:
Changes and requests are ticketed through Jira and we manage requests through an internal process. Then, we use Git and Puppet’s Code Manager app to manage Puppet code in accordance with best practices. Additionally, we run all of our Puppet changes through our continuous integration pipeline in Jenkins using the beaker testing framework.
42. What is the architecture of Puppet?
Answer: It has the following architectural components:
Configuration Language: Puppet provides a language that is used to configure Resources. We have to specify what Action has to be applied to which Resource. The Action has three items for each Resource: type, title, and list of attributes of a resource. Puppet code is written in Manifests files.
Resource Abstraction: We can create Resource Abstraction in Puppet so that we can configure resources on different platforms. Puppet agent uses a Factor for passing the information of an environment to the Puppet server. In Factor, we have information about IP, hostname, OS etc of the environment.
Transaction: In Puppet, Agent sends Factor to Master server. Master sends back the catalog to Client. The agent applies any configuration changes to the system. Once all changes are applied, the result is sent to Server.
43. What is Puppet Module and How it is different from Puppet Manifest?
Answer: A Puppet Module is a collection of Manifests and data (such as facts, files, and templates), and they have a specific directory structure. Modules are useful for organizing your Puppet code because they allow you to split your code into multiple Manifests. It is considered the best practice to use Modules to organize almost all of your Puppet Manifests.
Puppet programs are called Manifests which are composed of Puppet code and their file names use the .pp extension.
44. Can one consider DevOps as an Agile methodology?
Answer: DevOps can be considered complementary to the agile methodology, but not completely similar.
45. Name some of the top tools used in DevOps? What are the tools that you have used?
Answer: Some of the common tools are – Docker, Git, Selenium, Puppet, Nagios and Chef
46. What is Version control?
Answer: It is a system that records changes to a file or set of files over time so that you can recall specific versions later.
47. What are the uses of Version control?
Answer:
Revert files back to a previous state.
Revert the entire project back to a previous state.
Compare changes over time.
See who last modified something that might be causing a problem.
Who introduced an issue and when.
48. Which is the most popular scripting language in DevOps?
Answer: Python.
49. What is Vagrant and what is it used for?
Answer: a Vagrant is a tool that can create and manage virtualized (or containerized) environments for testing and developing software.
50. What is Git bisect?
Answer: Git bisect is used to find the commit that introduced a bug by using binary search.