DevOps - Interview Questions

DevOps Basics


What is DevOps?

FAQ

DevOps, which is a combined term for Development (Dev) and IT Operations (Ops), is a combination of teams (Development, QA, Operations), practices, processes, and tools - that enables an organization to deliver it's applications and products at a higher velocity, with continuous delivery, and better quality.


What are the different phases of a DevOps life cycle?

FAQ

DevOps life cycle typically consists of five phases.

1. Continuous Development

2. Continuous Integration

3. Continuous Testing

4. Continuous Deployment

5. Continuous Monitoring


What are some best practices of DevOps?

FAQ

Following are some best practices of DevOps.

1. Continuous Integration

2. Continuous Delivery

3. Usage of Micro-services

4. Infrastructure as Code

5. Monitoring and Logging

6. Communication and Collaboration


What are some benefits of DevOps?

FAQ

Following are some benefits of DevOps.

1. Higher Speed

2. Rapid Delivery

3. More Reliability

4. Faster Innovation

5. Bigger Scale

6. Improved Collaboration

7. Better Security


What are some common tools used across the different phases of DevOps?

FAQ

Following are some common tools of DevOps.

1. Planning and Collaboration - Confluence, Jira, VersionOne

2. Code Repository - Git, Subversion, Bitbucket

3. Build - Maven, Gradle, Sbt

4. Test - JMeter, Selenium, Cucumber

5. Integration and Release - Jenkins, Spinnaker, Bamboo, Circleci, Travis CI

6. Deploy - JFrog, Sonatype, nuget, docker, AWS, Azure, Heroku

7. Operate - Kubernetes, Ansible, Chef

8. Monitor - AppDynamics, Splunk, Datadog, New Relic, Dynatrace


What is Continuous Integration - CI?

FAQ

Continuous Integration - CI - is a software development process in which developers continuously commit code to a shared repository such as Git, in small increments and in frequent intervals, usually at-least once a day. The code is automatically build and tested before it is committed to the shared repository.


What is Continuous Delivery - CD?

FAQ

Continuous Delivery - CD - is a software development process in which code changes are automatically prepared for release to production.

Continuous Delivery expands upon Continuous Integration and ensures that you will always have a deployment-ready build artifact that has gone through and passed the various testing processes.

Continuous Delivery requires a manual process to deploy to production.


GIT


What is Git?

FAQ

Git is an open source distributed version control system, and is the most widely used version control system used today. Git was originally developed by Linus Torvalds in 2005 to version control the Linus OS kernel. Today Git is widely used as a source control system for commercial projects as well as for open source projects.


What is the key features of Git that makes it more efficient compared to other version control systems such as SVN and CVS?

FAQ

Distributed: Git is a distributed version control system. Git has a central server which maintains the project file and its history, called as a repository. Each user of Git has a complete and independent copy of this repository on his own local machine. Hence, Git users can continue working with Git and refer to history even if the central repository is unavailable.

Like Git, alternative source control systems such as SVN and CVS also have a central server which maintains the project files and its history. But unlike Git, users of these version control system do not have a local copy of the project files and its history. Hence these users are dependent on the central system, and cannot continue to work with the version control system if the central server becomes unavailable for any reason.

Snapshot-based: Git is a snapshot-based version control system. Every time a user commits the project, Git takes a snapshot of the project files and changes at that moment and stores a reference to that snapshot. If a file has not changed, Git links to the previous file instead of storing the file again.

Alternative version control systems such as SVN and CVS are delta-based version control systems. These systems store the project files and changes made to each file over time.

Speed: Git is built for speed. Nearly all operations in Git use local files and resources, and do not require information from the central server or any other computer. This eliminates network latency and dependency on the central server resulting in fast operations compared to the alternative source control systems.

Alternative source control systems such as SVN and CVS depend on information on the central server for all operations. Hence the operations are comparatively slower compared to Git, and most of these operations will not work of the central server is not available.

Integrity: Every file in Git is checksummed using a SHA-1 hash before it is stored, and is referred to with that checksum. This makes it impossible to lose or corrupt the files without Git detecting it.


What are the three main sections or regions of a Git project?

FAQ

A Git projects consists of the following three main regions.

Git directory - Git stores the meta-data and object database in the Git directory. When a user clones a repository the Git directory is copied to the local machine.

