DevOps Interview Question Part 1

What do you know about DevOps?

Your answer must be simple and straightforward. Begin by explaining the growing importance of DevOps in the IT industry. Discuss how such an approach aims to synergize the efforts of the development and operations teams to accelerate the delivery of software products, with a minimal failure rate. Include how DevOps is a value-added practice, where development and operations engineers join hands throughout the product or service lifecycle, right from the design stage to the point of deployment.

How is DevOps different from agile methodology?

DevOps is a culture that allows the development and the operations team to work together. This results in continuous development, testing, integration, deployment, and monitoring of the software throughout the lifecycle.

DevOps different from Agile

Agile is a software development methodology that focuses on iterative, incremental, small, and rapid releases of software, along with customer feedback. It addresses gaps and conflicts between the customer and developers.

DevOps different from Agile

DevOps addresses gaps and conflicts between the Developers and IT Operations.

DevOps different from Agile

Which are some of the most popular DevOps tools?

The most popular DevOps tools include:

Selenium
Puppet
Chef
Git
Jenkins
Ansible
Docker

DevOps Interview Question

What are the different phases in DevOps?

The various phases of the DevOps lifecycle are as follows:

  • Plan – Initially, there should be a plan for the type of application that needs to be developed. Getting a rough picture of the development process is always a good idea.
  • Code – The application is coded as per the end-user requirements. 
  • Build – Build the application by integrating various codes formed in the previous steps.
  • Test – This is the most crucial step of the application development. Test the application and rebuild, if necessary.
  • Integrate – Multiple codes from different programmers are integrated into one.
  • Deploy – Code is deployed into a cloud environment for further usage. It is ensured that any new changes do not affect the functioning of a high traffic website.
  • Operate – Operations are performed on the code if required.
  • Monitor – Application performance is monitored. Changes are made to meet the end-user requirements.
DevOps Lifecycle

The above figure indicates the DevOps lifecycle.

Mention some of the core benefits of DevOps.

The core benefits of DevOps are as follows:

Technical benefits

  • Continuous software delivery
  • Less complex problems to manage
  • Early detection and faster correction of defects

Business benefits

  • Faster delivery of features
  • Stable operating environments
  • Improved communication and collaboration between the teams

How will you approach a project that needs to implement DevOps?

The following standard approaches can be used to implement DevOps in a specific project:

Stage 1

An assessment of the existing process and implementation for about two to three weeks to identify areas of improvement so that the team can create a road map for the implementation.

Stage 2

Create a proof of concept (POC). Once it is accepted and approved, the team can start on the actual implementation and roll-out of the project plan.

Stage 3

The project is now ready for implementing DevOps by using version control/integration/testing/deployment/delivery and monitoring followed step by step.

By following the proper steps for version control, integration, testing, deployment, delivery, and monitoring, the project is now ready for DevOps implementation.

Advance DevOps Interview Question

What is the difference between continuous delivery and continuous deployment?

Continuous DeliveryContinuous Deployment
Ensures code can be safely deployed on to productionEvery change that passes the automated tests is deployed to production automatically
Ensures business applications and services function as expectedMakes software development and the release process faster and more robust
Delivers every change to a production-like environment through rigorous automated testingThere is no explicit approval from a developer and requires a developed culture of monitoring

What is the role of configuration management in DevOps?

  • Enables management of and changes to multiple systems.
  • Standardizes resource configurations, which in turn, manage IT infrastructure.
  • It helps with the administration and management of multiple servers and maintains the integrity of the entire infrastructure.

How does continuous monitoring help you maintain the entire architecture of the system?

Continuous monitoring in DevOps is a process of detecting, identifying, and reporting any faults or threats in the entire infrastructure of the system.

  • Ensures that all services, applications, and resources are running on the servers properly.
  • Monitors the status of servers and determines if applications are working correctly or not.
  • Enables continuous audit, transaction inspection, and controlled monitoring.

What is the role of AWS in DevOps?

AWS has the following role in DevOps:

  • Flexible services – Provides ready-to-use, flexible services without the need to install or set up the software.
  • Built for scale – You can manage a single instance or scale to thousands using AWS services.
  • Automation – AWS lets you automate tasks and processes, giving you more time to innovate
  • Secure – Using AWS Identity and Access Management (IAM), you can set user permissions and policies.
  • Large partner ecosystem – AWS supports a large ecosystem of partners that integrate with and extend AWS services.

