Skip to content

Install Gitlab CE on Kubernetes

Are you looking to streamline your CI/CD pipeline and improve collaboration across your development teams? Deploying GitLab on Kubernetes can help you achieve these goals and more. In this step-by-step tutorial, I will walk you through everything you need to know to get started with GitLab on Kubernetes.

Prerequisites

To complete this tutorial, you must have the following:

  • Virtual Machine running Ubuntu Linux
  • Domain, and ability to modify DNS records.

DNS

You will need to make sure that the below DNS entries are made prior to attempting to install Gitblab CE. These DNS entries will be used to create TLS Certificates for your installation.

  • gitlab.dev.dman.cloud
  • minio.dev.dman.cloud
  • registry.dev.dman.cloud
  • kas.dev.dman.cloud

Create Kubernetes Cluster

Run from shell prompt
1
2
3
4
5
6
7
8
sudo bash
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server" sh -s - --disable traefik
exit 
mkdir .kube
sudo cp /etc/rancher/k3s/k3s.yaml ./config
sudo chown dmistry:dmistry config
chmod 400 config
export KUBECONFIG=~/.kube/config

Install MetalLB (LoadBalancer) - Optional Step

Run from shell prompt
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.9/config/manifests/metallb-native.yaml
Next we need to configure MetalLB
Run from shell prompt
vim IPAddressPool.yaml

Copy and Paste the below remembering to change you network range below
1
2
3
4
5
6
7
8
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: first-pool
  namespace: metallb-system
spec:
  addresses:
  - 192.168.1.18/32
Run from shell prompt
vim L2Advertisement.yaml
Copy and Paste the below
1
2
3
4
5
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: gitlab-ce
  namespace: metallb-system
Apply the configuration
kubectl apply -f IPAddressPool.yaml
kubectl apply -f L2Advertisement.yaml

Install Helm

Run from shell prompt
1
2
3
4
5
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
sudo apt-get install apt-transport-https --yes
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm

Install Gitlab CE

Add the GitLab Helm repository

Run from shell prompt
helm repo add gitlab https://charts.gitlab.io/
helm repo update
Install the gitlab chart
1
2
3
4
5
6
helm install gitlab gitlab/gitlab \
  --timeout 600s \
  --set global.hosts.domain=dev.dman.cloud \
  --set certmanager-issuer.email=dinesh@dman.cloud \
  --set global.edition=ce \
  --set postgresql.image.tag=13.6.0

Fetch Initial Password

Run from shell prompt
kubectl get secret gitlab-gitlab-initial-root-password -ojsonpath='{.data.password}' | base64 --decode ; echo