Find Interview Questions for Top Companies
Ques:- What are IAM roles in GCP and how do you manage permissions?
Right Answer:

In Google Cloud Platform (GCP), IAM (Identity and Access Management) roles define what actions a user or service account can perform on resources.

There are 3 types of IAM roles:

  1. Basic Roles: Broad permissions (e.g., Viewer, Editor, Owner).

  2. Predefined Roles: Granular roles created by GCP for specific services (e.g., Storage Admin, Compute Viewer).

  3. Custom Roles: User-defined roles with selected permissions.

To manage permissions:

  • Assign roles to users, groups, or service accounts at the project, folder, or resource level.

  • Use the IAM policy binding (gcloud projects add-iam-policy-binding) or the GCP Console.

  • Follow the principle of least privilegeโ€”grant only the minimum permissions needed.

Roles ensure secure and controlled access to GCP resources.

Ques:- Whatโ€™s your experience using GitLab in a GitOps or DevSecOps workflow?
Right Answer:

In GitOps:

  • Used GitLab as the single source of truth for infrastructure as code.

  • Implemented CI/CD pipelines to auto-deploy to Kubernetes clusters using tools like ArgoCD or Flux.

  • Managed environment states entirely through version-controlled Git repositories.

In DevSecOps:

  • Integrated GitLabโ€™s built-in security features (SAST, DAST, dependency scanning, secret detection) into pipelines.

  • Enforced security checks before merge approvals.

  • Used GitLab CI/CD to automate compliance and vulnerability checks throughout the development lifecycle.

Overall, GitLab streamlined the deployment and security process through automation and transparency.

Ques:- How would you troubleshoot a failed GitLab CI pipeline?
Asked In :- Twilio, EvolveWare,
Right Answer:

To troubleshoot a failed GitLab CI pipeline:

  1. โœ… Check the pipeline/job logs for error messages.

  2. ๐Ÿ”„ Verify the .gitlab-ci.yml syntax and job dependencies.

  3. ๐Ÿ” Confirm required environment variables and secrets exist.

  4. ๐Ÿงช Test failing commands locally to reproduce the issue.

  5. ๐Ÿ“ฆ Ensure runners have necessary tools and permissions.

  6. ๐Ÿ” Retry the job or pipeline after fixing identified problems.

Ques:- Whatโ€™s the difference between only, except, rules, and when in GitLab CI?
Asked In :- Technologics, wallethub,
Right Answer:
  • only: Run job only for specified conditions (e.g., branches).

  • except: Skip job for specified conditions.

  • rules: More advanced, flexible replacement for only/except.

  • when: Controls job timing (e.g., manual, always, on_success).

Ques:- What are GitLab Auto DevOps and how do they work?
Right Answer:

How It Works:

  1. Detection: GitLab detects your projectโ€™s language and framework automatically.

  2. CI/CD Pipeline: It auto-generates .gitlab-ci.yml using predefined CI templates.

  3. Build: Builds a Docker image using Auto Build.

  4. Test: Runs auto-generated tests.

  5. Code Quality & SAST: Runs code quality analysis and security scans.

  6. Review App: Deploys temporary environments for each merge request.

  7. Deploy: Auto-deploys to Kubernetes using Helm charts.

  8. Monitor: Provides performance metrics and logging if integrated.

๐ŸŸข Requirements:

  • Kubernetes cluster connected to GitLab

  • GitLab Runner

  • Enable Auto DevOps in project settings

Ques:- How do you integrate GitLab with Jira, Slack, or other tools?
Right Answer:

Jira Integration with GitLab

  • Go to GitLab:
    โ†’ Settings โ†’ Integrations โ†’ Select Jira

  • Enter:

    • Jira URL

    • Project Key

    • Username + API token

  • Enables:

    • Linking GitLab commits/MRs to Jira issues using JIRA-123 in commit messages

    • Jira issue status updates


โœ… Slack Integration with GitLab

  • Go to GitLab:
    โ†’ Settings โ†’ Integrations โ†’ Select Slack notifications

  • Enter:

    • Webhook URL (from your Slack app or channel)

    • Channel name

    • Choose events (push, merge request, pipeline, etc.)

  • Enables:

    • GitLab events trigger messages in Slack channels


โœ… Other Tools (e.g., Trello, Microsoft Teams, Jenkins)

  • GitLab supports integrations via:

    • Webhooks

    • API tokens

    • Custom scripts in .gitlab-ci.yml

    • GitLab Apps/Marketplace

Example webhook:
โ†’ Settings โ†’ Webhooks
โ†’ Add URL of external service and select trigger events

Ques:- How would you implement deployment to Kubernetes using GitLab CI/CD?
Right Answer:

