Skip to content
Cloud Computing

DevOps Interview Questions: Practical Answers and Scenarios

Prepare for DevOps interviews with practical answers covering CI/CD, Git, Terraform, containers, Kubernetes, monitoring and security. Learn how to structure examples and explain your troubleshooting process.

DevOps Interview Questions: Practical Answers and Scenarios

DevOps interviews test more than tool knowledge. Interviewers want to see how you improve delivery, run systems reliably and work with other teams. This guide covers common devops interview questions, practical ways to answer them and the signals interviewers look for. Use it to explain your experience clearly, not to recite definitions.

The commands and examples in this guide target Ubuntu 22.04 LTS with Git 2.34+, Docker CE, Terraform 1.7+, kubectl 1.29.x, kind 0.22.x and GitHub Actions. Change versions on purpose if your environment differs.

How to approach devops interview questions

A strong answer connects a technical decision to its purpose and its outcome. When a question asks for an example, use this structure:

  1. Situation: Give enough context to explain the problem.
  2. Task: State what you were responsible for.
  3. Action: Describe the steps you took and why you took them.
  4. Result: Explain the outcome. Use a relevant measure if you have one.
  5. Learning: Share what you would repeat or change next time.

Be specific about your contribution. If you worked with a team, say what you owned and what others did. Interviewers usually value clear reasoning and honest limits more than claims of expertise in every tool.

Common DevOps interview questions and strong answers

1. What is DevOps?

A strong answer: DevOps is a way of working that brings development and operations closer together. It relies on practices such as automation, continuous delivery, shared ownership and feedback from production, so teams can ship changes reliably. It is not a single tool or a job title. The right practices depend on the organisation and its risks.

What interviewers assess: Whether you understand the collaboration and delivery principles behind the tools.

2. What does a typical CI/CD workflow look like?

A strong answer: A developer pushes a change to version control. The pipeline runs checks such as linting, unit tests and security scans, then builds and stores an artifact. After the required approvals or checks pass, the same artifact deploys to the target environment. Health checks and monitoring confirm the release worked. If it did not, a rollback or roll-forward plan limits the impact.

Describe the stages you have built or operated. Explain how you handle credentials, approvals and deployment failures. A list of tools alone does not show that you understand the process.

A minimal GitHub Actions workflow that tests, builds and gates deployment:

name: ci

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read
  packages: write

jobs:
  test:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: npm
      - run: npm ci
      - run: npm run lint
      - run: npm test -- --ci

  build:
    needs: test
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
          cache-from: type=gha
          cache-to: type=gha,mode=max

  deploy:
    needs: build
    runs-on: ubuntu-22.04
    environment: production
    steps:
      - uses: actions/checkout@v4
      - run: |
          mkdir -p ~/.kube
          echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > ~/.kube/config
          chmod 600 ~/.kube/config
      - run: |
          kubectl -n your_namespace set image deployment/your_app \
            your_app=ghcr.io/${{ github.repository }}:${{ github.sha }}
          kubectl -n your_namespace rollout status deployment/your_app --timeout=120s

Warning

A full kubeconfig stored in a CI secret gives the pipeline broad cluster access. Use short-lived credentials or OIDC federation where your platform supports them. Scope the service account to the namespace and verbs the deployment needs.

3. How do you use Git in a team?

A strong answer: Git records changes and supports teamwork through branches, reviews and merges. Some teams use short-lived feature branches. Others use trunk-based development. The right choice depends on the release process. I keep changes easy to review, resolve conflicts carefully and keep secrets and generated files out of commits. If a deployment problem follows a change, Git history shows what changed and makes a revert straightforward.

What interviewers assess: Your understanding of collaboration, traceability and safe change management. Knowing the commands is not enough.

A typical short-lived branch workflow:

git switch -c feature/add-healthcheck
git add app/healthcheck.py
git commit -m "Add readiness endpoint"
git push -u origin feature/add-healthcheck

