DevOps Engineer interview questions
100 real questions with model answers and explanations for Middle candidates.
See a DevOps Engineer resume example →Practice with flashcards
Spaced repetition · Hunter Pass
Questions
A CI pipeline should put the fastest and cheapest feedback first, then increase cost and risk gradually.
- Run linting and static checks first, unit tests next, then build the container and test that built image in integration tests.
- Run security scans only after cheaper checks pass, and publish or deploy only after every quality gate succeeds.
- This ordering prevents a formatting error from waiting behind a ten-minute build and avoids spending resources on already-broken commits.
- On pull requests, stop before publishing; on merge to main, publish the artifact and run deployment stages.
Why interviewers ask this: The fail-fast-and-cheap ordering principle, stated as a rule rather than a fixed recipe, shows the candidate designs pipelines instead of copying templates.
CI builds are slow because clean runners lack the persistent layer cache available on a developer machine.
- Give BuildKit a persistent source through registry-backed cache-from and cache-to, or mount the CI platform's cache storage into the build.
- Use BuildKit cache mounts for package-manager directories such as pip or npm so downloads survive builds without becoming image layers.
- Copy dependency manifests and install dependencies before copying application code, preserving expensive layers when only source files change.
- Verify cache hits in CI logs, because remote caching cannot compensate for a Dockerfile whose early layers change on every commit.
Why interviewers ask this: Knowing that clean runners lose the layer cache and naming registry cache plus cache mounts as the fixes shows real CI build optimization experience.
Cloud access in CI should use short-lived, narrowly scoped identities instead of stored access keys.
- With OIDC federation, the CI provider issues an identity token per job, the cloud validates it, and the job assumes only the role it needs.
- No static cloud secret then exists to leak through logs or forks, and there is no long-lived credential to rotate manually.
- Long-lived keys tend to remain unrotated and accumulate broad permissions, increasing both the chance and impact of compromise.
- If OIDC is unavailable, use short-lived tokens from a secrets manager, masked variables, least privilege, and scheduled rotation.
Why interviewers ask this: Naming OIDC federation as the replacement for static keys, with the reasons keys rot, is the current-practice marker interviewers listen for.
Build once, deploy many means promoting one tested, immutable artifact unchanged through every environment.
- Build and test one container image, then promote the exact same digest through development, staging, and production.
- Inject environment-specific configuration at runtime rather than baking it into separate images.
- Rebuilding per environment can change resolved dependencies, build inputs, or the base image, so production receives a binary that staging never tested.
- Tie immutable tags to the commit and never use mutable latest for promotion, preserving provenance and reliable rollback.
Why interviewers ask this: The tested-thing-is-the-shipped-thing argument and runtime configuration as its prerequisite form the core promotion discipline being probed.
Duplicate GitHub Actions pipelines should become versioned shared workflows with thin service-specific callers.
- Put workflow_call definitions with typed inputs and secrets in a central repository, leaving each service repository to pass only its parameters.
- Use composite actions for smaller reusable step sequences, such as configuring cloud credentials or building an image.
- Reference released tags rather than main so breaking changes can be adopted deliberately instead of affecting all repositories at once.
- Document an escape hatch for services with legitimate exceptions without returning the whole organization to copied workflows.
Why interviewers ask this: Reusable workflows with versioned references, plus the deliberate-rollout concern, show platform-minded pipeline maintenance rather than tolerated duplication.
Pipeline optimization starts with measured bottlenecks, not assumed ones.
- Collect per-stage and per-step timings across a few hundred runs to locate time spent on dependency installation, image builds, and serial tests.
- Cache dependencies and build layers, then parallelize independent jobs and shard test suites.
- Move slow full end-to-end suites out of the pull-request critical path into post-merge or nightly runs when their risk profile allows it.
- Set a duration budget and alert on regressions so performance remains owned instead of drifting back to forty minutes.
Why interviewers ask this: Measure-then-optimize with a maintained duration budget separates systematic engineers from people who once added a cache line.
Trunk-based development shifts CI/CD toward fast, reliable validation of small changes merged frequently into main.
- The pipeline must be quick and trustworthy enough to gate every merge, while incomplete functionality stays behind feature flags rather than branches.
- Long-lived branches delay integration, accumulate conflicts, and turn staging into a queue of large, partially tested merges.
- Trunk-based development and feature flags support continuous deployment by exposing integration problems early and reducing batch size.
- GitFlow-style branches favor release trains and larger batches; this can suit regulated release schedules but reduces deployment frequency.
Why interviewers ask this: Linking branch strategy to integration risk timing and flag usage shows the candidate understands CD as a system, not a tool setting.
Manual approval belongs only where a person contributes judgment that automated gates cannot provide.
- Use it for high-risk production changes, irreversible operations such as data migrations, or compliance requirements for a second reviewer.
- Implement approval through protected environments with a clearly defined approver group and enough context for an informed decision.
- Requiring a click for every routine deployment creates latency, encourages rubber-stamping, and batches changes into riskier releases.
- Gate routine releases with automated tests and canary metrics, reserving human review for cases someone will genuinely inspect.
Why interviewers ask this: Distinguishing judgment gates from rubber stamps, and the batching-risk consequence of gratuitous approvals, is the deployment maturity marker.
A reliable rollback redeploys the previous known-good artifact without requiring a new build.
- Keep immutable, versioned images in the registry and make deployment tooling able to select any retained version through a tested one-command path.
- Rehearse rollback procedures, because an untested runbook is likely to fail during an incident.
- Git revert alone waits for build and test while production is failing, and it is unusable if the pipeline itself is broken.
- Use backward-compatible schema changes and expand-contract migrations so data written by the new version does not prevent the old artifact from returning.
Why interviewers ask this: Artifact-level rollback with the schema compatibility caveat shows the candidate has thought past the happy path of undo.
A monorepo pipeline should rebuild and deploy only affected services while retaining a full-build safety net.
- Use path filters so each service reacts to changes in its own directory and in shared paths it consumes.
- Model shared-library dependencies with Nx, Bazel, Turborepo, or a maintained script that computes affected services from the diff.
- Run a complete build nightly because path and dependency-graph logic can miss relationships or contain bugs.
- Keep deployment independent per service so one team's change cannot release another team's unfinished work.
Why interviewers ask this: Handling the shared-library dependency graph, not just path filters, plus a full-build safety net, distinguishes real monorepo experience.
Self-hosted runners are justified by network, hardware, caching, or high-volume cost requirements that hosted runners cannot meet well.
- Choose them for private-network access, GPUs or large memory, persistent caches, or workloads where hosted per-minute pricing is uneconomical.
- The team then owns patching, capacity, scaling, monitoring, and regular replacement of the runner fleet.
- Prefer ephemeral or frequently recycled runners so one build cannot leave state for the next.
- Treat forked pull-request code as remote code execution: isolate its network and credentials, using hosted runners by default and locked-down ephemeral self-hosted runners only where needed.
Why interviewers ask this: Naming the fork-PR-equals-RCE risk and insisting on ephemeral runners shows security-aware infrastructure thinking, not just cost math.
GitOps makes Git the source of desired cluster state and lets an in-cluster controller reconcile reality to it.
- Manifests or Helm values live in Git, and a deployment is a merged pull request that changes an image tag for Argo CD or Flux to pull.
- CI no longer needs cluster credentials because the controller inside the cluster fetches and applies the change.
- Reconciliation detects manual drift and can report or revert it, making desired state continuously enforced rather than applied once.
- Rollback is a Git revert in the state repository, while Git history provides the audit trail of who changed what.
Why interviewers ask this: The credentials-stay-in-cluster point and drift reconciliation are the two substantive GitOps advantages that show understanding beyond the buzzword.
A build pipeline should make every input traceable and prevent unverified artifacts from reaching deployment.
- Pin third-party CI actions by commit SHA, base images by digest, and dependencies through lock files instead of mutable references.
- Generate an SBOM during the build and scan dependencies and images for known vulnerabilities, blocking critical findings by policy.
- Sign built images so deployment targets can verify that the artifact is exactly what CI produced.
- Never pass secrets through build arguments or layers, because they remain recoverable through image history.
Why interviewers ask this: Pinning by SHA and digest plus signing and SBOM shows familiarity with the current supply chain threat model rather than checkbox scanning.
Database migrations in continuous deployment must remain compatible with both old and new application instances during rollout.
- Run migrations as a separate init job or pipeline stage before deploying application code.
- Use expand-contract: add a nullable column, deploy code that writes both formats, backfill data, switch reads, and remove the old column in a later release.
- Keep each intermediate schema valid while old and new instances use it simultaneously.
- Do not ship a migration and code that immediately depends on it in the same deployment, preserving safe rollout and rollback.
Why interviewers ask this: The old-and-new-run-together constraint driving expand-contract, and separating migration deploys from code deploys, is the operational discipline sought.
One artifact can serve every environment only when all varying configuration stays outside the image.
- Inject environment variables, mounted configuration files, or configuration-service values at deployment time according to twelve-factor principles.
- Keep a shared base plus small Kustomize overlays or Helm value files so environment differences remain visible in review.
- Deliver secrets separately through a secrets manager or sealed secrets, never as plain values committed to the repository.
- Validate required configuration at startup so a missing or invalid value fails during deployment rather than during a later production request.
Why interviewers ask this: Base-plus-overlay structure with startup validation shows configuration treated as designed surface area, not an afterthought of env vars.
A Jenkins-to-GitHub-Actions migration preserves delivery concepts but should redesign the execution model rather than translate jobs line by line.
- Jenkins stages map to jobs, shared libraries to reusable workflows or composite actions, agents to runners, and credentials to environment secrets or preferably OIDC.
- Replace a stateful Jenkins server and years of plugin configuration with declarative repository-owned YAML and ephemeral runners.
- Remove snowflake job settings and unnecessary plugins instead of reproducing their accumulated behavior in the new platform.
- Inventory jobs that assume persistent workspaces, plugins with no Actions equivalent, and undocumented behavior hidden on the Jenkins server.
Why interviewers ask this: Framing migration as a chance to shed stateful snowflake configuration, with concrete trap awareness, shows real migration experience over tool tourism.
Infrastructure code should pass layered static, plan, integration, and staging checks before production.
- Start with terraform fmt and validate, tflint, and policy-as-code rules that reject risks such as public S3 buckets or 0.0.0.0/0 ingress.
- Run terraform plan on every pull request and review the plan diff as the primary artifact, including the proposed blast radius rather than only HCL style.
- For modules with meaningful logic, create them in an ephemeral sandbox account, assert behavior, and destroy the resources after the test.
- Apply the same change to staging infrastructure as the final safety layer before promoting it to production.
Why interviewers ask this: Treating the plan diff as the review artifact and policy-as-code gates shows infrastructure engineering discipline beyond syntax validation.
CI notifications become actionable when each failure reaches its owner with enough context to start triage immediately.
- Send pull-request failures directly to the author and main-branch service failures to the owning team's channel.
- Do not broadcast failures to people who cannot act on them, which prevents the wall-of-red channel everyone eventually mutes.
- Include the failed stage, a useful error excerpt, a log link, and the difference from the last green run in every notification.
- Track product test failures, infrastructure flakes, and environment outages as separate signal classes so routine noise does not teach teams to ignore red status.
Why interviewers ask this: Ownership-based routing and failure-class separation address the alert fatigue mechanism itself rather than adding another dashboard.
A multi-stage Dockerfile separates compilation from execution so production receives only the files required at runtime.
- The first stage uses the full toolchain image, installs dependencies, and compiles the binary or bundles the application.
- The final stage starts from a minimal distroless, Alpine, or slim base and copies only the built artifact and runtime dependencies.
- Compilers, development headers, package managers, and source code stay out of production, reducing image size and attack surface.
- Stable dependency installation remains in early cached layers while the tiny final stage rebuilds and ships quickly.
Why interviewers ask this: Connecting multi-stage to both attack surface reduction and cache structure, not just megabytes, shows complete understanding of the pattern.
A 1.8 GB image should be reduced by addressing the largest structural sources first and then preventing regression.
- Inspect the base image first; replacing a full OS or large language image with slim or distroless usually gives the biggest low-effort saving.
- Use docker history or dive to find build tools, apt or pip caches, copied source trees, and missing .dockerignore entries such as .git or node_modules.
- Use multi-stage builds to exclude build tools and remove package caches in the same RUN instruction that creates them.
- Add an image-size limit to CI after the reduction so silent bloat cannot return.
Why interviewers ask this: Using dive-style layer analysis and finishing with a CI size gate shows systematic optimization rather than one-off dieting.
Locked questions
- 21
Why does Dockerfile instruction order matter for build speed, and what is the canonical ordering mistake?
dockerownership - 22
ENTRYPOINT versus CMD: how do they interact, and how do you use them together well?
- 23
What container hardening do you apply by default, and what breaks when you first enable it?
containers - 24
A container ignores SIGTERM and gets killed after the grace period every deploy. What is happening and how do you fix it?
containersdeployment - 25
In docker compose, service A cannot reach service B despite both running. What is your diagnostic path?
docker - 26
Volumes versus bind mounts in Docker: when do you use each, and what data loss mistake do they prevent or cause?
ownershipdocker - 27
Why is deploying by the latest tag dangerous, and what tagging scheme do you use instead?
deployment - 28
What does registry hygiene look like for a team pushing dozens of images a day?
registries - 29
A container exits with code 137 intermittently. What does that mean and how do you investigate?
containers - 30
How do you set up docker compose for local development so that local matches production closely enough to matter?
docker - 31
Why do containers need explicit memory and CPU limits even outside Kubernetes, and what does each limit actually do?
kubernetescontainersmemory - 32
What do Docker healthchecks change in behavior, and what makes a good healthcheck command?
docker - 33
A pod is stuck in Pending. Walk me through your diagnosis.
problem-solving - 34
Deployment, StatefulSet, DaemonSet: what guarantees does each provide, and what goes wrong when you pick the wrong one?
deployment - 35
How does a Kubernetes Service actually route traffic to pods, and what are the ClusterIP, NodePort, and LoadBalancer types for?
kubernetes - 36
What does an Ingress add on top of Services, and what is the relationship between the Ingress resource and the controller?
kubernetes - 37
ConfigMaps and Secrets: how do you inject them, and what update behavior surprises people?
configkubernetessecrets - 38
Liveness, readiness, and startup probes: what does each control, and how does a bad liveness probe take down a service?
health-checks - 39
Explain requests versus limits for CPU and memory in Kubernetes, and the practical consequences of setting them badly.
memorykubernetes - 40
How does the Horizontal Pod Autoscaler work, and what prerequisites and pitfalls come with it?
scaling - 41
What do maxSurge and maxUnavailable control in a rolling update, and why can a technically successful rollout still drop traffic?
- 42
A pod is in CrashLoopBackOff. What are the most frequent causes you check, in order?
- 43
How do you apply least privilege in Kubernetes RBAC for both humans and workloads?
rbacleast-privilegekubernetes - 44
What isolation do namespaces actually provide in Kubernetes, and what do they not?
kubernetes - 45
When do you reach for Helm versus Kustomize, and what Helm discipline keeps charts maintainable?
helmkubernetes - 46
How does service discovery work inside a Kubernetes cluster, and what DNS-related issues have you debugged?
dnskubernetes - 47
A node needs maintenance. How do you take it out of service safely, and what stops pods from being evicted?
- 48
How do PersistentVolumes, PersistentVolumeClaims, and StorageClasses fit together, and why is stateful storage still the hard part of Kubernetes?
kubernetes - 49
A Service exists, pods are Running, but traffic gets connection refused. Describe your Kubernetes networking triage.
kubernetes - 50
What has to be configured for a Kubernetes deployment to be genuinely zero-downtime, end to end?
kubernetesdeploymentconfig - 51
What is Terraform state, and why do teams need remote state with locking from day one?
terraformlocking - 52
Describe a sane team workflow for Terraform changes from PR to applied infrastructure.
terraform - 53
When do you write a Terraform module versus using resources inline, and what makes a module good?
terraform - 54
How do you detect and handle infrastructure drift when people make changes in the cloud console?
iac - 55
You inherit cloud infrastructure built by hand. How do you bring it under Terraform without breaking anything?
ownershipterraform - 56
Terraform state contains secrets, and your database password just ended up in it. What is your approach to secrets in IaC?
terraformiacsecrets - 57
Terraform and Ansible both claim infrastructure automation. How do you divide work between them, and what does idempotency mean in Ansible practice?
terraformansibleidempotency - 58
Terraform workspaces versus separate directories per environment: which do you choose and why?
terraform - 59
How do you protect critical resources like the production database from accidental Terraform destruction?
databaseterraform - 60
A team debates Pulumi versus Terraform for new infrastructure. What are the real trade-offs?
terraformiac - 61
Design the basic VPC layout for a web application with a database. What goes where and why?
designnetworkingdatabase - 62
Security groups versus network ACLs in AWS: how do they differ, and how do you use them in practice?
networking - 63
What IAM practices do you enforce, and why are instance roles better than access keys on servers?
- 64
RDS Multi-AZ versus read replicas: what problem does each solve, and what do people confuse about them?
replication - 65
How do you secure an S3 bucket that stores user uploads, and how do clients access files safely?
aws - 66
ALB versus NLB: how do you choose, and what health check subtleties matter?
health-checks - 67
Your platform autoscales at two layers: cluster nodes and application pods. How do these interact, and what goes wrong?
scaling - 68
The monthly cloud bill doubled and nobody knows why. How do you find the waste operationally?
- 69
When does a serverless function fit better than a container service, and what operational surprises come with Lambda?
containerslambda - 70
What role does DNS TTL play during a migration or failover, and how do you plan around it?
migrationsdns - 71
How do you manage TLS certificates so expiry never becomes an incident?
incidentstls - 72
An availability zone goes down. What breaks in a typical single-region setup, and what does AZ resilience require?
incidentsavailability - 73
You get an empty Grafana instance for a service. Which dashboards do you build first, and around which signals?
monitoring - 74
How does Prometheus collect metrics, and when do counters, gauges, and histograms each apply?
monitoringdistributions - 75
Why must you apply rate() to a Prometheus counter before averaging or summing across instances, and what does rate() actually compute?
monitoring - 76
Symptom-based versus cause-based alerts: which should page a human, and how do you fight alert fatigue?
alerting - 77
Design the logging pipeline for a dozen services: what happens between a log line and a searchable event?
loggingci-cddesign - 78
What problem does distributed tracing solve that logs and metrics cannot, and what does adopting it actually require?
decision-makingdistributedmonitoring - 79
Latency p99 doubled since yesterday but error rate is flat. How do you localize the problem with observability tools?
latencyobservability - 80
A service must meet 99.9 percent availability. Walk me through choosing SLIs and using an error budget in practice.
reliability - 81
Metrics, logs, and traces each cost money and attention. How do you decide which signal answers which question?
monitoring - 82
Beyond application metrics, what infrastructure-level monitoring has saved you, and what silent failures does it catch?
monitoring - 83
What belongs in a runbook for an on-call engineer, and what makes most runbooks useless at 3 am?
on-callrunbooks - 84
How do you structure an on-call handoff so the next engineer is not blindsided?
on-call - 85
Explain blue-green deployment: mechanics, what it buys you, and where it hurts.
deployment-strategiesdeployment - 86
How does a metrics-driven canary deployment work, and what makes a canary analysis trustworthy?
deploymentmonitoringdeployment-strategies - 87
When is recreate deployment strategy actually the right choice, despite guaranteeing downtime?
deployment - 88
How do feature flags change the deployment picture, and what operational debt do they create?
deploymentfeature-flags - 89
Walk me through the first fifteen minutes after a production-down alert fires.
alerting - 90
What makes a postmortem genuinely blameless and actually useful, beyond the document existing?
incidents - 91
How do you classify incident severity, and what does the classification actually change?
classificationincidentsseverity-priority - 92
Production breaks right after your deploy. Rollback seems obvious, but when is rolling back the wrong move, and how do you decide fast?
deploymentrollback - 93
What turns a quick bash script into a production-safe one? Name the specific practices.
bash - 94
The same configuration value must exist in Terraform, Kubernetes manifests, and application env files. How do you prevent them from drifting apart?
kubernetesterraformconfig - 95
How do you identify which manual work to automate first, and when is automation the wrong answer?
- 96
A developer says deployment failures are your problem because you own the pipeline. The failures are broken tests in their code. How do you handle this?
deploymentci-cdsoft-skills - 97
Product pressure demands a release Friday evening before a holiday weekend. The change is nontrivial. What do you do?
- 98
You are paged at 3 am for the fourth night by the same alert, each time no action was needed. What do you do beyond silencing it?
alerting - 99
You believe the team should adopt GitOps, but colleagues are comfortable with the current push-based deploys. How do you drive the change without breaking trust?
deploymentgitopsdecision-making - 100
After a painful incident, management wants someone held accountable. How do you protect the blameless culture while still ensuring accountability?
incidents