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–8 of 8 questions
Learn GitLab CI/CD →1.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.
2.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.
3.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.
4.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?
5.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.
6.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.
7.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.
8.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.