How We Saved on Cloud Costs by Using Old Hardware for Ephemeral Workloads

Using an Old MacBook Pro 15-inch (Mid 2012) as a GitLab Runner: A Step-by-Step Guide to Upgrading to macOS Sonoma and Configuring as a GitLab Runner with Docker Support

Although cloud computing has advantages, multiple companies are moving away from cloud services (i.e. “Cloud Repatriation”) for various reasons; mainly due to unrealized benefits and cost control. They may end up moving away in whole, fully operating on-premises, or part to a hybrid setup where some select services are running on-premises but still keep some cloud servers for scalability and flexibility.

We are in the same position where we have some services that do not need to run 24/7 and do not need to have persistent states (i.e. ephemeral). In particular, our runners for GitLab CI, that is responsible for building and deploying software we push to the repository, is doing nothing most of the time, but suddenly needing computing resources when something needs to be built, which happens, at most, ten times a day. So theoretically, we can save costs by running the server only when it’s needed.

The problem, however, is while many cloud computing services can scale up to accommodate more workloads with low effort, very few can “scale to zero” where one is charged nothing when nothing is running, especially when doing it automatically. This is especially challenging for GitLab Runners, because they ping the server to update the server on their availability, rather than the server pinging them. This means that we cannot have the runners turn themselves off and on in response to workload in a straightforward manner.

So we opted to instead have our runners on-premises by transforming old hardware, in this instance an old MacBook Pro, into a dedicated (or a backup) GitLab Runner. This breathes new life into hardware that may otherwise be considered outdated and is a cost-effective approach that saves significant expenses compared to using cloud runners in services like Google Cloud or AWS.

The rest of the article describes how to update a MacBook Pro 15-inch Mid 2012 to macOS Sonoma using OpenCore Legacy Patcher[Link], and then set it up as a GitLab Runner with the latest Docker Engine.

It’s important to note that the original operating system (MacOS Catalina) on these models does not support the latest Docker Engine due to compatibility issues.

Step 1: Preparing Your MacBook Pro

Before proceeding, ensure you have a full backup of your data. Updating the OS using OpenCore Legacy Patcher involves risks, including potential data loss.

  1. Check Compatibility: Verify that your MacBook Pro model is compatible with the OpenCore Legacy Patcher. In our case, the Macbook Pro 15 inch 2012 is compatible.
  2. Download OpenCore Legacy Patcher: Go to the OpenCore Legacy Patcher official website and download the latest version suitable for macOS Sonoma.

Step 2: Creating a Bootable USB Drive

  1. Format a USB Drive: Insert a USB drive (at least 16 GB) and use Disk Utility to format it as “Mac OS Extended (Journaled)” with a GUID Partition Map.
  2. Create Bootable Installer: Follow the OpenCore Legacy Patcher instructions to create a bootable macOS Sonoma installer on your USB drive.

Step 3: Installing macOS Sonoma with OpenCore

  1. Boot from USB: Restart your MacBook Pro while holding the Option key to open the startup manager. Select the USB drive.
  2. Install macOS Sonoma: Follow the on-screen instructions to install macOS Sonoma. This process may take some time.

Step 4: Post-Installation Setup

Mac OS Sonoma in a 2012 15 inch Macbook Pro

After installing macOS Sonoma, run the OpenCore Legacy Patcher post-install tool to ensure all drivers and patches are correctly applied for your MacBook Pro.

Step 5: Configuring GitLab Runner

With macOS Sonoma installed, you can now set up your MacBook Pro as a GitLab Runner.

  1. Install Homebrew: If not already installed, open Terminal and run the following command to install Homebrew:
ShellScript
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
ShellScript

2. Install GitLab Runner: Use Homebrew to install GitLab Runner:

ShellScript
brew install gitlab-runner
ShellScript

3. Configure GitLab Runner: Register your GitLab Runner with your GitLab instance:Follow the prompts to complete the registration, including specifying your GitLab URL and registration token.

ShellScript
gitlab-runner register
ShellScript

Step 6: Installing Docker Engine

Due to the original OS’s limitations, installing the latest Docker Engine requires macOS Sonoma.

  1. Install Docker: Use the following Homebrew command to install Docker:
ShellScript
brew install --cask docker
ShellScript
  1. Start Docker: Open the Docker application from your Applications folder to start Docker.
  2. Verify Installation: Run docker --version in Terminal to verify the installation.

Step 7: Additional Options

Use a wired connection:

For a stable and reliable network connection, especially important during continuous integration tasks that require constant connectivity, consider using a wired connection.

How does it perform?

It is showing its age.

Using the MacBook Pro Mid 2012 with 16GB RAM as a GitLab Runner, it’s observed that a typical job builds in approximately 2 minutes and 27 seconds.

For comparison, a cloud machine equipped with an AMD CPU and 64GB RAM completes the same job in about 27 seconds. While the MacBook Pro’s performance is noticeably slower, it may still serve as a viable backup GitLab Runner for tasks that do not demand fast build times.

Conclusion

Even though cloud computing is flexible and scalable, many companies, including us, are looking to move some services back from the cloud to save on costs and improve efficiency. For instance, things like GitLab CI runners, which aren’t used all the time, could save money if they were managed in-house. Furthermore, by repurposing old technology, we are able to have a sustainable way for computing.

Bonito Tech can help with this transition. We offer specialized system administration services tailored to help companies like yours move smoothly to managing things on-site, or even if you decide to stay in the Cloud, we have experienced people to help you. Our experts in Kubernetes and Google Cloud Platform (GCP) can design, set up, and maintain your in-house infrastructure, making sure it’s secure, performs well, and stays running smoothly. Contact us today to get started.