DevOps Interview Questions and Answers for Freshers and Experienced (51 Questions)

Quick answer: These 51 DevOps interview questions and answers cover what is asked most in DevOps engineer, cloud engineer, site reliability engineer and build and release interviews: DevOps basics, Git, CI/CD and Jenkins, Docker, Kubernetes, infrastructure as code and configuration management, and cloud, monitoring and Linux. Key answers include short code examples.

Read each answer, then close the page and explain it aloud in two or three sentences. That is exactly what interviewers check.

Contents

1. DevOps Basics Interview Questions

Q1. What is DevOps?

DevOps is a culture and set of practices that brings software development and IT operations together to deliver software faster and more reliably. It relies on automation, continuous integration and delivery, infrastructure as code, monitoring and shared responsibility.

Q2. What are the key benefits of DevOps?

Faster and more frequent releases, fewer failed deployments, quicker recovery from failures, better collaboration between teams, and more stable, scalable systems through automation.

Q3. What is the DevOps life cycle?

Plan, code, build, test, release, deploy, operate and monitor, running continuously in a loop with feedback from monitoring going back into planning.

Q4. What is the difference between DevOps and Agile?

Agile focuses on how development teams plan and build software in short iterations. DevOps extends this to testing, deployment and operations, so that working software reaches users quickly and reliably.

Q5. What is the difference between continuous integration, continuous delivery and continuous deployment?

Continuous integration merges code often and runs automated builds and tests on every change. Continuous delivery keeps the code always ready to release, with a manual approval for production. Continuous deployment releases every change that passes the tests to production automatically.

Q6. What are the popular DevOps tools?

Git and GitHub/GitLab for version control, Jenkins, GitHub Actions or GitLab CI for pipelines, Docker for containers, Kubernetes for orchestration, Terraform for infrastructure as code, Ansible for configuration, and Prometheus and Grafana for monitoring.

2. Version Control with Git Interview Questions

Q7. What is Git?

Git is a distributed version control system that tracks changes in code. Every developer has a full copy of the repository with its history, so work can continue offline and changes are merged later.

Q8. What is the difference between git merge and git rebase?

Merge joins two branches and keeps both histories, adding a merge commit. Rebase moves your commits on top of another branch, creating a straight, linear history. Do not rebase commits that others have already pulled.

Q9. What is the difference between git pull and git fetch?

git fetch downloads new commits from the remote without changing your working branch. git pull runs fetch and then merges (or rebases) those changes into your current branch.

Q10. How do you resolve a merge conflict?

Open the conflicting files, edit the sections between the <<<<<<<, ======= and >>>>>>> markers to keep the correct code, remove the markers, then stage and commit the result. Run the tests afterwards.

Q11. What is a branching strategy?

A branching strategy defines how teams use branches. Git Flow uses main, develop, feature, release and hotfix branches. Trunk-based development keeps short-lived branches merged into main several times a day, which suits CI/CD.

Q12. What do git stash, git reset and git revert do?

git stash saves uncommitted changes temporarily. git reset moves the branch pointer back and can discard commits (use carefully). git revert creates a new commit that undoes an earlier commit, which is safe on shared branches.

3. CI/CD and Jenkins Interview Questions

Q13. What is a CI/CD pipeline?

A pipeline is an automated sequence of stages that takes code from a commit to production: build, unit tests, code quality and security scans, packaging (for example a Docker image), deployment to staging, further tests and deployment to production.

Q14. What is Jenkins?

Jenkins is an open-source automation server used to build CI/CD pipelines. It has thousands of plugins and supports pipelines written as code in a Jenkinsfile.

Q15. What is a Jenkinsfile?

A Jenkinsfile defines a Jenkins pipeline as code and is stored in the repository. It describes the stages and steps, so the pipeline is version-controlled and reviewed like application code.

pipeline {
  agent any
  stages {
    stage('Build') { steps { sh 'mvn -B package' } }
    stage('Test')  { steps { sh 'mvn test' } }
    stage('Docker') { steps { sh 'docker build -t myapp:${BUILD_NUMBER} .' } }
  }
}

Q16. What is the difference between declarative and scripted Jenkins pipelines?

Declarative pipelines use a simpler, structured syntax with a fixed format and are easier to read. Scripted pipelines use Groovy code directly and give more flexibility for complex logic.

Q17. What are GitHub Actions?

GitHub Actions is a CI/CD service built into GitHub. Workflows are YAML files in .github/workflows that run jobs on events such as push or pull request.

Q18. What are blue-green and canary deployments?