Check the result before you open a pull request:

git status
git log --oneline -5

Expected output looks like this:

On branch feature/add-healthcheck
nothing to commit, working tree clean

To undo a merged change without rewriting shared history:

git revert <commit_sha>

Warning

Commands such as git reset --hard and git push --force can discard work or rewrite shared branches. Use git push --force-with-lease only on your own branch. Never force-push a protected branch.

Scan for accidentally committed credentials before you push:

docker run --rm -v "$PWD:/repo" zricethezav/gitleaks:latest detect --source /repo --verbose

4. What is Infrastructure as Code (IaC), and why use it?

A strong answer: IaC defines infrastructure in version-controlled files. Teams can review, test and reproduce changes instead of relying on undocumented manual steps. Tools such as Terraform manage resources through a plan-and-apply workflow. I separate environments, handle state carefully, restrict access to sensitive values and review each proposed change before I apply it.

IaC does not make infrastructure safe or correct by itself. You still need change control, access management, testing and a recovery plan.

A minimal Terraform configuration with a remote backend:

terraform {
  required_version = ">= 1.7.0"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }

  backend "s3" {
    bucket         = "YOUR_BUCKET_NAME"
    key            = "env/prod/terraform.tfstate"
    region         = "YOUR_AWS_REGION"
    dynamodb_table = "YOUR_LOCK_TABLE"
    encrypt        = true
  }
}

Run the plan-and-apply workflow from the directory that contains the configuration:

terraform init
terraform fmt -check -recursive
terraform validate
terraform plan -out=tfplan
terraform show tfplan
terraform apply tfplan

Check that the backend and providers initialised correctly:

terraform version
terraform state list

Warning

terraform apply changes real infrastructure, and terraform destroy deletes it. Review the saved plan before you apply it. Protect production state with locking and backups. Never edit state by hand unless you have a tested recovery path.

5. What problem do containers solve?

A strong answer: Containers package an application and its dependencies into one consistent unit. This reduces differences between development, test and production. Containers support repeatable deployment and workload isolation. They do not replace host security, resource management or monitoring. I also keep two terms separate: an image is the packaged template, and a container is a running instance of that image.

A multi-stage Dockerfile for a Node.js service:

FROM node:20-bookworm-slim AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:20-bookworm-slim
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
USER node
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
  CMD node -e "fetch('http://127.0.0.1:3000/healthz').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
CMD ["node", "dist/server.js"]

Build, run and verify the container:

docker build -t your_app:local .
docker run --rm -d -p 3000:3000 --name your_app your_app:local
curl -fsS http://localhost:3000/healthz
docker inspect --format '{{.State.Health.Status}}' your_app
docker stop your_app

Expected health status:

healthy

6. How do Kubernetes deployments stay available?

A strong answer: Kubernetes keeps the desired number of replicas running and replaces unhealthy pods. Services give workloads a stable way to reach them. Readiness probes decide whether a pod receives traffic. Liveness probes restart a container when its process gets stuck. Availability also depends on sensible resource requests and limits, rollout settings, application health and the capacity of the cluster.

For more practice, review these Kubernetes interview questions and answer examples.

A Deployment with probes, resource limits and a conservative rolling update:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: your_app
  namespace: your_namespace
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  selector:
    matchLabels:
      app: your_app
  template:
    metadata:
      labels:
        app: your_app
    spec:
      containers:
        - name: your_app
          image: ghcr.io/your_org/your_app:YOUR_TAG
          ports:
            - containerPort: 3000
          readinessProbe:
            httpGet:
              path: /healthz
              port: 3000
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /healthz
              port: 3000
            initialDelaySeconds: 15
            periodSeconds: 20
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 256Mi

Apply the manifest and verify the rollout:

kubectl apply -f deployment.yaml
kubectl -n your_namespace rollout status deployment/your_app --timeout=120s
kubectl -n your_namespace get pods -l app=your_app -o wide

