Open In App
Related Articles

Installing Private Git Server on K8s Cluster with Gitea and AKS

Improve Article
Save Article
Like Article

In this article, we are going to install a self-hosted Gitea server on top of Azure Kubernetes Service with Helm and set up a git repo. Having a private Git server might be beneficial these days.

Gitea is a community-managed Git-compatible lightweight code hosting solution written in Go. It is published under the MIT license.

Azure Kubernetes Service (AKS) is a Microsoft Azure Managed Kubernetes service

In this article, we will set up an AKS cluster using az CLI and cloud shell.


Before creating any resources, we need to verify that Microsoft.OperationsManagement and Microsoft.OperationalInsights are registered on your subscription

az provider show -n Microsoft.OperationsManagement -o table
az provider show -n Microsoft.OperationalInsights -o table

If they are not registered, register using the following commands:

az provider register --namespace Microsoft.OperationsManagement
az provider register --namespace Microsoft.OperationalInsights

First of all, we need to create a resource group since all azure resources must be in a particular resource group. All resources I’m going to create will be in the West Europe region (westeurope).

az group create --name my-gitea-lab --location westeurope

Install AKS cluster:

Then we will deploy Azure Kubernetes Cluster on a single VM and make it generate ssh keys for us:

az aks create --resource-group my-gitea-lab --name mygiteaAKSCluster --node-count 1 --node-vm-size standard_b2s --generate-ssh-keys

You can check the prices and sizes of VMs in Azure Documentation. For AKS you need a minimum of 3.5 GB RAM worker VM so the cheapest option for our example is standard_b2s.

Note: When you create an AKS cluster, a second resource group is automatically created to store the AKS resources

New k8s cluster is ready

To get access to your newly created cluster you can run the following command:

az aks get-credentials --resource-group my-gitea-lab --name mygiteaAKSCluster

The helm CLI is already installed in Azure Cloud Shell but if you are using another environment – make sure you have helm 3 CLI binary installed with the following command:

which helm

Let’s continue by adding gitea-charts helm repository 

helm repo add gitea-charts
helm repo update

To customize your Gitea deployment you need to download the values.yml file. You can play around with options of your Gitea setup and provide custom storageclass, expose Gitea through Loadbalancer\Ingress, or setup LDAP or Oauth2 integration. Here are a few examples:

  • The service.http.type=LoadBalancer default value is ClusterIP but since we are deploying in the public cloud we will use LoadBalancer 
  • The ingress.enabled will enable ingress, by default it is false.
  • The service.ssh.port setup custom port for ssh traffic.

Deploy Gitea:

Let’s bootstraps a Gitea deployment on the Azure Kubernetes Service cluster using the Helm package manager

helm install gitea gitea-charts/gitea  --set service.http.type=LoadBalancer

You can watch the Load balancer being provisioned 

kubectl get --namespace default svc -w gitea-http

Once appeared external IP run  those commands to get Gitea URL:

export SERVICE_IP=$(kubectl get svc --namespace default gitea-http --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
echo http://$SERVICE_IP:3000

Welcome to a freshly deployed Gitea!

default username and password could be found in the values.yml file

 username: gitea_admin
 password: r8sA8CPHD9!bt6d

Create Repository:

Once logged in let us create a new repository by clicking “+New Repository” in the top right corner

There are plenty of parameters that you can setup during the repo creation process:

Push code:

Let’s initiate git repo in cloud shell, add Readme file and push code to our private Gitea server:

git init
echo "Hello from Gitea Repo!" >
git add
git commit -m "first commit"
git remote add origin
git push -u origin master

Now we can see the first commit on the remote server!

Clean up:

To clean up, you need to delete the helm chart

helm delete gitea

and delete resource group with AKS cluster and worker node

az group delete --name my-gitea-lab --yes --no-wait

In this article, we covered steps to install Azure Kubernetes Service (AKS) with az CLI, customized and installed Gitea helm chart, exposed Gitea with Load Balancer. Then we created a git repository and pushed code to the Gitea server.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 30 Mar, 2023
Like Article
Save Article
Similar Reads
Complete Tutorials