Feedback

Chat Icon

Cloud Native CI/CD with GitLab

From Commit to Production Ready

Runners and Executors: The Engines of GitLab CI/CD
75%

Executors: What are They and How to Choose the Right One?

In the next sections, we will see how to create runners using different environments: Shell, Docker, and Kubernetes. These environments are called "executors" in GitLab CI/CD. An executor is responsible for running the jobs in the pipeline. The executor determines the environment in which the jobs are executed.

Runners are the agents that receive the jobs from GitLab. Each runner defines at least one executor, which is the environment where the jobs are executed (e.g., Docker, Shell, Kubernetes).

ℹ️ Executors for Runners are like engines for cars. They determine how the car runs, but they are not the car itself. The car is the Runner, the engine is the Executor.. and you are the driver!

GitLab provides several executors that you can choose from based on your requirements. Here is the list:

  • SSH
  • Shell
  • Parallels
  • VirtualBox
  • Docker
  • Docker Autoscaler
  • Docker Machine (auto-scaling)
  • Kubernetes
  • Instance
  • Custom

SSH Executor

The SSH executor in GitLab provides a straightforward way to execute CI jobs on remote machines through SSH.

It's ideal for scenarios where you need to run jobs on a specific machine with unique configurations or resources not available elsewhere. The SSH executor, while simple, supports only Bash scripts and lacks caching, which might slow down tasks that benefit from reuse of previous outputs.

The executor requires careful setup of SSH authentication, either through passwords or SSH keys, and offers flexibility in how and where jobs are executed. However, its reliance on the stability and availability of the remote server can be a potential drawback.

Shell Executor

We will see the Shell executor in action but let's go through the details first.

The Shell executor is another simple yet powerful tool that runs CI jobs directly on the machine where GitLab Runner is installed. It supports a variety of shell environments including Bash, PowerShell, and Windows Batch, making it versatile across different OSs (MacOS, *nix, MS Windows..etc).

The Shell executor allows for quick job execution since it runs locally, but it also poses significant security risks. Running jobs with this executor could potentially expose the system to vulnerabilities, especially if the jobs are not from trusted sources, as they run with the user's permissions. This makes it suitable only for trusted environments. Additionally, the lack of isolation between jobs could lead to conflicts, especially when different jobs require different system configurations.

Parallels and VirtualBox Executors

Parallels and VirtualBox

Cloud Native CI/CD with GitLab

From Commit to Production Ready

Enroll now to unlock all content and receive all future updates for free.