GitLab provides a complete CI/CD toolchain in a single application. One interface. One conversation. One permission model. Thousands of features. GitLab simplifies DevOps by providing everything you need to build, test, deploy, and monitor your applications in one place.
- Duration: 15-30 minutes
- Requirements: Your Docker daemon should have at least 12GB RAM
- GitLab: 6GB
- Minikube: 2GB
- Operating System: 2GB
- Process: We'll bring up the Docker daemon and Minikube, then deploy GitLab on top of Minikube using Helm
bash docker/docker.sh
bash minikube/minikube.sh
bash gitlab/gitlab.sh
vagrant up --provision-with basetools,docker,docsify,minikube,gitlab
docker compose exec hashiqube /bin/bash
bash hashiqube/basetools.sh
bash docker/docker.sh
bash docsify/docsify.sh
bash minikube/minikube.sh
bash gitlab/gitlab.sh
During the installation, you can monitor progress via the Kubernetes Dashboard once Minikube is installed. Initially, you'll see some red indicators as GitLab pods and services start up, which will gradually turn green as the deployment completes.
- Kubernetes Dashboard: http://localhost:10888/
The GitLab provisioning process will look like this:
Once installation is complete, you can access GitLab at:
- URL: http://localhost:5580
- Username:
root
- Password: The password is printed in the terminal output
- Example:
jMh629reoQ7FqtillBmLQZPY69JUStSFATXD11T5wMk39NtNezqIKohcIIwoxwvl
- Example:
After logging in, you'll see the GitLab dashboard:
- Click on Create a Project → Create a Blank project
- Enter the project name as
test
- Select the namespace as
root
- Make it a Public repository
- Click Create Project
Once created, you'll see your new repository:
To clone the repository using SSH, you need to add your SSH key to GitLab:
- Click on your profile icon in the top left corner
- Select Preferences
- Navigate to SSH Keys in the sidebar
-
On your local machine, retrieve your public SSH key:
cat ~/.ssh/id_rsa.pub
-
Copy the key and paste it into the GitLab SSH key field
-
Important: Remove the expiry date
-
Click Add Key
After adding the key:
- Navigate back to your test project
- Click the Clone button
- Copy the Clone with SSH URL
⚠️ Note: The HTTP link doesn't work correctly due to a bug with the port configuration. Use SSH instead.
-
Clone the repository:
git clone ssh://git@localhost:32022/root/test.git
-
In your local repository, create a
.gitlab-ci.yml
file:cd test nano .gitlab-ci.yml
-
Add the following pipeline configuration:
variables: REPOSITORY_URL: xxxxxxxxxxxxx.dkr.ecr.eu-west-1.amazonaws.com/container stages: - test - build - dev - stg - prd test: stage: test script: - echo 'Here you can run tests' build: stage: build script: - echo 'After Test stage was successful, here you can run build your container' dev: stage: dev script: - echo 'After Build stage was successful, here you can run your Development environment deployment' stg: stage: stg script: - echo 'After Dev stage was successful, here you can run your Staging environment deployment' prd: stage: prd script: - echo 'After Stg stage was successful, here you can run your Production environment deployment'
-
Commit and push the changes:
git add .gitlab-ci.yml git commit -am "adding .gitlab-ci.yml pipeline file" git push
After pushing, you'll see the file in your repository:
- In your project, navigate to Settings → CI/CD
- Expand the Runners section
- Click New Project Runner
- In the configuration form, check Run Untagged Jobs
- Click Create Runner
⚠️ Note: Due to a known bug, you might be redirected to a blank page. If this happens, manually add:5580
to the URL:Instead of: http://localhost/root/test/-/runners/1/register?platform=linux
Use: http://localhost:5580/root/test/-/runners/1/register?platform=linux
-
Copy the registration command, but remember to add the port
:5580
:Incorrect:
gitlab-runner register --url http://localhost --token glrt-NRYUnqLZ2yzyutC1MYVV
Correct:
gitlab-runner register --url http://localhost:5580 --token glrt-NRYUnqLZ2yzyutC1MYVV
-
SSH into your HashiQube instance:
vagrant ssh
-
Register the runner with the corrected command
-
Start the runner:
gitlab-runner run
- Return to GitLab to see the confirmation:
- Click Go to the Runners page to see your registered runner:
- Navigate to Build → Pipelines in the left sidebar
- You'll see your pipeline is running:
- To see job details, navigate to Jobs in the left sidebar and click on a job:
- GitLab Documentation
- GitLab Runner Documentation
- GitLab with Docker
- GitLab CI/CD Pipeline Configuration
The GitLab environment is set up using this script:
#!/bin/bash
# Print the commands that are run
set -x
# Stop execution if something fails
set -e
# This script provisions Gitlab on Minikube
# Check if kubectl exists
if ! [ -x "$(command -v kubectl)" ]; then
echo 'kubectl is not installed, please install minikube first" >&2'
exit 1
fi
if ! [ -x "$(command -v helm)" ]; then
echo 'helm is not installed, installing it ...' >&2
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
rm -f get_helm.sh
fi
# Check if Minikube environment exists
if ! [ -x "$(minikube status | grep Running)" ]; then
echo 'Minikube is not running, starting it up ...' >&2
# Start Minikube
minikube start
fi
# Get the IP of the Minikube instance to allow access to Gitlab ports
MINIKUBEIP=$(minikube ip)
echo "Minikube is running at $MINIKUBEIP"
# Clean up
function clean_up {
NAMESPACE=gitlab
kubectl delete namespace $NAMESPACE
helm uninstall gitlab
echo "Successfully cleaned up $NAMESPACE namespace and gitlab helm release"
}
if [ "$1" == "clean" ] || [ "$1" == "delete" ] || [ "$1" == "destroy" ] || [ "$1" == "cleanup" ]; then
clean_up
exit 0
fi
# Get IP for Hashiqube
HOSTIP=$(hostname -I | awk '{print $2}')
if [[ -z "$HOSTIP" ]]; then
HOSTIP=$(hostname -I | awk '{print $1}')
fi
# Add the GitLab Helm repository
helm repo add gitlab https://charts.gitlab.io/
helm repo update
# Install GitLab using Helm
helm upgrade --install gitlab gitlab/gitlab \
--timeout 600s \
--set global.hosts.domain=local \
--set global.hosts.externalIP=$HOSTIP \
--set global.edition=ce \
--set [email protected] \
--set nginx-ingress.enabled=false \
--set global.ingress.enabled=false \
--set global.ingress.configureCertmanager=false \
--set gitlab-runner.install=true
# Wait for deployment to complete
echo "Waiting for GitLab deployment to complete..."
sleep 10
# Get the root password
ROOT_PASSWORD=$(kubectl get secret gitlab-gitlab-initial-root-password -ojsonpath='{.data.password}' | base64 --decode ; echo)
# Get the service ports
GITLAB_SSH_PORT=$(kubectl get service gitlab-gitlab-shell -ojsonpath='{.spec.ports[0].nodePort}')
GITLAB_HTTP_PORT=$(kubectl get service gitlab-webservice-default -ojsonpath='{.spec.ports[0].nodePort}')
# Forward ports for easy access
echo "Forward ports for easy access"
echo "kubectl port-forward svc/gitlab-webservice-default 5580:8080 &"
echo "kubectl port-forward svc/gitlab-gitlab-shell 32022:22 &"
kubectl port-forward svc/gitlab-webservice-default 5580:8080 > /dev/null 2>&1 &
kubectl port-forward svc/gitlab-gitlab-shell 32022:22 > /dev/null 2>&1 &
echo "GitLab is now running!"
echo "Access the web UI at http://localhost:5580"
echo "Login with username: root and password: $ROOT_PASSWORD"
echo "You can use SSH with port $GITLAB_SSH_PORT"
echo "You can use HTTP with port $GITLAB_HTTP_PORT"