Working directory - Working directory is the checked out version of the Git project. The project files are retrieved from the compressed database of the Git directory and put on disk for users to modify.

Index or staging area - The staging area, also called as Index, is a file in the Git directory that stores information on what goes into the next commit.


How do you create a new repository and add all contents in the current directory to this repository?

FAQ

You create a new repository using the git init command. You can then add the contents of the current directory to this repository using the git add and git commit commands

$ git init
$ git add .
$ git commit -am 'Initial Commit'

How do you create a new branch?

FAQ

You create a new branch using the git checkout command with the -b option.

$ git checkout -b NewBranch


Lets say that you made a commit to a branch but later realized that you have made a mistake and should not have made that commit. How do you discard this last commit made to the branch?

FAQ

You discard the last commit made by using the git reset command.

$ git reset HEAD~

How do you update your local branch with updates made to the original repository?

FAQ

You can update your local branch with updates made to the original repository using the git pull command.

$ git pull

How do you update the original repository with the changes made to your local branch?

FAQ

You can update the original repository with the changes made to your local branch using the git push command.

$ git push

What does the git stash command perform?

FAQ

Git Stash command saves the current index and working tree, and resets the working tree to mat the HEAD commit. The saved state can be restored back using git stach pop or git stach apply commands.

$ git stash

What does the git stash command perform?

FAQ

Git Stash command saves the current index and working tree, and resets the working tree to mat the HEAD commit. The saved state can be restored back using git stach pop or git stach apply commands.

$ git stash

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

FAQ

You can find the list of files that were change in a particular commit by using the diff-tree command.

$ git diff-tree -r {hash}


Jenkins


What is Jenkins, and where does it fit in the DevOps landscape?


Jenkins is an automation tool used for building, deploying and automating any project.

Jenkins is architected for plugin support, and can integrate with practically every tool in the CICD tool chain.

Jenkins, along with it's integration abilities with other CICD tools provides unlimited CICD capabilities.


What language is Jenkins developed, what is the installation process?


Jenkins was developed using Java programming language.

Jenkins is typically run as a standalone application using the built-in Jetty Servlet/Application container. Jenkins can also be run as a servlet in other application servers such as Apache Tomcat.

Jenkins can be run on operating systems - macOS, Windows,and Linux - on containers such as Docker containers - and on cloud services such as AWS and Azure.


What are the different scope for credentials in Jenkins?


Credentials in Jenkins can be set up at two scopes.

Global scope: - Applies to Jenkins, nodes, items, and all descendant items. This scope is typically used from pipeline projects.

System scope Applies to Jenkins and nodes only. This scope is typically used for system admin functions such as email authentications, agent connections etc.


What are the different kinds of credentials that can be setup in Jenkins?


Credentials in Jenkins can be of different kinds - Username with password, SSH with private key, Secret file, Secret text, PKCD certificate etc.


What is Jenkins Controller?


Jenkins controller is the central process which stores configurations, loads plugins, renders user interfaces, manages agents, and executes pipeline tasks either directly or more typically via agents.



What are Jenkins Agents?


Jenkins agents are individual nodes - typically a machine, or container - which connects to a Jenkins controller and executes pipeline tasks when directed by the controller.


What is Jenkins pipeline? What are the different options of creating a Jenkins pipeline?


Jenkins pipeline is suite of plugins that implements and integrates continuous delivery pipelines into Jenkins.

There are three ways to create a Jenkins pipeline

Blue Ocean - A UI tool to visually create pipelines

Classic UI - Jenkins classic UI through which you can create a basic pipeline.

SCM - Write a JenkinsFile manually and commit to your projects code repository which will be picked up and processed by Jenkins.

For enterprise projects, and in general as a best practice it is better to create a JenkinsFile and check the file into the source control repository.


JFrog


What DevOps capabilities does JFrog platform provide?

FAQ

JFrog platform provides an end-to-end solution to manage and control the flow of your code binaries from build to production.

JFrog platform consists of five products.

JFrog Artifactory - Provides capabilities to manage binaries and artifacts through the application development and delivery process.

JFrog Xray - Provides capabilities to pro-actively identify vulnerabilities in the binaries and artifacts managed by JFrog repository.