Expected rollout output:

deployment "your_app" successfully rolled out

Warning

kubectl delete removes live workloads. kubectl rollout undo shifts production traffic to an earlier revision. Confirm the namespace and context first with kubectl config current-context and kubectl -n your_namespace get deployment.

7. How do you monitor a production service?

A strong answer: I combine metrics, logs and traces where they help. Metrics show trends and service health. Structured logs give event details. Traces show where time goes along a request path. I prioritise signals that reflect user impact, such as latency, errors and successful transactions. Then I tie each alert to a clear response. Too many low-value alerts can bury the incidents that matter.

Useful PromQL signals for a service that uses standard HTTP metrics:

sum(rate(http_requests_total{job="your_app",status=~"5.."}[5m]))
/
sum(rate(http_requests_total{job="your_app"}[5m]))
histogram_quantile(
  0.95,
  sum by (le) (rate(http_request_duration_seconds_bucket{job="your_app"}[5m]))
)

Check that Prometheus and the Kubernetes metrics pipeline are reachable:

curl -fsS http://YOUR_SERVER_IP:9090/-/healthy
kubectl top pods -n your_namespace

Expected Prometheus response:

Prometheus Server is Healthy.

8. How do you handle secrets in a pipeline?

A strong answer: I do not store secrets in source code, images or plain-text pipeline files. I use a secrets manager or protected CI/CD variables. I limit access to the minimum required, rotate credentials and keep sensitive values out of logs. The exact setup depends on the platform. Treat every secret as a credential with controlled access and an audit trail.

Pass a CI secret to a step through an environment variable instead of putting it in the command:

- run: ./deploy.sh
  env:
    API_TOKEN: ${{ secrets.API_TOKEN }}

For a lab, create a Kubernetes Secret from a literal value:

kubectl -n your_namespace create secret generic your_app_secret \
  --from-literal=API_TOKEN='REPLACE_ME'

Verify the metadata only, not the decoded value:

kubectl -n your_namespace describe secret your_app_secret

Warning

Kubernetes Secrets are base64-encoded, not encrypted by default. Enable encryption at rest, restrict RBAC access to Secret objects and prefer an external secrets operator or sealed-secrets workflow in production. Never print decoded secrets into CI logs.

9. What is the difference between continuous delivery and continuous deployment?

A strong answer: Continuous delivery keeps software ready to deploy at any time. A person or a deliberate trigger usually approves the production release. Continuous deployment releases every change that passes the pipeline's checks automatically. Both depend on reliable testing and deployment practices. Neither one guarantees quality without the right controls.

Scenario-based questions: show your troubleshooting process

Scenario questions test how you investigate when you are not sure of the cause. Do not jump straight to a familiar fix. State what you know, identify what you still need to verify and explain how you reduce risk while you investigate.

A deployment causes a spike in errors. What do you do?

Start by confirming the impact. Which users or services are affected? When did the errors start? Do they match the release timeline? Check dashboards, logs, traces and deployment events. If the release is the likely cause, follow your team's rollback or roll-forward process and keep the evidence. Once service is stable, find the root cause, add a test or safeguard, and communicate the incident and follow-up actions.

Useful first commands:

kubectl -n your_namespace rollout history deployment/your_app
kubectl -n your_namespace get pods -l app=your_app -o wide
kubectl -n your_namespace logs -l app=your_app --tail=100 --since=15m

Warning

A rollback changes production. Confirm the target revision and any database or API compatibility before you run kubectl rollout undo deployment/your_app --to-revision=<revision>.

A Kubernetes pod keeps restarting. How do you investigate?

Check the pod's status and recent events. Then inspect its logs, configuration and resource use. Look for failed probes, application startup errors, image or configuration problems and memory limits being exceeded. Find out whether one replica or the whole workload is affected. Avoid changing several settings at once. Make one targeted change, verify recovery and record what you learned.

