Building a Kubernetes Development Cloud with Raspberry Pi 4, Synology NAS and OpenWRT – Part 7 – Installing Gitlab and the Gitlab Runner

This is the seventh article in a series covering detailing building a Raspberry Pi Kubernetes development cluster. In the first 6 parts we have covered tting the cluster ready to run applications. In this article we will deploy Gitlab and the Gitlab Runner. We will also install PostgreSQL reduce the footprint of the Gitlab pod and make it easier to run on the cluster.

PostgreSQL

Because Gitlab will use Postgres to store it’s data we will first need to install Postgres. Lets start by creating a namespace. Create a gitlab-namespace.yaml file ina new directory with the following content

Apply the file to the cluster

Next lets set up a persistent volume for Postgres using the Synology CSI driver to automatically provision a LUN on the NAS. create postgres-pvc.yml. Create these files in a subdirectory named “postgres”

We can take regular snapshots of this volume too using the automated volume snapshotter. Add the file postgres-snapshot.yml

Next we will add a config map to store the database connection details. postgres-configmap.yml

Create a service to expose the postgres deployment. postgres-service.yml

And finally create the deployment. postgres-deployment.yml

With all the manifests in the directory postgres, you can apply them all at once like this

Gitlab

Now that we have a postgres deployment we can deploy Gitlab to the cluster. Be warned it takes quite a while for Gitlab to get up and running. Be patient.

Before we start, we are going to need a certificate that is generated by a trusted root certificate authority. If you have followed the guides so far your DNS resolution, network ingress and the cert manager deployment are all in place for this to work.

This certificate will need to be valid for 2 domains. First the domain on which Gitlab it’s self will respond and second a domain name for the container registery service.

Create a gitlab-certificate.yml file in a new gitlab directory

Apply this file to the cluster, and wait for the certificate to generate

Once the certificate is ready we can create the rest of the manifests in the gitlab directory

We will start with the persistent volume claim again. Create gitlab-storage.yml

gitlab-snapshot.yml

Next create the gitlab-deployment.yml file (note the use of the arm56 image)

gitlab-service.yml

Finally we need to create the configuration file. In this file be sure to use the username and password you set on your postgres deployment, and ensure you are using the same domain names you registered in your certificate.

gitlab-ingress.yml

You can now deploy gitlab to your cluster

Once the deployment goes green/ready you will still have to wait some time for Gitlab to actually become available. Once it does it will be accessible over HTTPS and publicly available. You should navigate to it right away, change the admin password and begin setting it up to your tastes.

Gitlab Runner

Now that we have Gitlab installed on the cluster, we can start to store the manifests we have created so far in source control repositories. This gives us somewhere safe to store the code that deploys the cluster. But we can also take it one step further and uses Gitlab’s built in CI/CD tooling to deploy the manifests to the cluster so that any time we commit a change to our manifests to source control, Gitlab (running on the cluster) will automatically update the cluster.

To achieve this we are going to deploy the Gitlab runner using helm, but first we need to get a few things ready. Lets start with the Helm values file. Create a file called gitlab-runner-chart-value.yml

Leave a Reply

Your email address will not be published. Required fields are marked *