DevOps Interview Questions
1. What is DevOps?
DevOps is a culture and set of practices that bring together software development and IT operations to shorten the system development life cycle and deliver high-quality software continuously.
2. What are the key benefits of DevOps?
Faster delivery, improved collaboration, reduced failures, quicker recovery, and better resource utilization.
3. What are the key phases of DevOps lifecycle?
Plan, Code, Build, Test, Release, Deploy, Operate, and Monitor.
4. What tools are commonly used in DevOps?
Git, Jenkins, Docker, Kubernetes, Terraform, Ansible, Prometheus, Grafana, AWS, and ELK Stack.
5. What is Continuous Integration (CI)?
CI is the practice of integrating code changes frequently into a shared repository, followed by automated builds and tests.
6. What is Continuous Deployment (CD)?
CD automates the release process, deploying code changes to production automatically after successful testing.
7. What is Infrastructure as Code (IaC)?
IaC is the process of managing infrastructure using code through tools like Terraform, CloudFormation, or Ansible.
8. What is the difference between Continuous Delivery and Continuous Deployment?
Continuous Delivery prepares every code change for release, while Continuous Deployment automatically deploys every change to production.
9. How do you ensure zero downtime deployment?
Use rolling updates, blue-green deployments, or canary releases to deploy updates gradually.
10. What is configuration drift?
Configuration drift occurs when infrastructure or application configurations deviate from the desired state over time.
11. Scenario: Your Jenkins build fails after a commit. What do you do?
Check the Jenkins console output, identify the failing stage, verify dependencies, and review recent code commits for syntax or build issues.
12. Scenario: Docker image size is too large. How can you reduce it?
Use smaller base images (like alpine), clean up temporary files, and combine RUN instructions to reduce image layers.
13. Scenario: Application running in Kubernetes is crashing repeatedly. How do you debug?
Run 'kubectl logs <pod>' and 'kubectl describe pod <pod>' to check logs, events, and resource limits. Verify container health checks.
14. What is the purpose of Docker Compose?
Docker Compose is used to define and manage multi-container applications using a YAML file.
15. What is the difference between a Docker image and a container?
An image is a static snapshot of an application and its dependencies, while a container is a running instance of that image.
16. How do you monitor a CI/CD pipeline?
Use Jenkins Blue Ocean, Prometheus + Grafana, or custom scripts to monitor job success/failure and duration metrics.
17. What are rolling updates in Kubernetes?
Rolling updates allow gradual updates of pods without downtime by replacing old pods with new ones step-by-step.
18. Scenario: Terraform plan shows resource deletion. What could be the cause?
Drift or manual changes in the infrastructure. Always review plans before applying and use 'terraform import' if resources were created manually.
19. How do you handle secrets in DevOps pipelines?
Use secret management tools like AWS Secrets Manager, HashiCorp Vault, or Jenkins credentials binding.
20. What is blue-green deployment?
It involves maintaining two environments — one active (blue) and one idle (green). The new version is deployed to green, tested, and then switched over.
21. Scenario: Your application deployment succeeded, but users report errors. What’s your first step?
Check application logs, rollback to the previous version if necessary, and analyze configuration or environment changes.
22. What is a Jenkins pipeline?
A Jenkins pipeline defines a series of automated steps (build, test, deploy) written in Groovy syntax to manage CI/CD workflows.
23. Scenario: CPU usage in a container is consistently high. What do you do?
Check application code for leaks, verify Kubernetes resource limits, and analyze metrics in Prometheus or Grafana.
24. What is container orchestration?
Container orchestration automates deployment, scaling, and management of containers across multiple hosts — typically using Kubernetes or Docker Swarm.
25. How do you handle rollback in CI/CD?
Maintain previous stable artifacts or use Git tags to redeploy the last working version automatically.
26. What is Ansible used for?
Ansible is used for configuration management, application deployment, and task automation using YAML playbooks.
27. Scenario: Jenkins job fails due to missing dependencies. How do you fix it?
Update the build node environment, use Docker agents for consistent builds, or include dependency installation steps in the pipeline.
28. What is the difference between Terraform and Ansible?
Terraform is declarative and used for provisioning infrastructure, while Ansible is procedural and used for configuration management.
29. Scenario: Deployment to production failed midway. What’s your immediate action?
Rollback using the last successful deployment artifact, investigate logs, and disable auto-deploy until the issue is resolved.
30. What are Prometheus and Grafana used for?
Prometheus collects time-series metrics, while Grafana visualizes them through dashboards and alerts.
31. Scenario: You see a sudden spike in 500 errors after a new release. What’s your approach?
Check the application logs, rollback if necessary, validate environment variables, and analyze changes introduced in the release.
32. What are some best practices for Dockerfile writing?
Use minimal base images, define explicit versions, avoid unnecessary layers, and use .dockerignore to reduce context size.
33. What is GitOps?
GitOps uses Git repositories as the single source of truth for declarative infrastructure and applications, automatically syncing changes to environments.
34. What is the role of a reverse proxy in DevOps architectures?
Reverse proxies like Nginx or HAProxy manage traffic routing, SSL termination, caching, and load balancing.
35. Scenario: Your Terraform state file is corrupted. How do you recover?
Use a remote backend (like S3 + DynamoDB), restore from a previous state version, or import resources again using 'terraform import'.
36. What is canary deployment?
Canary deployment releases updates to a small subset of users before full rollout, allowing safe testing in production.
37. Scenario: A service is failing health checks in Kubernetes. What do you check?
Review liveness and readiness probes, container logs, and verify service-to-pod connectivity.
38. What is version control and why is it important?
Version control (like Git) tracks changes to code, supports collaboration, and enables rollback to previous states.
39. What are Jenkins agents?
Agents are worker nodes that execute Jenkins jobs, allowing parallel builds and workload distribution.
40. Scenario: Your CI/CD pipeline runs slowly. How can you optimize it?
Enable parallel stages, use caching, run lightweight containers for builds, and archive only necessary artifacts.
41. What is immutable infrastructure?
Immutable infrastructure means servers or containers are replaced rather than modified when updates are applied.
42. What is the difference between monitoring and observability?
Monitoring tracks known metrics; observability provides deeper insight into system behavior using logs, traces, and metrics together.
43. Scenario: You deployed an app via Terraform but can’t SSH into the EC2 instance. What could be wrong?
Check the security group inbound rules, key pair association, and ensure correct subnet routing.
44. What is the role of CI/CD in DevOps?
It automates code integration, testing, and deployment to ensure faster, more reliable software delivery.
45. Scenario: A developer pushed broken code to the main branch. How do you mitigate it?
Implement branch protection, automated testing in PRs, and use Jenkins to validate code before merging.
46. What is chaos engineering?
Chaos engineering involves intentionally injecting failures into systems to test resilience and improve reliability.
47. Scenario: Disk space on Jenkins master is full. What do you do?
Clean old build logs, archive artifacts externally, and configure automatic workspace cleanup.
48. What is the difference between pull and push deployment models?
In pull, agents fetch deployment instructions (like GitOps). In push, a central system (like Jenkins) triggers deployments directly.
49. Scenario: Your Prometheus metrics are missing after a restart. What could be the cause?
Check the retention period, ensure persistent storage for /prometheus data, and validate configuration files.
50. How do you ensure security in a DevOps pipeline?
Integrate security scans (SAST/DAST), manage credentials securely, use signed images, and enforce least-privilege IAM policies.