This article will guide you through utilizing k3s to manage a self-hosted GitLab instance. If you’re already leveraging Kubernetes for platform development, this can be a simplified yet effective option.
Why Use k3s?
k3s is a lightweight version of Kubernetes designed to run on resource-constrained environments. Think of it as a compact toolbox filled with essential tools that fit into any small space without sacrificing functionality. You still get all the tools you need for managing your projects but in a much smaller footprint.
Step-by-Step Setup Process
1. Obtain a Server (or VM Instance)
For this guide, we will be using a Vultr server, specifically the Los Angeles instance with the following specifications:
- 2 CPU
- 4096MB Memory
- Ubuntu 18.04 x64
Ensure that Private Networking is enabled, and assign a Server Hostname Label like gitlab.apk8s.dev.
2. Configure DNS
Add DNS A records for your domain pointing to your server’s public IP. This includes entries for gitlab.apk8s.dev and *.gitlab.apk8s.dev.
3. Prepare Your Server
Log into your server using:
ssh root@NEW_SERVER_IP
Once logged in, upgrade any outdated packages:
apt update && apt upgrade -y
4. Install k3s
Install k3s with a simple curl command:
curl -sfL https://get.k3s.io | sh
Congratulations! You’ve installed k3s, and the Kubernetes API is now available.
5. Remote Access with kubectl
Make sure you can access the new k3s cluster:
curl --insecure https://SERVER_IP:6443
If you receive a **401 Unauthorized** response, retrieve the credentials stored at:
cat /etc/rancher/k3s/k3s.yaml
This is a kubectl config file that allows you to manage your Kubernetes cluster.
6. Install Cert Manager
Since you’re using GitLab with Lets Encrypt capabilities, follow these commands:
kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.8/deploy/manifests/00-crds.yaml
kubectl create -f .k8s0000-global001-cert-manager-helm.yml
7. Install GitLab
Now you can set up GitLab following a few commands:
kubectl apply -f .k8s1000-gitlab000-namespace000-namespace.yml
kubectl apply -f .k8s1000-gitlab000-namespace010-certs.yml
kubectl apply -f .k8s1000-gitlab100-gitlab10-service.yml
kubectl apply -f .k8s1000-gitlab100-gitlab40-deployment.yml
After the deployment, access GitLab via your web browser using the URL: https://gitlab.apk8s.dev.
Troubleshooting
- Unreachable Server: Ensure the server is powered on and the firewall settings allow traffic on the required ports (80 and 443).
- Configuration Issues: Double-check your configurations by reviewing the
gitlab.rb
file located atsrvgitlab/config/gitlab.rb
on your server. - kubectl Access Denied: Ensure your
k3s.yaml
file has the correct permissions and is pointed to the right context.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Final Reminders
Remember to keep the directory srvgitlab
backed up on the server. Regular backups are crucial for the integrity of your deployed applications.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.