How to install Gogs on Kubernetes and Raspberry Pi

Posted by Alexandre on September 14, 2018


I wanted a Git service because I didn’t like having to SSH on my NAS and creating --bare repos by hands.

I didn’t want to store it directly on the SD Card of a Raspberry Pi because of the high risk of data corruption, and I happen to have four Raspberry Pi set up a Kubernetes cluster.

I first thought about GitLab but it has high memory requirements. Then I stumbled upon Gogs.


Gogs is a self-hosted Git service written in Go. The program is just one binary and only requires a database (SQLite, MySQL or Postgres) to work.


  • Having created 2 folders on the filesystem that you expose to your cluster: one is of the DB, the other is for Gogs (it will hold the config and the repos)


My k8 config files are on GitHub

First, you have to create a secrets.yml file

apiVersion: v1
kind: Secret
  name: gogs-secrets
type: Opaque
  username: <redacted>
  password: <redacted>

Put base64 encoded credentials in place of the <redacted>. username and password will be used as the user and password for Postgres. To get them, run:

# In your terminal
echo -n <your-string> | base64

Then, you have to edit the PersistentVolume according to your filesystem provider. I use NFS. The list of filesystems that kubernetes supports can be found here. This can be edited in the files gogs-{db, repos}-pv.yml

You might also want to adjust the size of the volumes accordingly to your needs. In that case, edit both PersistentVolume and PersistentVolumeClaim.

Then, run in that order:

kubectl apply -f secrets.yml
kubectl apply -f gogs-db-pv.yml
kubectl apply -f gogs-db-pvc.yml
kubectl apply -f gogs-postgres.yml
kubectl apply -f gogs-repos-pv.yml
kubectl apply -f gogs-repos-pvc.yml
kubectl apply -f gogs-app.yml

When the pod is up and running, go to http://<your-cluster-master-ip>:30009. You should be greeted by the init page of Gogs. Add your database credentials and other fields, and click follow the instructions. You’re all set!