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 151–165 of 570 questions

151.How do you keep secrets out of your pipeline code?BeginnerGitLab CI/CD

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.

152.What is a merge request, and what happens when you write 'Closes #12' in one?BeginnerGitLab CI/CD

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.

153.Why use npm ci instead of npm install in CI?BeginnerGitLab CI/CD

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.

154.Your merge request pipeline is missing some jobs. What is the most likely cause?MidGitLab CI/CD

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.

155.How do you stop getting two pipelines (branch and merge request) for one push?MidGitLab CI/CD

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.

156.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.

157.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?

158.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.

159.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.

160.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.

161.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.

162.A pipeline takes 25 minutes. How would you make it faster and cheaper?SeniorGitLab CI/CD

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.

163.How would you make sure every project in the company runs secret detection, even if a team removes it?SeniorGitLab CI/CD

Use security policies from a security policy project linked to the top group. A scan execution policy forces secret detection in every pipeline, and projects can't turn it off. A merge request approval policy blocks merges with new critical or high findings until the security team approves. Pipeline execution policies can add other required jobs. Scope policies to compliance frameworks where needed.

164.How do you protect production in GitLab end to end?SeniorGitLab CI/CD

Several layers: protected main and tags; merge checks (pipeline must pass, threads resolved) and approval rules with CODEOWNERS; protected variables for production secrets; protected runners or a protected-branch-only Kubernetes agent; protected environments with deployment approvals; resource_group for one deploy at a time; and audit events streamed to a SIEM.

165.What must a self-managed GitLab backup include, and how do you restore it?SeniorGitLab CI/CD

gitlab-backup create saves the database, repositories, uploads, artifacts, packages and more. It does not include /etc/gitlab/gitlab.rb and gitlab-secrets.json; copy those separately and keep them safe, because without gitlab-secrets.json encrypted data like CI/CD variables and runner tokens can't be read. To restore: same GitLab version, stop puma and sidekiq, gitlab-backup restore BACKUP=ID, put back the config files, reconfigure, restart, and run gitlab-rake gitlab:check. Practise restores regularly.