Apa Itu GitLab
GitLab Official Website adalah platform DevOps yang digunakan untuk:

- Menyimpan source code (Git repository)
- Version control
- CI/CD automation
- Issue tracking
- Container Registry
- Deployment automation
GitLab sering dipakai bersama:
- Kubernetes / K3s
- Docker
- Rancher
- Jenkins
- Terraform
- Cloud platform
Karena sebelumnya kamu sudah setup K3s + Rancher + GitLab CI/CD, belajar GitLab akan sangat membantu untuk workflow DevOps end-to-end.
Roadmap Belajar GitLab
1. Dasar Git (WAJIB)
Sebelum GitLab, pahami dulu Git.
Konsep penting:
- Repository
- Commit
- Branch
- Merge
- Push
- Pull
- Clone
Install Git
Ubuntu:
sudo apt update
sudo apt install git -y
Cek:
git --version
2. Konfigurasi Git
git config --global user.name "Nama Kamu"
git config --global user.email "[email protected]"
Cek:
git config --list
3. Workflow Git Dasar
Buat folder project
mkdir belajar-git
cd belajar-git
Inisialisasi git
git init
Buat file
echo "Hello GitLab" > app.txt
Cek status
git status
Add file
git add .
Commit
git commit -m "first commit"
4. Belajar Branch
Buat branch baru
git checkout -b development
Lihat branch
git branch
Pindah branch
git checkout main
5. Belajar GitLab
Buat akun GitLab
6. Push Project ke GitLab
Buat repository baru di GitLab
Misal:
belajar-gitlab
Hubungkan local ke GitLab
git remote add origin https://gitlab.com/USERNAME/belajar-gitlab.git
Push
git push -u origin main
7. Belajar SSH GitLab (Penting)
Agar tidak login terus saat push.
Generate SSH Key
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Lihat public key
cat ~/.ssh/id_rsa.pub
Tambahkan ke GitLab
Test:
ssh -T [email protected]
8. Belajar CI/CD GitLab
Ini bagian paling penting untuk DevOps.
GitLab menggunakan file:
.gitlab-ci.yml
Contoh sederhana:
stages:
- test
test-job:
stage: test
script:
- echo "Hello CI/CD"
Setelah push:
- Pipeline otomatis jalan
- GitLab Runner execute job
9. Belajar GitLab Runner
Runner adalah executor pipeline.
Install Runner
Ubuntu:
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt install gitlab-runner -y
Register:
sudo gitlab-runner register
10. Integrasi GitLab + Docker
Contoh pipeline build image:
build:
stage: build
script:
- docker build -t app .
11. Integrasi GitLab + K3s/Kubernetes
Workflow real-world:
Developer Push Code
↓
GitLab Pipeline
↓
Build Docker Image
↓
Push ke Registry
↓
Deploy ke K3s
↓
Rancher monitoring
