Skip to content
$ lynuxpro

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 1–15 of 20 questions

Learn GitLab CI/CD →
1.What is the difference between a pipeline, a stage and a job?Beginner

A job is a list of commands that runs in a fresh environment and passes or fails. A stage is a group of jobs that run at the same time. A pipeline is one run of all the jobs for one commit. Stages run in order, and the next stage starts only when every job in the stage before it passed.

2.What is a GitLab runner?Beginner

A program that runs the jobs. It connects out to GitLab, asks for work, runs each job (usually in a Docker container or a Kubernetes pod) and sends back the log and artifacts. GitLab.com gives you shared runners; companies often run their own for speed, cost, special hardware or access to private networks.

3.What is the difference between artifacts and cache?Beginner

Artifacts pass a job's results (like a dist/ folder or a test report) to later jobs, and they must be there. Cache keeps downloaded packages (like .npm/) between pipelines to save time, and it may be missing. If a job would be wrong without the files, use artifacts; if it would only be slower, use cache.

4.How do you keep secrets out of your pipeline code?Beginner

Store them as CI/CD variables in Settings, marked masked (hidden in logs) and protected (only given to protected branches). Never commit them. For cloud access, prefer short-lived OIDC tokens (id_tokens) or a secret manager like Vault, so nothing long-lived is stored at all.

5.What is a merge request, and what happens when you write 'Closes #12' in one?Beginner

A merge request asks to merge one branch into another. It shows the changes, the pipeline result, approvals and security findings. 'Closes #12' links issue #12 and closes it automatically when the MR is merged into the default branch.

6.Why use npm ci instead of npm install in CI?Beginner

npm ci installs exactly the versions in package-lock.json and fails if the lock file is out of date. npm install can quietly change versions. In CI you want every build to be the same.

7.Your merge request pipeline is missing some jobs. What is the most likely cause?Mid

Jobs without rules don't run in merge request pipelines (their old default only covers branches and tags). Add rules to them, for example rules: - when: on_success, or rules that match merge_request_event. Also check workflow: rules, which can filter out the whole pipeline.

8.How do you stop getting two pipelines (branch and merge request) for one push?Mid

Use workflow: rules. Run a pipeline for merge request events, skip branch pipelines when the branch has an open MR ($CI_OPEN_MERGE_REQUESTS), and keep branch pipelines otherwise. GitLab ships this as the Workflows/MergeRequest-Pipelines template.

9.What does needs do, and when would you use it?Mid

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.

10.A job is stuck in pending. How do you debug it?Mid

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?

11.How do you build a Docker image inside a GitLab job?Mid

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.

12.How do you set up review apps, and how do they get cleaned up?Mid

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.

13.How do you deploy to Kubernetes from GitLab without storing a cluster password?Mid

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.

14.How do you share CI configuration across many projects?Mid

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.

15.A pipeline takes 25 minutes. How would you make it faster and cheaper?Senior

Measure first: wall time (what people wait) and total job time (what you pay), per job, from CI/CD analytics or the API. Then: needs to remove waiting, a dependency cache keyed on the lock file with pull policy for readers, smaller images, rules: changes to skip unneeded jobs, parallel for long test suites, Docker layer caching, interruptible plus auto-cancel for old commits, artifact expiry, and right-sized or spot autoscaled runners.