DevOps Interview Question

Name three important DevOps KPIs.

The three important KPIs are as follows:

  • Meantime to failure recovery – This is the average time taken to recover from a failure.
  • Deployment frequency – The frequency in which the deployment occurs. 
  • Percentage of failed deployments – The number of times the deployment fails.

Explain the term “Infrastructure as Code” (IAC) as it relates to configuration management.

  • Writing code to manage configuration, deployment, and automatic provisioning.
  • Managing data centers with machine-readable definition files, rather than physical hardware configuration.
  • Ensuring all your servers and other infrastructure components are provisioned consistently and effortlessly. 
  • Administering cloud computing environments, also known as infrastructure as a service (IaaS).

How is IAC implemented using AWS?

Start by talking about the age-old mechanisms of writing commands onto script files and testing them in a separate environment before deployment and how this approach is being replaced by IAC. Similar to the codes written for other services, with the help of AWS, IAC allows developers to write, test, and maintain infrastructure entities in a descriptive manner, using formats such as JSON or YAML. This enables easier development and faster deployment of infrastructure changes.

Advance DevOps Interview Question

Why Has DevOps Gained Prominence over the Last Few Years?

Before talking about the growing popularity of DevOps, discuss the current industry scenario. Begin with some examples of how big players such as Netflix and Facebook are investing in DevOps to automate and accelerate application deployment and how this has helped them grow their business. Using Facebook as an example, you would point to Facebook’s continuous deployment and code ownership models and how these have helped it scale up but ensure the quality of experience at the same time. Hundreds of lines of code are implemented without affecting quality, stability, and security.

Your next use case should be Netflix. This streaming and on-demand video company follow similar practices with fully automated processes and systems. Mention the user base of these two organizations: Facebook has 2 billion users while Netflix streams online content to more than 100 million users worldwide.

These are great examples of how DevOps can help organizations to ensure higher success rates for releases, reduce the lead time between bug fixes, streamline and continuous delivery through automation, and an overall reduction in manpower costs.

We will now look into the next set of DevOps Interview Questions that includes – Git, Selenium, Jenkins.

Explain the difference between a centralized and distributed version control system (VCS).

Centralized Version Control System

  • All file versions are stored on a central server
  • No developer has a copy of all files on a local system
  • If the central server crashes, all data from the project will be lost

Distributed Control System

  • Every developer has a copy of all versions of the code on their systems
  • Enables team members to work offline and does not rely on a single location for backups
  • There is no threat, even if the server crashes

What is the git command that downloads any repository from GitHub to your computer?

Git Clone

The git command that downloads any repository from GitHub to your computer is git clone.

DevOps Interview Question

How do you push a file from your local system to the GitHub repository using Git?

First, connect the local repository to your remote repository:

git remote add origin [copied web address]

// Ex: git remote add origin https://github.com/Simplilearn-github/test.git

Second, push your file to the remote repository:

git push origin master

How is a bare repository different from the standard way of initializing a Git repository?

Using the standard method:

git init

  • You create a working directory with git init
  • A .git subfolder is created with all the git-related revision history

Using the bare way

git init –bare

  • It does not contain any working or checked out a copy of source files
  • Bare repositories store git revision history in the root folder of your repository, instead of the .git subfolder

Which of the following CLI commands can be used to rename files?

  1. git rm
  2. git mv
  3. git rm -r
  4. None of the above

The correct answer is B) git mv

Advance DevOps Interview Question

What is the process for reverting a commit that has already been pushed and made public?

There are two ways that you can revert a commit:

Remove or fix the bad file in a new commit and push it to the remote repository. Then commit it to the remote repository using:

git commit –m “commit message”

Create a new commit that undoes all the changes that were made in the bad commit. Use the following command:

git revert
Example: git revert 56de0938f

Explain the difference between git fetch and git pull.