In blue-green deployment, the new version (green) runs alongside the old (blue) and traffic switches over at once, with instant rollback. In a canary deployment, the new version first receives a small share of traffic and is rolled out gradually if metrics stay healthy.

Q19. How do you roll back a failed deployment?

Redeploy the previous known-good version or image, switch traffic back in blue-green setups, or use kubectl rollout undo in Kubernetes. Database changes need backward-compatible migrations so that rollback is safe.

Preparing for a DevOps interview? We run live one-to-one classes and mock interviews in DevOps, cloud and Linux, arranged around your free time. Chat on WhatsApp.

4. Docker and Containers Interview Questions

Q20. What is Docker?

Docker packages an application with its dependencies into a container image that runs the same way on any machine. Containers share the host operating system kernel, so they are lighter and start faster than virtual machines.

Q21. What is the difference between a container and a virtual machine?

A virtual machine includes a full guest operating system on a hypervisor, so it is heavier and slower to start. A container shares the host kernel and isolates only the application and its dependencies, so it uses far fewer resources.

Q22. What is the difference between a Docker image and a container?

An image is a read-only template with the application and its dependencies. A container is a running instance of an image with its own writable layer.

Q23. What is a Dockerfile?

A Dockerfile is a text file of instructions to build an image: the base image, files to copy, commands to run, ports to expose and the start command.

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["python", "app.py"]

Q24. What is the difference between CMD and ENTRYPOINT?

ENTRYPOINT sets the main command that always runs. CMD provides default arguments or a default command that can be overridden when running the container. They are often used together.

Q25. What is the difference between COPY and ADD?

COPY copies files from the build context into the image. ADD can also extract local tar files and download URLs. Prefer COPY unless you need those extra features.

Q26. What is Docker Compose?

Docker Compose defines and runs multi-container applications, such as a web app plus a database, in one YAML file and starts them all with docker compose up.

Q27. How do you reduce Docker image size?

Use small base images such as alpine or slim, use multi-stage builds to leave build tools behind, combine RUN commands, clean package caches, and add a .dockerignore file.

Q28. What are Docker volumes?

Volumes store data outside the container's writable layer, so data such as a database survives when the container is removed or replaced.

5. Kubernetes Interview Questions

Q29. What is Kubernetes?

Kubernetes is an open-source platform that automates deploying, scaling and managing containers across a cluster of machines. It handles scheduling, self-healing, load balancing and rolling updates.

Q30. What is a Pod?

A Pod is the smallest deployable unit in Kubernetes. It contains one or more containers that share the same network address and storage, and it is usually created through a Deployment.

Q31. What are the main components of a Kubernetes cluster?

The control plane has the API server, etcd (the cluster database), the scheduler and the controller manager. Each worker node runs the kubelet, kube-proxy and a container runtime.

Q32. What is the difference between a Deployment, a ReplicaSet and a StatefulSet?

A ReplicaSet keeps a set number of identical Pods running. A Deployment manages ReplicaSets and adds rolling updates and rollback. A StatefulSet gives Pods stable names and storage, which suits databases.

Q33. What is a Kubernetes Service?

A Service gives a stable network address to a changing set of Pods. ClusterIP exposes it inside the cluster, NodePort on each node's port, and LoadBalancer through a cloud load balancer. An Ingress routes HTTP traffic to Services by host or path.

Q34. What are ConfigMaps and Secrets?

ConfigMaps store non-sensitive configuration such as URLs and feature flags. Secrets store sensitive data such as passwords and API keys. Both are injected into Pods as environment variables or files, so configuration stays out of the image.

Q35. How does Kubernetes scale applications?

The Horizontal Pod Autoscaler adds or removes Pods based on CPU, memory or custom metrics. The Cluster Autoscaler adds or removes nodes when Pods cannot be scheduled.

Q36. What are liveness and readiness probes?

A liveness probe checks whether a container is still working; if it fails, Kubernetes restarts the container. A readiness probe checks whether it is ready to receive traffic; until it passes, the Pod is kept out of the Service.

Q37. Which kubectl commands do you use most?

kubectl get pods, describe pod, logs, apply -f, exec -it, scale and rollout status/undo.

kubectl get pods -n prod
kubectl describe pod web-7d9f
kubectl logs -f web-7d9f
kubectl apply -f deployment.yaml
kubectl rollout undo deployment/web

6. Infrastructure as Code and Configuration Management Interview Questions

Q38. What is Infrastructure as Code (IaC)?

IaC manages servers, networks and other infrastructure through code files instead of manual setup. The code is version-controlled, reviewed and reused, so environments are consistent and can be recreated quickly.

Q39. What is Terraform?