JFrog Mission Control - Provides capabilities to manage multiple JFrog platform deployments through a single administrative dashboard.

JFrog Distribution - Provides capabilities for managing release bundles and their distribution process.

JFrog Pipelines - Provides capabilities for end-to-end automation (CI/CD), workflow and tool orchestration.


What is JFrog Artifactory?

FAQ

JFrog Artifactory is a centralized universal repository that can be used to store different kinds of build binaries, and used across the application development and delivery process - enabling faster delivery cycles.


What are the different kinds of JFrog Repositories?

FAQ

There are four kinds of JFrog repositories.

1. Local repositories - Local repositories contain artifacts that you upload and manage locally.

2. Remote repositories - Remote repositories contain cached artifacts from public cloud repositories like DockerHub, MVNRepository, NPM repository etc.

3. Virtual repositories - Virtual repository aggregates local and remote repositories into one logical repository.

4. Distribution repositories - Distribution repositories contain artifacts that can be easily moved from Artifactory to bintray, for distribution to end users.


What features does JFrog Repository provide for Automation?

FAQ

JFrog Artifactory provides three key features to support Automation.

1. Rest APIs - Rest APIs that can be used for various Artifactory tasks such as build automations, artifact deployments, and integration with CI/CD automation tools.

2. JFrog CLI - A command line interface to automate and optimize Artifactory tasks. JFrog CLI internally used the Rest APIs to communicate with Artifactory.

3. Plug-in Framework - Plug-is that provide hooks into the Artifactory and automate tasks such as scheduling tasks, managing downloads and uploads, responding to new builds and artifacts etc.

Built-in Integrations - Integration to CI/CD and build tools such as Jenkins, Bamboo etc.


Docker


What is Docker?

FAQ

Docker is a platform for developing, shipping, and running applications - which significantly reduces the time between developing the application and running it in production.

Docker provides the capability to package your application code and run it in an isolated environment called the container. You can package and run the container in your local machine, share or ship the container, and deploy and run the same container in lower and production environments. This streamlining of development life-cycle makes containers ideal for continuous integration and continuous delivery (CI/CD) workflows.

Docker containers are light weight, fast, and multiple containers can simultaneously run on the same host. You can easily bring up new containers or bring down running containers - making it easy to scale up or down. This makes Docker containers ideal for cloud base deployments.


What are the key architectural components of Docker?

FAQ

Docker uses a client-server architecture. Following are the key architectural components of Docker.

Docker daemon - Docker daemon does the heavy lifting of building, running, and distributing Docker containers. Docker daemon listens to Docker client API requests and manages Docker objects such as images and containers.

Docker Client - Docker users interact with Docker via Docker client. Docker client sends user docker commands such as 'docker run' or 'docker push' to the Docker daemon which executes the commands.

Docker Registries - Docker registry stores Docker images, which are templates for creating Docker containers. Docker provides a public registry called Docker Hub that anyone can use. Docker looks for an image on Docker Hub by default.


What is the difference between Docker images and Docker Containers?

FAQ

Docker image is a template with instructions for creating a Docker container. An image can be based on another image, with added customizations.

Docker container is a runnable instance of an image that can be created, started, stopped or deleted using the Docker API or Docker CLI.


What is the difference between Docker Containers and Virtual Machines?

FAQ

Docker is based on container-based technology where the container contains all the dependencies and libraries used to run an application. Docker containers share the Host OS Kernel and multiple containers run on a single OS. Since Docker containers share the Host OS, they are light-weight, small in size, have fast boot-up times, and are easily portable.

Virtual Machines (VMs) are based on virtualization technology which uses the user space and Host OS Kernel. Unlike Docker containers VMs do not share the OS kernel and each VM requires a complete host kernel. Since Host OS and dependencies have to be included with the VM, they are heavy-weight, larger in size, have slower boot-up times, and difficult to share.


Describe the background process when you execute the docker run command, say 'docker container run --publish 80:80 nginx'?

FAQ

When you run the 'docker container --publish 80:80 nginx' command, the following steps are processed by docker

1. Check for the nginx image file in the local image cache.

2. If it does not find in the local image cache then it looks at the remote image repository, which is by default docker hub

3. Downloads the latest version of nginx image from docker hub.

4. Create new container based on the downloaded nginx image.