Git fetchGit pull
Git fetch only downloads new data from a remote repositoryGit pull updates the current HEAD branch with the latest changes from the remote server
Does not integrate any new data into your working filesDownloads new data and integrate it with the current working files
Users can run a Git fetch at any time to update the remote-tracking branchesTries to merge remote changes with your local ones
Command – git fetch origin                  git fetch –-allCommand – git pull origin master

What is Git stash?

A developer working with a current branch wants to switch to another branch to work on something else, but the developer doesn’t want to commit changes to your unfinished work. The solution to this issue is Git stash. Git stash takes your modified tracked files and saves them on a stack of unfinished changes that you can reapply at any time.

DevOps Interview Question

Explain the concept of branching in Git.

Suppose you are working on an application, and you want to add a new feature to the app. You can create a new branch and build the new feature on that branch.

  • By default, you always work on the master branch
  • The circles on the branch represent various commits made on the branch
  • After you are done with all the changes, you can merge it with the master branch

What is the difference between Git Merge and Git Rebase?

Suppose you are working on a new feature in a dedicated branch, and another team member updates the master branch with new commits. You can use these two functions:

Git Merge

To incorporate the new commits into your feature branch, use Git merge.

  • Creates an extra merge commit every time you need to incorporate changes
  • But, it pollutes your feature branch history
Git Merge

Git Rebase

As an alternative to merging, you can rebase the feature branch on to master.

  • Incorporates all the new commits in the master branch
  • It creates new commits for every commit in the original branch and rewrites project history

How do you find a list of files that have been changed in a particular commit?

The command to get a list of files that have been changed in a particular commit is:

git diff-tree –r {commit hash}

Example: git diff-tree –r 87e673f21b

  • -r flag instructs the command to list individual files
  • commit hash will list all the files that were changed or added in that commit

Advance DevOps Interview Question

What is a merge conflict in Git, and how can it be resolved?

A Git merge conflict happens when you have merge branches with competing for commits, and Git needs your help to decide which changes to incorporate in the final merge.

Manually edit the conflicted file to select the changes that you want to keep in the final merge.

Resolve using GitHub conflict editor

This is done when a merge conflict is caused after competing for line changes. For example, this may occur when people make different changes to the same line of the same file on different branches in your Git repository.

  • Resolving a merge conflict using conflict editor:
  • Under your repository name, click “Pull requests.”
  • In the “Pull requests” drop-down, click the pull request with a merge conflict that you’d like to resolve
  • Near the bottom of your pull request, click “Resolve conflicts.”
  • Decide if you only want to keep your branch’s changes, the other branch’s changes, or make a brand new change, which may incorporate changes from both branches.
  • Delete the conflict markers <<<<<<<, =======, >>>>>>> and make changes you want in the final merge.
  • If you have more than one merge conflict in your file, scroll down to the next set of conflict markers and repeat steps four and five to resolve your merge conflict.
  • Once you have resolved all the conflicts in the file, click Mark as resolved.
  • If you have more than one file with a conflict, select the next file you want to edit on the left side of the page under “conflicting files” and repeat steps four to seven until you’ve resolved all of your pull request’s merge conflicts.
  • Once you’ve resolved your merge conflicts, click Commit merge. This merges the entire base branch into your head branch.
  • To merge your pull request, click Merge pull request.
  • A merge conflict is resolved using the command line.
  • Open Git Bash.
  • Navigate into the local Git repository that contains the merge conflict.
  • Generate a list of the files that the merge conflict affects. In this example, the file styleguide.md has a merge conflict.
Git Status
  • Open any text editor, such as Sublime Text or Atom, and navigate to the file that has merge conflicts.
  • To see the beginning of the merge conflict in your file, search the file for the conflict marker “<<<<<<<. ” Open it, and you’ll see the changes from the base branch after the line “<<<<<<< HEAD.”
  • Next, you’ll see “=======”, which divides your changes from the changes in the other branch, followed by “>>>>>>> BRANCH-NAME”.
  • Decide if you only want to keep your branch’s changes, the other branch’s changes, or make a brand new change, which may incorporate changes from both branches.
  • Delete the conflict markers “<<<<<<<“, “=======”, “>>>>>>>” and make the changes you want in the final merge.

        In this example, both the changes are incorporated into the final merge:

  • Add or stage your changes. 
  • Commit your changes with a comment.

