INTERVIEW PREP
Interview questions
570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.
Showing 61–75 of 188 questions
61.What does needs do, and when would you use it?MidGitLab CI/CD
needs lets a job start as soon as the jobs it lists are done, instead of waiting for whole earlier stages. needs: [] starts a job right away. Use it to run tests and lint at the same time as the build, which can cut pipeline time a lot. Jobs only download artifacts from the jobs they need.
62.A job is stuck in pending. How do you debug it?MidGitLab CI/CD
Check: does any online runner have all of the job's tags? Is the job untagged while no runner takes untagged jobs? Is the only matching runner protected while this is a feature branch? Is the runner offline or paused (gitlab-runner status, Settings > CI/CD > Runners)? Or are all runners simply busy?
63.How do you build a Docker image inside a GitLab job?MidGitLab CI/CD
The docker command needs a daemon, which a job container doesn't have. Options: a docker:dind service (needs a privileged runner), binding the host's Docker socket (fast but unsafe on shared runners), or a daemonless builder like BuildKit rootless or Buildah. Log in with CI_REGISTRY_USER and CI_REGISTRY_PASSWORD using --password-stdin, and tag images with the commit ID.
64.How do you set up review apps, and how do they get cleaned up?MidGitLab CI/CD
A deploy job with environment: name: review/$CI_COMMIT_REF_SLUG and its own URL runs for each merge request. Its on_stop names a stop job with the same environment and action: stop, which GitLab runs when the MR is merged or the branch is deleted. auto_stop_in: 1 week removes forgotten ones.
65.How do you deploy to Kubernetes from GitLab without storing a cluster password?MidGitLab CI/CD
Use the GitLab agent for Kubernetes. It runs in the cluster and connects out to GitLab. Its config file grants ci_access to chosen projects, which then get a kube context in their jobs (kubectl config use-context group/project:agent). For production, set protected_branches_only: true so only protected branches can deploy.
66.How do you share CI configuration across many projects?MidGitLab CI/CD
Put shared jobs in a central project and include them with include: project, pinned to a tag. Better for new work: CI/CD components with typed inputs, published in the CI/CD Catalog. Inside a file, use hidden jobs with extends and !reference. Check the result with glab ci config compile.
67.How do you make jobs run in order?MidGitHub & GitHub Actions
Use needs. A job with needs waits for the listed jobs to pass. Without it, jobs run in parallel.
68.How do you pass data between jobs?MidGitHub & GitHub Actions
Declare outputs on the producing job, write them to $GITHUB_OUTPUT in a step, and read them in the next job with needs.<job>.outputs.<name>. For files, use artifacts.
69.What is the difference between secrets and variables?MidGitHub & GitHub Actions
Secrets hold private values, are masked in logs and cannot be read back. Variables hold ordinary settings and are visible.
70.What does branch protection do and why does it matter?MidGitHub & GitHub Actions
It sets rules for important branches: pull requests, approvals, passing checks and no force pushes. It keeps main safe and enforces your review process.
71.How does caching speed up a workflow?MidGitHub & GitHub Actions
Dependencies are saved under a key, usually a hash of the lock file. When the key matches, they are restored instead of downloaded again.
72.When do you use a matrix?MidGitHub & GitHub Actions
When the same job must run with several settings, like Node versions or operating systems. It creates one job per combination, running in parallel.
73.What is the difference between artifacts and cache?MidGitHub & GitHub Actions
A cache speeds up repeated downloads and may be evicted. Artifacts are files from a run that you pass to other jobs or keep for download.
74.What is a merge conflict and how do you fix it?MidGitHub & GitHub Actions
It happens when two branches changed the same lines, so Git cannot choose. Git marks the lines in the file. You keep the right version, remove the marker lines, then add and commit.
75.How do you make images smaller and builds faster?MidDocker
Use multi-stage builds, a small base (slim, distroless, alpine where appropriate), order instructions so rarely changing layers come first, use .dockerignore, and combine package install and cleanup in one RUN.