5. Assigns a virtual IP for the container in a private network inside docker engine.

6. Since we specified --publish option with ports 80:80, opens port 80 on host and forwards to port 80 on container.

7. Starts the container by executing the CMD in the image file.



How do you see the list of containers in a docker engine?

FAQ

You can see the list of running containers by using the ls command - docker container ls.

You can see the list of all containers (running and non-running) by using the ls command with the -a option - docker container ls -a.

> docker container ls
> docker container ls -a

How do you access a running container via shell, say with bash?

FAQ

You can get access to the shell command of a running container using the exec command. For example, to access the bash shell of a container that is running nginx you can use the command - docker container exec -it nginx bash

> docker container exec -it nginx bash

How do you access a running container via shell, say with bash?

FAQ

You can get access to the shell command of a running container using the exec command. For example, to access the bash shell of a container that is running nginx you can use the command - docker container exec -it nginx bash

> docker container exec -it nginx bash

How do you create a new virtual network and run a docker container in that network?

FAQ

You can create a new virtual network in docker using the create command - docker network create my_new_network

You can then run a container in the newly created virtual network by using the run command with the --network option - docker container run nginx --network my_new_network

> docker network create my_new_network
> docker container run nginx --network my_new_network

What is the difference between docker image id and image tag?

FAQ

Docker image id is a unique id given to an image. Image Ids are unique and are not shared across different images.

Docker image tag is a label or nickname given to an Image. Image tags can be used for versioning images. Same tag can be used across different images.



What is a Dockerfile?

FAQ

Dockerfile is a text file containing a sequence of instructions or commands that are needed to build a Docker image.

Dockerfile must adhere to a specific format and set of instructions specified by Docker.

Each Dockerfile instruction is a considered as a layer. The layers are stacked and each layer is a delta of the changes from the previous layer.


What storage options does Docker provide to persist and share data across containers?

FAQ

By default any file created inside a container is stored on a writable layer within the container. That means the data is lost when the container is removed, and also the data cannot be shared with other processes.

Docker provides two storage options to store files in the host machine, so that these files can be shared across containers and processes. Theses two storage options are Volumes and Bind mounts


What is the difference between Data Volumes and Bind mount?

FAQ

Volumes - Volumes are stored in part of the file system that is managed by Docker.

Bind mounts - Bind mounts can be stored anywhere in the host file system, and can by modified by any process including non-docker processes.


What is Docker Compose?

FAQ

Docker Compose is a tool where you can define and share multi-container applications, by defining the application stack and services in a YAML file.

With a single Docker Compose command you can spin up the complete application stack, or tear it down.


Docker Swarm


What is Docker Swarm?

FAQ

Docker Swarm is an orchestration tool provided with Docker. With Docker Swarm you can manage, scale, and maintain containerized applications.

A Docker swarm contains multiple Docker hosts which run in swarm mode and can act as both managers as well as workers. Managers manage swarm memberships and workers run swarm services.


What are nodes in Swarm? What are the different kinds of nodes?

FAQ

Nodes in Swarm are Docker instances running in swarm mode. There are two kinds of nodes - Manager nodes and Worker nodes.

Manager nodes are responsible for orchestration and cluster management functions, which helps maintain the desired state of the swarm. Manager nodes also dispatch units of work or tasks to worker nodes.

Worker nodes execute tasks that are dispatched to them by Manager nodes, and update the status back to the Manager node.


How do you specify the number of containers to run for a service using Docker Swarm?

FAQ

You can use the Docker Swarm command docker service update with the parameter --replicas to specify the number of containers to run for a service.

For example below command creates 3 containers for the service myService

> docker service update myService --replicas 3

Kubernetes


What is Kubernetes?

Key Concept

Kubernetes, also known as K8s, is an open-source container orchestration and management platform.

Kubernetes groups containers into pods, which are the basic operational units of Kubernetes. Kubernetes scales, manages, and orchestrates these pods across a cluster of virtual machines, or nodes.

Kubernetes has in-built capabilities to automatically manage load balancing, scaling, service discovery, resource allocation, health checks, and self-healing of containers.


What are the key features provided by Kubernetes?

Key Concept

Following are some key features provided by Kubernetes.

