10 DevOps Interview Questions and Answers for 2026 | Real-World Scenarios
DevOps interviews are no longer just about remembering Linux commands or explaining what Docker is.
Today, interviewers want to understand how you approach real production problems, automate infrastructure, troubleshoot failures, and maintain reliable deployment pipelines.
Whether you’re preparing for a DevOps Engineer, Cloud Engineer, or Site Reliability Engineer (SRE) role, these 10 questions will help you strengthen your practical understanding.
Let’s get started! 🚀
1. How do you prevent two engineers from running Terraform simultaneously?
Answer:
When multiple engineers execute Terraform against the same infrastructure, concurrent operations can cause state conflicts and unexpected changes.
To prevent this, we use Terraform state locking.
For example, when using an AWS S3 backend, we can enable state locking through S3’s native lockfile mechanism.
terraform {
backend “s3” {
bucket = “my-terraform-state”
key = “prod/terraform.tfstate”
region = “ap-south-1”
use_lockfile = true
}
}
When Engineer A executes “terraform apply”, Terraform acquires a lock.
If Engineer B tries to execute another operation that requires the same lock, Terraform waits or returns a lock acquisition error, depending on the timeout configuration.
Real-world best practices:
- Store Terraform state remotely.
- Enable state locking.
- Use CI/CD pipelines for production deployments.
- Restrict direct production changes.
- Enable versioning on the S3 bucket.
Key takeaway: State locking prevents concurrent Terraform operations from modifying the same state.
2. Your Kubernetes Pod is in CrashLoopBackOff. How do you troubleshoot it?
Answer:
CrashLoopBackOff means a container repeatedly starts, crashes, and gets restarted by Kubernetes.
Step 1: Check Pod status.
kubectl get pods -n production
Step 2: Describe the Pod.
kubectl describe pod -n production
Step 3: Check application logs.
kubectl logs -n production
Step 4: Check logs from the previous container instance.
kubectl logs -n production –previous
Step 5: Investigate the root cause.
Common causes include:
- Application startup failures
- Missing environment variables
- Incorrect ConfigMaps or Secrets
- OOMKilled due to memory limits
- Failing liveness probes
- Database connectivity issues
Real-world scenario:
Suppose a Java application requires 1 GB of memory, but its container memory limit is 512 MB.
The container may be terminated with OOMKilled.
After validating the application’s memory requirements, we can adjust its resource limits and monitor the Pod.
Key takeaway: Always investigate logs, Pod events, and container termination reasons before restarting or redeploying.
3. What happens when a Jenkins pipeline fails during deployment?
Answer:
A failed Jenkins deployment can result from application errors, infrastructure problems, credentials, or configuration issues.
My troubleshooting approach would be:
Step 1: Open the failed Jenkins build and inspect Console Output.
Step 2: Identify the failed stage, such as Build, Test, Docker Build, or Deploy.
Step 3: Check the exact error message.
Step 4: Validate credentials, environment variables, dependencies, and connectivity.
Step 5: Fix the root cause and rerun the appropriate pipeline stages.
For Kubernetes deployments, I would also verify rollout status:
kubectl rollout status deployment/my-app
If a new release causes production issues, and the previous ReplicaSet is available, we can initiate a rollback:
kubectl rollout undo deployment/my-app
Key takeaway: A reliable CI/CD pipeline should support clear logging, automated testing, deployment verification, and controlled rollback.
4. How do you detect and fix Terraform infrastructure drift?
Answer:
Infrastructure drift occurs when actual cloud resources differ from the configuration managed by Terraform.
Example:
An engineer manually changes an EC2 instance type from “t3.medium” to “t3.large” using the AWS Console.
However, Terraform configuration still defines:
instance_type = “t3.medium”
To detect drift, execute:
terraform plan
Terraform refreshes its view of managed resources during planning and identifies differences.
How to fix it:
There are two possible approaches:
- If the manual change was unauthorized, review the plan and apply the approved Terraform configuration to restore the intended state.
- If the manual change was approved, update the Terraform code to reflect the new requirement.
Best practice: Integrate scheduled drift detection into CI/CD workflows and review changes before applying them.
Key takeaway: Terraform should remain the source of truth for infrastructure configuration.
5. What is the difference between Docker CMD and ENTRYPOINT?
Answer:
Both instructions define how a container starts, but they serve different purposes.
CMD provides the default command or arguments for a container.
CMD [“python”, “app.py”]
The default command can be overridden when starting the container.
ENTRYPOINT defines the main executable.
ENTRYPOINT [“python”]
CMD [“app.py”]
When both are used in exec form, Docker runs:
python app.py
If you execute:
docker run my-image worker.py
Docker runs:
python worker.py
Key takeaway: Use ENTRYPOINT for the primary executable and CMD for its default arguments.
6. How do you achieve zero-downtime deployments in Kubernetes?
Answer:
Kubernetes supports rolling updates, allowing new application Pods to replace existing Pods gradually.
Example deployment strategy:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
How it works:
- Kubernetes creates additional Pods during deployment.
- Readiness probes determine when new Pods can receive traffic.
- Existing Pods remain available until replacement Pods are ready, subject to the deployment strategy.
- Kubernetes gradually completes the rollout.
To monitor the deployment:
kubectl rollout status deployment/my-app
To view rollout history:
kubectl rollout history deployment/my-app
Important: Rolling updates alone do not guarantee zero downtime. We must also configure readiness probes, sufficient capacity, graceful shutdown, and backward-compatible application changes.
Key takeaway: Zero-downtime deployment requires both Kubernetes configuration and application-level readiness.
7. How do you securely manage secrets in a DevOps pipeline?
Answer:
Sensitive information such as database passwords, API keys, and cloud credentials should never be hardcoded in source code.
Recommended practices:
- Store secrets in AWS Secrets Manager, HashiCorp Vault, or another approved secret management service.
- Use IAM roles and short-lived credentials wherever possible.
- Restrict access using least-privilege permissions.
- Avoid printing secrets in pipeline logs.
- Enable encryption and audit logging.
- Rotate credentials when required.
AWS example:
An application running on an EC2 instance can use an attached IAM role to retrieve a database password from AWS Secrets Manager.
This avoids storing long-lived AWS access keys inside application configuration.
Key takeaway: Secrets should be centrally managed, access-controlled, and retrieved securely at runtime.
8. Your EC2 instance is running, but the application is inaccessible. How do you troubleshoot?
Answer:
An EC2 instance showing a Running state does not necessarily mean the application is healthy.
I would troubleshoot systematically.
Step 1: Check EC2 status checks.
Verify instance and system status checks in the AWS Console.
Step 2: Verify security groups.
Ensure the required application port is permitted from the intended source.
Step 3: Check network connectivity.
Validate route tables, network ACLs, and public or private access paths.
Step 4: Connect to the instance and inspect the service.
sudo systemctl status nginx
Step 5: Check whether the application is listening.
sudo ss -tulnp
Step 6: Review application logs and dependencies.
If the application is behind an Application Load Balancer, also inspect target group health checks.
Key takeaway: Troubleshoot from the network layer to the operating system and application layer.
9. How do you manage multiple environments using Terraform?
Answer:
In real-world projects, organizations commonly maintain separate environments such as Development, Testing, Staging, and Production.
A scalable approach is to use reusable Terraform modules with separate environment configurations and state files.
Example structure:
terraform/
├── modules/
│ ├── vpc/
│ ├── ec2/
│ └── rds/
├── environments/
│ ├── dev/
│ ├── test/
│ └── prod/
Each environment can use the same modules while passing different variables.
For example:
Development:
instance_type = “t3.micro”
Production:
instance_type = “t3.large”
Production and development should maintain separate Terraform states and appropriate access controls.
Key takeaway: Reusable modules improve consistency, while environment isolation reduces deployment risks.
10. How would you design a complete CI/CD pipeline for a containerized application?
Answer:
For a production-grade application, I would design a pipeline using GitHub or GitLab, Jenkins, Docker, Amazon ECR, and Kubernetes.
Stage 1: Source Code
A developer pushes code to the Git repository.
Stage 2: Build
Jenkins automatically triggers the pipeline and builds the application.
Stage 3: Testing
Run unit tests, integration tests, and code quality checks.
Stage 4: Security Scanning
Scan dependencies and container images for known vulnerabilities.
Stage 5: Docker Image Creation
Build the application container image.
Stage 6: Image Registry
Push the tested image to Amazon ECR using an immutable version or digest.
Stage 7: Deployment
Deploy the application to Amazon EKS using Helm or Kubernetes manifests.
Stage 8: Verification
Validate deployment status, readiness, and application health.
Stage 9: Monitoring and Rollback
Monitor application performance through tools such as Prometheus, Grafana, CloudWatch, or Datadog.
If critical health checks fail, initiate a controlled rollback.
Key takeaway: CI/CD is not just about automating deployments. It is about delivering software consistently, securely, and reliably.
Final Thoughts
DevOps interviews are increasingly focused on real-world problem-solving rather than theoretical definitions.
Knowing a command is useful, but understanding why you use it, when you use it, and how it helps resolve a production issue is what makes your answer stronger.
When preparing for your next interview, focus on three things:
- Understand the concept — Learn how the technology works.
- Practice hands-on — Build pipelines, deploy infrastructure, and troubleshoot failures.
- Explain real-world scenarios — Connect your technical knowledge to actual production challenges.
Remember:
A good DevOps engineer knows the tools. A great DevOps engineer knows how to use them to build reliable systems.
Keep learning. Keep automating. Keep improving. 🚀
If you found this article useful, consider sharing it with someone preparing for a DevOps or Cloud Engineering interview.