Terraform is an IaC tool that uses declarative HCL files to create and manage infrastructure on AWS, Azure, Google Cloud and many other providers. The main workflow is terraform init, plan and apply.

resource "aws_instance" "web" {
  ami           = "ami-0abcdef1234567890"
  instance_type = "t3.micro"
  tags = { Name = "web-server" }
}

Q40. What is Terraform state?

The state file records the real resources Terraform manages and maps them to the configuration. In teams it is stored remotely, for example in an S3 bucket with locking, so two people do not change infrastructure at the same time.

Q41. What is Ansible?

Ansible is an agentless configuration management tool that connects over SSH and runs YAML playbooks to install software, configure servers and deploy applications.

Q42. What is the difference between Terraform and Ansible?

Terraform mainly provisions infrastructure such as servers, networks and databases. Ansible mainly configures software on existing servers. They are often used together.

Q43. What is idempotency?

An idempotent operation gives the same result whether it runs once or many times. Terraform and Ansible are designed to be idempotent, so re-running them does not create duplicates.

7. Cloud, Monitoring and Linux Interview Questions

Q44. What is the role of cloud computing in DevOps?

Cloud platforms such as AWS, Azure and Google Cloud provide on-demand servers, managed databases, Kubernetes services and CI/CD tools through APIs, which makes automation and scaling much easier.

Q45. What are the three cloud service models?

IaaS provides virtual machines, storage and networks (for example AWS EC2). PaaS provides a platform to run applications without managing servers. SaaS provides ready-to-use software such as email.

Q46. What is monitoring and observability?

Monitoring tracks known health metrics and raises alerts. Observability lets you understand why a system behaves as it does, using metrics, logs and traces together.

Q47. What are Prometheus and Grafana?

Prometheus collects time-series metrics from applications and servers and evaluates alert rules. Grafana builds dashboards from Prometheus and other data sources.

Q48. What are SLI, SLO and SLA?

An SLI is a measured indicator, such as the percentage of successful requests. An SLO is the target for it, such as 99.9% per month. An SLA is the agreement with customers, often with penalties if the target is missed.

Q49. Which Linux commands are important for DevOps?

ls, cd, cat, grep, find, chmod, chown, ps, top, df, du, free, netstat or ss, curl, systemctl, journalctl, tail -f and ssh are used daily for troubleshooting servers.

Q50. How would you troubleshoot a slow application in production?

Check monitoring dashboards for CPU, memory, disk and network, read application and server logs, look for recent deployments, check database query times and external dependencies, and use tracing to find the slowest step.

Q51. What is DevSecOps?

DevSecOps adds security to every stage of the pipeline: code scanning, dependency vulnerability checks, container image scanning, secrets management and policy checks, instead of testing security only at the end.

How to Prepare for a DevOps Interview

  1. Get hands-on: interviewers ask what you have actually built, so run Docker and Kubernetes yourself.
  2. Know the pipeline end to end: from a Git commit to a monitored production deployment.
  3. Be strong in Linux: troubleshooting questions are common in every DevOps round.
  4. Learn one cloud well: AWS is the most requested.
  5. Prepare scenarios: failed deployments, slow applications and rollbacks.

Next steps: strengthen scripting with Python interview questions, learn security basics from cyber security interview questions, and choose a project from our final year projects for computer science.

Want a mentor for your preparation? We teach DevOps, cloud and Linux through live online classes arranged around your free time, with mock interviews before your placement. Message us on WhatsApp or email engineersrworld@gmail.com.

More interview preparation: see all interview questions, including Python, SQL, SQL query, Java, JavaScript, React, C++, .NET, Spring Boot, Node.js, DSA, OOPs, DBMS, operating system, networking, machine learning, data science, AI, Excel, Power BI, DevOps, manual testing, Selenium, cyber security and HR.

Frequently Asked Questions

Which DevOps topics are asked most for freshers?

Git, Linux commands, CI/CD concepts, Docker, basic Kubernetes objects, and the difference between DevOps and traditional development appear in almost every fresher interview.

Do I need coding for DevOps?

Yes, some. You should be comfortable with shell scripting and basic Python, and able to read YAML, Dockerfiles and Terraform code.

Which cloud should I learn for DevOps?

AWS has the largest job market, followed by Azure and Google Cloud. The concepts transfer easily, so start with one and learn the others later.

How should I prepare for a DevOps interview?

Revise the concepts on this page and build a small end-to-end project: a web app in Git, a Jenkins or GitHub Actions pipeline, a Docker image, and deployment to Kubernetes or a cloud server with monitoring.

Scroll to Top