Service Discovery and Load Balancing - Kubernetes assigns unique IP addresses for each pod, and a unique DNS name for a set of pods. Kubernetes automatically load balances across these pods.

Self-healing - Kubernetes automatically restarts containers when they fail, replaces containers when a node goes down, and brings down containers when health check fails. Kubernetes does not expose a container to client requests, until it is ready to serve.

Auto scaling - Kubernetes automatically scales an application up or down based on CPU usage. You can also manually scale up or down by using command line interface or UI.

Configuration management - Kubernetes has the capability to deploy and update application configurations, without the need to rebuild your application.

Automated roll outs and rollbacks - Kubernetes progressively rolls out application changes, while monitoring application health checks. If the health checks fail Kubernetes will automatically rollback the changes. This ensures that all instances of the application do not come down at the same time.

Storage binding Kubernetes has the capability to automatically mount the storage system define by you - local storage, storage provided by cloud providers, or network storage systems such as NFS.


What are the key components in a Kubernetes system?

Key Concept

Kubernetes components can be grouped into Control plane components and Node components.

Control plane components make global decisions on the cluster, and detecting and responding to cluster events.

Node components run on every node and provides Kubernetes runtime environment.

Control plane components

kube-apiserver - kube-apiserver exposes the Kubernetes APIs to other Kubernetes components

kube-controller-manager - kube-controller-manager manages and runs controller processes. There are different kinds of controllers such as - Node controllers which track and respond when nodes go down, job controller which creates pods to run one-off tasks, Endpoint controller which joins services and pods, etc.

cloud-controller-manager - cloud-controller-manager links the Kubernetes cluster to the cloud providers APIs. cloud-controller-manager manages and runs controllers specific to the cloud provider. Example of these controllers are Node controllers which manage nodes on the cloud, Route controller which sets up routes in the cloud infrastructure, Service controller which creates, updates, and deletes load balancers provided by the cloud provider.

kube-scheduler - Kube-scheduler tracks newly created pods with no assigned node, and assigns a node for the pod to run on.

etcd - etcd is a highly-available key-value store which Kubernetes uses as a backing store for all cluster data.

Node components

kubelet - kubelet is an agent that runs on every Kubernetes pod and ensures that containers are running and healthy in the pod.

kube-proxy - kube-proxy is network proxy that runs on each node in a Kubernetes cluster, which maintains network rules on nodes which allow network communication to the pods from either inside or outside of the cluster.

Container runtime - Container runtime is the software that runs containers. Container runtimes are specific to the container used such as Docker, containerd, etc.


What are Kubernetes objects?

Key Concept

Kubernetes objects are persistent entities in the Kubernetes system which you create to represent the 'desired state' of the cluster.

Once an object is created, Kubernetes control plane actively and continually manages the object's actual state to match its desired state.

Kubernetes objects are created, updated, or deleted by using Kubernetes API - either directly by calling the RESTful APIs or indirectly via kubectl command-line interface.

If you are directly using the Kubernetes APIS, the object spec must be provided in JSON format. If you are using kubectl command-line interface the object spec is typically provided in .yaml format. kubectl internally converts the .yaml format to JSON format before calling the Kubernetes APIs.


What are some examples of Kubernetes objects?

Key Concept

Following are some examples of Kubernetes objects.

Pod - Represents the configuration of a pod. Pod contains a collection of containers that run on a node.

ReplicaSet - Represents the configuration of a ReplicaSet. ReplicaSet Ensures that a defined number of pod instances are running at any given time.

Deployment - Represents the configuration of a Deployment. Deployment enables declarative updates for pods and ReplicaSets.

Job - Represents the configuration of a Job.

Service - Represents the configuration of Service. Configuration includes port and IP definitions, which determine which pods the requests will be routed to.

Ingress - Represents the configuration of Ingress. Ingress contains a collection of rules which allow inbound requests to reach backend endpoints.

ConfigMap - Represents the configuration of a ConfigMap. ConfigMap holds configuration data that pods consume.

Volume - Represents the configuration of Volume. Volume represents a named volume in a pod that can be accessed by any container in the pod.



 
Subscribe to our Newsletter

 
 
RECOMMENDED RESOURCES
Behaviorial Interview
Top resource to prepare for behaviorial and situational interview questions.

STAR Interview Example