Now you can merge the branches on the command line, or push your changes to your remote repository on GitHub and merge your changes in a pull request.

Explain the master-slave architecture of Jenkins.

  • Jenkins master pulls the code from the remote GitHub repository every time there is a code commit.
  • It distributes the workload to all the Jenkins slaves.
  • On request from the Jenkins master, the slaves carry out, builds, test, and produce test reports.

What is Jenkins file?

Jenkins file contains the definition of a Jenkins pipeline and is checked into the source control repository. It is a text file.

It allows code review and iteration on the pipeline.
It permits an audit trail for the pipeline.
There is a single source of truth for the pipeline, which can be viewed and edited.

DevOps Interview Question

Which of the following commands runs Jenkins from the command line?

  1. java –jar Jenkins. War
  2. java –war Jenkins.jar
  3. java –jar Jenkins.jar
  4. java –war Jenkins. War

The correct answer is A) java –jar Jenkins. War

What concepts are key aspects of the Jenkins pipeline?

  • Pipeline: User-defined model of a CD pipeline. The pipeline’s code defines the entire build process, which includes building, testing and delivering an application
  • Node: A machine that is part of the Jenkins environment and capable of executing a pipeline
  • Step: A single task that tells Jenkins what to do at a particular point in time
  • Stage: Defines a conceptually distinct subset of tasks performed through the entire pipeline (build, test, deploy stages)

Which file is used to define dependency in Maven?

  1. build.xml
  2. pom.xml
  3. dependency.xml
  4. Version.xml

The correct answer is B) pom.xml

Advance DevOps Interview Question

Explain the two types of pipeline in Jenkins, along with their syntax.

Jenkins provides two ways of developing a pipeline code: Scripted and Declarative.

A. Scripted Pipeline: It is based on Groovy script as their Domain Specific Language. One or more node blocks do the core work throughout the entire pipeline.

Syntax:

  1. Executes the pipeline or any of its stages on any available agent
  2. Defines the build stage
  3. Performs steps related to building stage
  4. Defines the test stage
  5. Performs steps related to the test stage
  6. Defines the deploy stage
  7. Performs steps related to the deploy stage

B. Declarative Pipeline: It provides a simple and friendly syntax to define a pipeline. Here, the pipeline block defines the work done throughout the pipeline.

Syntax:

  1. Executes the pipeline or any of its stages on any available agent
  2. Defines the build stage
  3. Performs steps related to building stage
  4. Defines the test stage
  5. Performs steps related to the test stage
  6. Defines the deploy stage
  7. Performs steps related to the deploy stage

How do you create a backup and copy files in Jenkins?

In order to create a backup file, periodically back up your JENKINS_HOME directory.

In order to create a backup of Jenkins setup, copy the JENKINS_HOME directory. You can also copy a job directory to clone or replicate a job or rename the directory.

How can you copy Jenkins from one server to another?

  • Move the job from one Jenkins installation to another by copying the corresponding job directory.
  • Create a copy of an existing job by making a clone of a job directory with a different name.
  • Rename an existing job by renaming a directory.

DevOps Interview Question

Name three security mechanisms Jenkins uses to authenticate users.

  • Jenkins uses an internal database to store user data and credentials.
  • Jenkins can use the Lightweight Directory Access Protocol (LDAP) server to authenticate users. 
  • Jenkins can be configured to employ the authentication mechanism that the deployed application server uses. 

How is a custom build of a core plugin deployed?

Steps to deploy a custom build of a core plugin:

  • Copy the .hpi file to $JENKINS_HOME/plugins
  • Remove the plugin’s development directory
  • Create an empty file called <plugin>.hpi.pinned
  • Restart Jenkins and use your custom build of a core plugin

How can you temporarily turn off Jenkins security if the administrative users have locked themselves out of the admin console?

  • When security is enabled, the Config file contains an XML element named use Security that will be set to true.
  • By changing this setting to false, security will be disabled the next time Jenkins is restarted.

Advance DevOps Interview Question

What are the ways in which a build can be scheduled/run in Jenkins?

  • By source code management commits.
  • After completion of other builds.
  • Scheduled to run at a specified time.
  • Manual build requests.

What are the commands that you can use to restart Jenkins manually?