kubectl -n your_namespace get pods -l app=your_app
kubectl -n your_namespace describe pod <pod_name>
kubectl -n your_namespace logs <pod_name> --previous
kubectl -n your_namespace get events --sort-by=.lastTimestamp

Look for CrashLoopBackOff, OOMKilled, failed readiness probes or ImagePullBackOff in the describe output before you change the Deployment.

A Terraform plan proposes an unexpected replacement. What next?

Do not apply it until you understand why. Review the plan, identify which attributes changed and check the configuration, provider behaviour and state. Confirm whether the replacement is intended and what it means for data or availability. If the plan still looks wrong, pause and review it with your team. Do not edit state or apply a risky change without review.

terraform plan -out=tfplan
terraform show tfplan
terraform show -json tfplan | jq '.resource_changes[] | select(.change.actions[] == "delete")'

The JSON query needs jq. On Ubuntu 22.04, install it with sudo apt-get install -y jq.

A pipeline is slow or failing intermittently. How would you respond?

Find the stage that takes the most time or fails most often. Compare recent runs for patterns such as shared runners, external dependencies, flaky tests or artifact handling. Separate infrastructure problems from application or test failures. Improve the pipeline step by step. For example, remove unnecessary work or make a flaky test deterministic. Measure whether each change helped. Do not skip important checks just to make builds faster.

What interviewers are looking for

Across technical and behavioural questions, interviewers often look for:

  • Clear fundamentals: You explain concepts in plain language and tell similar ideas apart.
  • Practical judgment: You weigh security, reliability, cost, maintainability and user impact.
  • Structured troubleshooting: You gather evidence, form hypotheses, test them and verify the result.
  • Ownership without blame: You explain your part in an incident and focus on learning and prevention.
  • Communication: You describe trade-offs and adjust the detail to your audience.
  • Honesty: You separate direct experience from what you have studied, and you explain how you would learn an unfamiliar tool.

If you do not know an answer, say so plainly. Then explain what you would check or how you would reason through the problem. A sound approach often persuades more than a confident guess.

A practical preparation plan

  1. Read the job description closely. Group the requirements into Linux, networking, cloud, CI/CD, containers, IaC, security and observability.
  2. Prepare real examples. Write down a deployment you improved, an incident you investigated and a trade-off you made. Include your role, your decisions and the outcome.
  3. Review fundamentals before tool trivia. Practise explaining how a pipeline, container, deployment and monitoring setup fit together.
  4. Practise scenarios aloud. Walk through each investigation step in order, including how you would protect users and verify a fix.
  5. Build a small lab if it helps. A disposable environment lets you practise Git, containers, pipelines or IaC without risk to production. If you need a VPS for a learning lab, compare available hosting plans and choose one that fits your workload.
  6. Prepare questions for the interviewer. Ask how the team handles deployments, on-call work, incident reviews, infrastructure changes and collaboration between development and operations.

A useful exercise is to explain one past project in two minutes. Then answer follow-up questions about failure modes, security and what you would improve. This keeps you from giving memorised answers and makes your experience easier to assess.

Optional lab setup on Ubuntu 22.04

Install the core tools:

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg jq unzip

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker "$USER"

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(. /etc/os-release && echo "$VERSION_CODENAME") main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt-get update
sudo apt-get install -y terraform

curl -fsSLo /tmp/kubectl https://dl.k8s.io/release/v1.29.4/bin/linux/amd64/kubectl
sudo install -m 0755 /tmp/kubectl /usr/local/bin/kubectl

curl -fsSLo /tmp/kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-amd64
sudo install -m 0755 /tmp/kind /usr/local/bin/kind

Log out and back in so the Docker group membership takes effect. Then create a disposable cluster:

kind create cluster --name devops-lab
kubectl cluster-info --context kind-devops-lab

Verify each tool:

git --version
docker --version
terraform version
kubectl version --client
kind version

Expected output looks like this:

