2 minutes
Get Started with Fleet and Gitea in Kubernetes
Author: Roberto Galaz
🔗 Connect on LinkedIn
This tutorial will guide you through setting up Fleet with Gitea on Kubernetes in a straightforward and beginner-friendly way. Fleet is a GitOps tool for managing Kubernetes clusters, and Gitea is a lightweight Git hosting solution. By the end of this guide, you’ll have a basic setup to demonstrate GitOps principles using these tools.
Pre-requisites
- A kubernetes cluster version 1.20+
- Helm
Add the Helm repositories
helm repo add fleet https://rancher.github.io/fleet-helm-charts/
helm repo add gitea-charts https://dl.gitea.com/charts/
helm repo update
Installation
- Create
values.yaml
with the following content
gitea:
config:
server:
DOMAIN: gitea-http.gitea.svc.cluster.local
SSH_DOMAIN: gitea-ssh.gitea.svc.cluster.local
webhook:
ALLOWED_HOST_LIST: "*"
DELIVER_TIMEOUT: 15
Explanation:
We will use Gitea through the Kubernetes service (via port-forwarding). Set DOMAIN
and SSH_DOMAIN
to the Kubernetes DNS for the service. Leave the webhook configuration as-is for now; we’ll revisit it later.
Install the Gitea chart
helm install gitea gitea-charts/gitea -n gitea --create-namespace --values values.yaml --debug
Install the Fleet chart
helm -n cattle-fleet-system upgrade --create-namespace --wait fleet fleet/fleet
Setting Up
- Run the port-forward
kubectl port-forward svc/gitea-http -n gitea 3000:3000
- Go to http://localhost:3000
- Register a new user, this will be the admin user
- Create an organization and repository, both with name
testing
- Create and apply the GitRepo resource
apiVersion: fleet.cattle.io/v1alpha1
kind: GitRepo
metadata:
name: sample
namespace: fleet-local
spec:
repo: "http://gitea-http.gitea.svc.cluster.local:3000/testing/testing.git"
branch: main
paths:
- simple
targetNamespace: default
disablePolling: false
Explanation:
The GitRepo resource should be created in the fleet-local
namespace because Fleet’s Cluster
resource is auto-wired there. However, workloads will be deployed to the default
namespace.
- Add the files to the repo, we’ll create a deployment for our test
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: testing
name: testing
spec:
replicas: 1
selector:
matchLabels:
app: testing
strategy: {}
template:
metadata:
labels:
app: testing
spec:
containers:
- image: nginx
name: nginx
resources: {}
Ensure your repository has the following structure:
├── README.md
└── simple
└── testing.yaml
- Push the changes and you will see the deployment created and running in the
default
namespace
References
- https://fleet.rancher.io/0.11/quickstart
- https://fleet.rancher.io/ref-gitrepo