Two ways to manually restart Jenkins: 

  1. (Jenkins_url)/restart            // Forces a restart without waiting for builds to complete                                
  2. (Jenkins_url)/safeRestart    // Allows all running builds to complete before it restarts   

What are the different Selenium components?

Selenium has the following components:

Selenium Integrated Development Environment (IDE)

It has a simple framework and should be used for prototyping.
It has an easy-to-install Firefox plug-in.
Selenium Remote Control (RC)

Testing framework for a developer to write code in any programming language (Java, PHP, Perl, C#, etc.).
Selenium WebDriver

Applies a better approach to automate browser activities.
It does not rely on JavaScript.
Selenium Grid

Works with Selenium RC and runs tests on different nodes using browsers.

DevOps Interview Question

What are the different exceptions in Selenium WebDriver?

Exceptions are events that occur during the execution of a program and disrupt the normal flow of a program’s instructions. Selenium has the following exceptions:

  • Timeout Exception – It is thrown when a command performing an operation does not complete in the stipulated time.
  • No Such Element Exception – It is thrown when an element with specific attributes is not found on the web page.
  • Element Not Visible Exception – It is thrown when an element is present in Document Object Model (DOM) but is not visible. Ex: Hidden Elements defined in HTML using type=“hidden”.
  • Session Not Found Exception – The WebDriver is performing the action immediately after quitting the browser.

Can Selenium test an application on an Android browser?

Selenium is capable of testing an application on an Android browser using an Android driver. You can use the Selendroid or Appium framework to test native apps or web apps in the Android browser. The following is a sample code:

What are the different test types that Selenium supports? 

Functional – This is a type of black-box testing in which the test cases are based on the software specification.

Regression – This testing helps to find new errors, regressions, etc. in different functional and non-functional areas of code after the alteration. 

Load Testing – This testing seeks to monitor the response of a device after putting a load on it. It is carried out to study the behavior of the system under certain conditions.

Advance DevOps Interview Question

How can you access the text of a web element?

Get command is used to retrieve the text of a specified web element. The command does not return any parameter but returns a string value.

Used for:

  • Verification of messages
  • Labels
  • Errors displayed on the web page

Syntax: 

String Text=driver.findElement(By.id(“text”)).getText();

How can you handle keyboard and mouse actions using Selenium?

You can handle keyboard and mouse events with the advanced user interaction API. The advanced user interactions API contains actions and action classes.

Method Description
clickAndHold()Clicks without releasing the current mouse location 
dragAndDrop()Performs click-and-hold at the location of the source element 
keyDown(modifier_key)Performs a modifier key press (ctrl, shift, Fn, etc.) 
keyUp(modifier_key)Performs a key release

Which of these options is not a Web Element method?

  1. get Text()
  2. size()
  3. get Tag Name()
  4. send Keys()

The correct answer is B) size()

DevOps Interview Question

When do we use find Element() and find Elements()?

A. findElement()

It finds the first element in the current web page that matches the specified locator value.

Syntax:

WebElement element=driver.findElements(By.xpath(“//div[@id=‘example’]//ul//li”));

B. findElements()

It finds all the elements in the current web page that matches the specified locator value.

Syntax:

List elementList=driver.findElements(By.xpath(“//div[@id=‘example’]//ul//li”));

What are driver.close() and driver.quit() in WebDriver?

These are two different methods used to close the browser session in Selenium WebDriver:

  • driver.close() – This is used to close the current browser window on which the focus is set. In this case, there is only one browser open.
  • driver.quit() – It closes all the browser windows and ends the WebDriver session using the driver. dispose method.

How can you submit a form using Selenium?

The following lines of code will let you submit a form using Selenium:

WebElement el = driver.findElement(By.id(“ElementID”));

el.submit();

Advance DevOps Interview Question

Why are SSL certificates used in Chef?

  • SSL certificates are used between the Chef server and the client to ensure that each node has access to the right data.
  • Every node has a private and public key pair. The public key is stored at the Chef server.
  • When an SSL certificate is sent to the server, it will contain the private key of the node.
  • The server compares this against the public key in order to identify the node and give the node access to the required data.
DevOps Part 2DevOps Part 3
Back to top