DEV Community

Cover image for My Journey Upgrading GitLab and GitLab Runner on AWS EC2
marocz
marocz

Posted on

My Journey Upgrading GitLab and GitLab Runner on AWS EC2

Introduction

Recently, I embarked on the journey of upgrading our GitLab server and GitLab Runner hosted on an AWS EC2 instance. Though the process is documented, there's nothing like hands-on experience to understand the nuances. In this article, I'll share my step-by-step approach, the challenges I faced, and the commands that saved my day!

📦 Prerequisites:

  • An EC2 instance with GitLab already humming along.
  • A GitLab runner, tirelessly building and testing our projects.
  • Trusty SSH access to the EC2 instance.

🛡️ Step 1: Backing Up Data

Before diving into the upgrade, I made sure to backup. Can't stress this enough!

GitLab:

sudo gitlab-rake gitlab:backup:create
Enter fullscreen mode Exit fullscreen mode

GitLab Runner:

Backing up the runner configuration was a breeze:

cp /etc/gitlab-runner/config.toml ~/gitlab-runner-config-backup.toml
Enter fullscreen mode Exit fullscreen mode

🚀 Step 2: Upgrading the GitLab Server:

Checking Available Versions:
My curiosity led me to check which versions were available:

sudo yum list available gitlab-ce --showduplicates | sort -r
Enter fullscreen mode Exit fullscreen mode

Updating Repository Information:

Ensuring I had the latest repository info was crucial:

https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
Enter fullscreen mode Exit fullscreen mode

The Actual Upgrade:

Choosing the desired version, I proceeded:

sudo yum install gitlab-ce-<version_number>
Enter fullscreen mode Exit fullscreen mode

Verification:
Post-upgrade, I had to ensure everything was in order:

sudo gitlab-rake gitlab:env:info
Enter fullscreen mode Exit fullscreen mode

🏃 Step 3: Upgrading the GitLab Runner:

Repository Update:
A quick refresh of the repository information:

curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
Enter fullscreen mode Exit fullscreen mode

Runner Upgrade:
With a leap of faith:

sudo yum install gitlab-runner
Enter fullscreen mode Exit fullscreen mode

🔍 Step 4: Verifying the GitLab Runner Upgrade:

I made sure the runner was back on its feet:

sudo gitlab-runner restart
sudo gitlab-runner status
Enter fullscreen mode Exit fullscreen mode

🚒 Step 5: Potential Rollback:

Though everything went smoothly, I was prepared for a rollback:

GitLab:

sudo gitlab-rake gitlab:backup:restore BACKUP=<backup timestamp>
Enter fullscreen mode Exit fullscreen mode

GitLab Runner:

cp ~/gitlab-runner-config-backup.toml /etc/gitlab-runner/config.toml
sudo gitlab-runner restart
Enter fullscreen mode Exit fullscreen mode

🌟 Conclusion:

My adventure upgrading GitLab and GitLab Runner on AWS EC2 was both challenging and rewarding. While the process is generally straightforward, it's the small nuances that make the experience unique.

To all the DevOps enthusiasts out there, always backup, stay updated, and happy coding!

Top comments (0)