Steps to Deploy to Kubernetes Using GitLab CI/CD:

  1. Connect GitLab to Your Kubernetes Cluster
    โ†’ In your GitLab project:
    Settings โ†’ CI/CD โ†’ Kubernetes
    โ†’ Add your cluster credentials (API URL, CA cert, Token, etc.).

  2. Define .gitlab-ci.yml Pipeline
    Example:

    yaml
    image: bitnami/kubectl:latest

    stages:
    - deploy

    deploy:
    stage: deploy
    script:
    - kubectl config set-cluster my-cluster --server=$KUBE_URL --certificate-authority=$KUBE_CA
    - kubectl config set-credentials gitlab --token=$KUBE_TOKEN
    - kubectl config set-context default --cluster=my-cluster --user=gitlab
    - kubectl config use-context default
    - kubectl apply -f k8s/deployment.yaml

  3. Store Sensitive Variables Securely
    โ†’ Add KUBE_URL, KUBE_TOKEN, and KUBE_CA in GitLab CI/CD variables.

  4. Add Your Kubernetes YAML Files
    โ†’ Add deployment files like deployment.yaml, service.yaml inside a folder (e.g., /k8s).

  5. Optional: Use Helm Charts
    Replace kubectl apply with:

    - helm upgrade --install my-app ./chart

๐Ÿ”’ Make sure access is secure and only CI/CD has permission to deploy.

Ques:- How do you handle secrets and sensitive data in GitLab pipelines?
Asked In :- pragma edge inc,
Right Answer:

To handle secrets in GitLab pipelines:

  1. Use CI/CD Variables
    โ†’ Go to Settings โ†’ CI/CD โ†’ Variables and add secrets (e.g., API keys).

  2. Mask and Protect
    โ†’ Enable Masked (hides in logs) and Protected (only used in protected branches).

  3. Access in .gitlab-ci.yml

    yaml
    script:
    - echo "$MY_SECRET"
  4. Avoid Hardcoding
    โ†’ Never put secrets directly in the pipeline or code.

  5. Use Group Variables
    โ†’ For shared secrets across projects.

  6. Optional: Use Secret Managers
    โ†’ Integrate tools like HashiCorp Vault or AWS Secrets Manager.

Ques:- How can you implement parallel jobs or matrix builds in GitLab?
Right Answer:

In GitLab CI/CD:

-โ€ฏparallel: N runs the same job N times concurrently.
-โ€ฏparallel: matrix: runs jobs with different variable combinations.

Used for faster builds/tests across configs or environments.

Ques:- What is a needs keyword and when would you use it?
Right Answer:

In GitLab CI/CD, the needs keyword defines job dependencies and allows jobs to run earlier by enabling parallel execution when possible.

โœ… Purpose:

It tells GitLab that a job depends on the output of another job.

๐Ÿ”ง Syntax:

build:
stage: build
script: echo "Building"

test:
stage: test
script: echo "Testing"
needs: ["build"] # test needs build to finish

๐Ÿ“Œ When to use:

  • To reduce pipeline time by skipping stage sequencing

  • When jobs in later stages need artifacts/results from earlier jobs

  • For creating DAG-style (Directed Acyclic Graph) pipelines

Ques:- How do you set environment variables in GitLab CI/CD?
Right Answer:

In GitLab CI/CD, you can set environment variables in several ways:

1. ๐Ÿ”ง In the GitLab UI (recommended for secrets)

  • Go to: Project โ†’ Settings โ†’ CI/CD โ†’ Expand Variables

  • Add key-value pairs (e.g., API_KEY = abc123)

  • You can mark them as protected or masked

2. ๐Ÿ“ In .gitlab-ci.yml

variables:
ENV_NAME: "production"
TIMEOUT: "30s"

3. ๐Ÿ“ฆ In job definitions

deploy:
script:
- echo "Deploying to $ENV_NAME"
variables:
ENV_NAME: "staging"

โœ… Tip: Use UI for sensitive values (API keys, tokens) and .gitlab-ci.yml for general config.

Ques:- How do you use artifacts and caches in GitLab pipelines?
Right Answer:

In GitLab CI/CD, you use artifacts and caches to manage files between pipeline jobs:

๐Ÿ”น Artifacts:

  • Used to pass files from one job to another.

  • Saved files after a job finishes (e.g., compiled binaries, test reports).

  • Defined using:

    artifacts:
    paths:
    - build/
    expire_in: 1 hour

๐Ÿ”น Cache:

  • Used to speed up jobs by reusing dependencies (like npm packages, pip installs).

  • Not passed between jobs but stored for reuse.

  • Defined using:

    cache:
    paths:
    - node_modules/

โœ… Use artifacts to share outputs.
โœ… Use cache to reduce build time.

Ques:- Whatโ€™s the difference between shared and specific runners?
Right Answer:

The difference between Shared and Specific Runners in GitLab:

๐Ÿ”น Shared Runners

  • Available to all projects in a GitLab instance.

  • Useful for CI/CD across multiple projects.

  • Maintained by GitLab or an admin.

  • Suitable for general-purpose jobs.

๐Ÿ”น Specific Runners

  • Assigned to a specific project or group.

  • Provide more control over the runner environment.

  • Ideal for jobs that need special dependencies or isolation.