git version 2.34.1
Docker version 24.0.7, build afdd53b
Terraform v1.7.5
Client Version: v1.29.4
kind v0.22.0 go1.20.4 linux/amd64

Troubleshooting

Terraform reports "Backend initialization required"

Run initialisation again in the configuration directory:

terraform init -reconfigure

If you changed the backend configuration on purpose, run terraform init -migrate-state. Review the prompt before you confirm.

Terraform reports "Error acquiring the state lock"

Another run may still be active. Confirm that no teammate or CI job is applying changes. Then release the lock by its ID:

terraform force-unlock <LOCK_ID>

Warning

Force-unlocking while another apply is running can corrupt state. Do this only after you confirm the lock is stale.

kubectl reports "Unable to connect to the server"

Check the active context and whether the cluster is reachable:

kubectl config current-context
kubectl cluster-info

If the context is wrong, switch with kubectl config use-context <context_name>. For a kind lab, recreate the cluster if its Docker container was removed.

Docker reports "permission denied while trying to connect to the Docker daemon socket"

Add your user to the Docker group and refresh your session:

sudo usermod -aG docker "$USER"
newgrp docker
docker info

Git push is rejected as non-fast-forward

Fetch the remote and rebase your branch onto it before you push:

git pull --rebase origin main
git push origin main

Warning

Do not fix this with git push --force on a shared branch. Force-pushing can erase commits that other people depend on.

A pod is stuck in CrashLoopBackOff or ImagePullBackOff

Inspect the previous container logs and the pod events:

kubectl -n your_namespace describe pod <pod_name>
kubectl -n your_namespace logs <pod_name> --previous

For ImagePullBackOff, confirm that the image tag exists and that the pod references the correct imagePullSecrets. For CrashLoopBackOff, check the startup command, configuration and probe paths before you change resource limits.

GitHub Actions fails with "Resource not accessible by integration"

Add explicit least-privilege permissions to the workflow:

permissions:
  contents: read
  packages: write

If the job still cannot push an image, confirm that the repository allows GitHub Actions to write packages. Also check that the workflow uses secrets.GITHUB_TOKEN rather than a hard-coded credential.

Conclusion

Strong interview answers combine solid fundamentals, clear examples, careful reasoning and an honest account of your experience. As you prepare, ground your explanations in systems you have built or supported. Ritik Barnwal's hosting resources may also help you explore the infrastructure concepts behind real-world operations.

Frequently asked questions

What versions and tools does this DevOps interview guide use?

The commands and examples target Ubuntu 22.04 LTS with Git 2.34+, Docker CE, Terraform 1.7+, kubectl 1.29.x, kind 0.22.x and GitHub Actions. The article advises changing versions on purpose if your environment differs.

What should I do if a Kubernetes pod keeps restarting?

Check the pod status, events, logs, configuration and resource use, looking for failed probes, startup errors, image or configuration problems, and exceeded memory limits. The guide's investigation commands are kubectl -n your_namespace get pods -l app=your_app, kubectl -n your_namespace describe pod <pod_name>, kubectl -n your_namespace logs <pod_name> --previous and kubectl -n your_namespace get events --sort-by=.lastTimestamp.

What should I do if Terraform reports an error acquiring the state lock?

Confirm that no teammate or CI job is applying changes before releasing the lock. If the lock is stale, use terraform force-unlock <LOCK_ID>; force-unlocking while another apply is running can corrupt state.

What is the difference between continuous delivery and continuous deployment?

Continuous delivery keeps software ready to deploy at any time, with a person or deliberate trigger usually approving the production release. Continuous deployment releases every change that passes the pipeline's checks automatically.

How should I structure an answer to a behavioral DevOps interview question?

Use Situation, Task, Action, Result and Learning: explain the context, your responsibility, what you did and why, the outcome, and what you would repeat or change next time. Be specific about your contribution and distinguish your work from what others did.

Comments

Loading comments…

Leave a comment

All articles