Setting Up CI/CD Deployment with GitLab Runner in GCP VM
Overview
I am reaching out to seek your assistance in setting up CI/CD deployment with GitLab Runner in a Google Cloud Platform (GCP) virtual machine (VM) using a shell (bash) executor. As per our discussion, I have a self-hosted GitLab instance and I need to deploy code from GitLab to a GCP VM. After researching online, I came across a video you shared at https://www.youtube.com/watch?v=lDMAuTux-Tw, which was informative but seemed to be focused on Kubernetes. I am looking for instructions specifically for a shell-based GCP VM.
I have experience setting up CI/CD on my local Linux box, but I am encountering errors when trying to set it up on GCP. It appears that there might be some missing configurations, and I was hoping to seek your guidance on this.
Based on my research, here are the general steps I followed:
- Set up a virtual machine instance in GCP with a Linux OS of our choice, such as Ubuntu or CentOS, configuring it with the desired machine type, disk size, and other options.
- Install GitLab Runner on the GCP VM by following the official GitLab Runner installation instructions for Linux, including adding the GitLab Runner repository, installing the GitLab Runner package, and configuring the GitLab Runner registration token to connect it to our self-hosted GitLab instance.
- Configure a shell executor in GitLab Runner by specifying "shell" as the executor and configuring other relevant settings in the GitLab Runner configuration file (/etc/gitlab-runner/config.toml), such as the GitLab URL, registration token, and other options as needed.
- Configure our GitLab project to use the GitLab Runner by adding a runner in the CI/CD section of our project settings, using the runner's public IP or hostname and the registration token used during the GitLab Runner setup. This will associate the runner with our project and allow us to trigger CI/CD pipelines.
- Define our CI/CD pipeline in our project's .gitlab-ci.yml file, specifying the stages, jobs, and scripts to be executed during the pipeline. We can use the shell executor to run shell commands, scripts, or other actions to deploy our code to the GCP VM or perform other tasks as needed.
- Trigger the CI/CD pipeline in GitLab manually or automatically based on events such as code pushes or merge requests, as defined in our .gitlab-ci.yml file.
After executing I got an error on the pipeline.