โœ… Use Shared Runners for simplicity.
โœ… Use Specific Runners for customization or security.

Ques:- What are GitLab Runners? What types are there?
Right Answer:

Types of GitLab Runners:

  1. Shared Runners โ€“ Provided by GitLab, available to all projects in an instance.

  2. Specific Runners โ€“ Dedicated to a project or group, gives more control over environment.

Executors used by runners include:

  • Shell

  • Docker

  • Kubernetes

  • SSH

  • Custom

They determine how and where the job runs.

Ques:- How do you trigger a pipeline manually or on specific events?
Right Answer:

In GitLab CI/CD, you can trigger pipelines in several ways:

๐Ÿ”น 1. Manually (From GitLab UI):

  • Go to CI/CD > Pipelines in your project.

  • Click the โ€œRun pipelineโ€ button.

  • You can choose a branch and pass variables.

๐Ÿ”น 2. On Specific Events:

  • push: Automatically triggered on code push.

  • merge_request_events: On merge requests.

  • schedule: Using CI/CD > Schedules to run periodically.

  • tags: Trigger when a tag is pushed.

๐Ÿ”น 3. Via .gitlab-ci.yml Rules:

Use rules, only, or except to specify conditions:

job_name:
script: echo "Triggered"
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

๐Ÿ”น 4. Trigger Token (API):

Use the GitLab API and a trigger token to start pipelines externally:

curl -X POST \
-F token=TRIGGER_TOKEN \
-F ref=main \
https://gitlab.com/api/v4/projects/PROJECT_ID/trigger/pipeline

These options give you flexibility for automation and control over your CI/CD process.

Ques:- What are the stages in a GitLab CI/CD pipeline?
Right Answer:

๐Ÿ”น Common Stages:

  1. build โ€“ Compile or build your application.

  2. test โ€“ Run unit, integration, or other automated tests.

  3. deploy โ€“ Deploy your app to staging or production.

  4. review โ€“ Create review apps for testing in an isolated environment.

  5. cleanup โ€“ Clean up temporary resources or cache.

โœ… You can customize and define any number of stages in your .gitlab-ci.yml file depending on your workflow. Jobs in each stage run in parallel, and stages run sequentially.

Ques:- How does GitLab handle merge requests (MRs)?
Right Answer:

๐Ÿ”น Key Features:

  • Code Review: Team members can review code, comment, and suggest changes.

  • Pipeline Integration: CI/CD pipelines automatically run (e.g. tests, builds) before merging.

  • Approvals: You can set required approvals before allowing merge.

  • Conflict Detection: GitLab checks for merge conflicts automatically.

  • Squash & Merge: Option to squash commits into a single commit on merge.

  • Merge Strategies: Merge commit, fast-forward, or squash merge.

โœ… Summary: MRs ensure quality and collaboration by combining code review, automated testing, and controlled merging.

Ques:- What is the .gitlab-ci.yml file? Whatโ€™s its role in CI/CD?
Right Answer:

๐Ÿ”น Purpose:

It tells GitLab:

  • What jobs to run (e.g., build, test, deploy)

  • When to run them

  • In what order

๐Ÿ”น Key Components:

  • stages: Defines stages like build, test, deploy.

  • jobs: Specific tasks under each stage.

  • script: Commands to execute in a job.

  • rules / only / except: Define when jobs should run.

  • artifacts: Files to pass between jobs or store.

๐Ÿ’ก Summary: It automates your development workflow by defining CI/CD steps in a single YAML file at the root of your repository.

Ques:- How do you manage access control in GitLab?
Right Answer:

In GitLab, access control is managed using:

1. Project & Group Memberships:

  • Users are assigned roles at the project or group level.

2. Role-Based Permissions:

Common roles include:

  • Guest โ€“ limited access (issues, comments)

  • Reporter โ€“ can view and download code

  • Developer โ€“ can push code, create branches

  • Maintainer โ€“ full access, including CI/CD and settings

  • Owner (group level only) โ€“ manage everything, including members

3. Private, Internal, and Public Visibility:

  • Controls who can access the project/repo.

4. Protected Branches and Tags:

  • Limit who can push, merge, or delete branches/tags.

5. Access Tokens:

  • Personal, project, or group access tokens for CI/CD or API use.

These tools together help enforce secure and flexible access policies in GitLab.

Ques:- What are GitLab Groups and Projects? How do they differ?
Asked In :- Webtech Developers,
Right Answer:

In GitLab:

-โ€ฏGroups are containers that organize related projects and manage permissions for multiple users. Think of them like folders or teams.

-โ€ฏProjects are where your actual code, issues, CI/CD pipelines, and settings live.

Key Differences:

Feature Group Project
Purpose Organize and manage multiple projects Store code and configurations for a specific app
Permissions Set roles across multiple projects Set roles for a single project
Inheritance Subgroups and projects inherit permissions No inheritance
CI/CD Sharing Can use shared runners and templates Project-specific pipelines

So, Groups = Organization level, and Projects = Actual work/code.



AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users