40 Commits

Author SHA1 Message Date
1928fdad6e WIP: StatefulSet config for gitea-server
A deployment cannot actually attach the same persistent storage across
nodes. We have to switch to a StatefulSet for any and all programs that
need shared persistent storage.

I tried applying this config, but it didn't attach the same volume/disk
as before, so I had to revert to the Deployment for now.
2019-12-19 14:10:57 +01:00
2ab0db6c2a Merge branch 'chore/update_gitea' of kosmos/gitea.kosmos.org into master 2019-12-19 13:10:13 +00:00
d6d70af0ad Upgrade Gitea to 1.10.1 2019-12-19 14:09:35 +01:00
75881c4c3f Merge branch 'chore/update_gitea' of kosmos/gitea.kosmos.org into master 2019-11-24 12:17:10 +00:00
3cd4b3102c Update Gitea to 1.10.0 2019-11-24 13:13:12 +01:00
11ae884dea Merge branch 'chore/update_gitea' of kosmos/gitea.kosmos.org into master 2019-10-31 11:58:21 +00:00
6785287227 Update Gitea to 1.9.5 2019-10-31 12:57:25 +01:00
d4784e9787 Merge branch 'chore/update_gitea' of kosmos/gitea.kosmos.org into master 2019-10-13 11:45:42 +00:00
da278556ed Adapt CPU resource request and limit
After the new pod wasn't able to be scheduled due to insufficient CPU
resources, I checked the current usage and it was well below the
requested amount. Lowering request and limit fixed the deployment issue.
2019-10-13 13:42:34 +02:00
4dd0f4b844 Update Gitea to 1.9.4 2019-10-13 13:42:24 +02:00
b6894598a6 Update Gitea to 1.9.2 2019-08-31 12:01:16 +02:00
972bbedb87 Improve customizations documentation (#35) 2019-08-16 09:26:00 +00:00
db396d6ee1 Merge branch 'chore/update_gitea' of kosmos/gitea.kosmos.org into master 2019-08-15 15:33:48 +00:00
d821e02dec Update Gitea to 1.9.1 2019-08-15 17:32:38 +02:00
2f02ddb79d Merge branch 'docs_label' of kosmos/gitea.kosmos.org into master 2019-08-12 11:38:11 +00:00
Greg Karékinian
90cb219d79 Change the color for the docs label to ead746 2019-08-12 13:27:41 +02:00
Greg Karékinian
9c36ebeb14 Add the docs label to the Kosmos label set 2019-08-09 16:06:01 +02:00
gregkare
5f3b80ab9e Merge branch 'deployment_api_version' of kosmos/gitea.kosmos.org into master 2019-08-07 09:20:50 +00:00
b00931352f Improve README 2019-08-06 13:16:07 +02:00
Greg Karékinian
f8d964f8d2 Bump the api version for the Deployment resource to apps/v1
It was previously set to extensions/v1beta1. I have discovered that when
the Deployment is created as a extensions/v1beta1, it causes the
existing pod to be killed immediately when doing a rolling update. When
the Deployment was created as apps/v1, a rolling update behaves as
expected: a new pod is created, and the old one is only terminated once
the new pod is ready to serve traffic.

The existing Deployment resource will need to be deleted and recreated:

    kubectl delete deployment gitea-server
    kubectl apply -f gitea-server.yaml

Applying the file without deleting it first will not fix the issue with
rolling updates. It will cause a short downtime
2019-08-06 12:44:57 +02:00
810482c755 Merge branch 'chore/30-update_1.9.0' of kosmos/gitea.kosmos.org into master 2019-08-02 15:59:38 +00:00
Greg Karékinian
4e225ab1af Update Gitea to 1.9.0
Closes #30
2019-08-02 17:34:28 +02:00
1f6e0b7d57 Merge branch 'feature/ark_to_velero' of kosmos/gitea.kosmos.org into master 2019-06-22 12:26:30 +00:00
Greg Karékinian
a3fa72bb56 Update the documentation, Ark is now Velero
Refs #27
2019-06-19 18:33:44 +02:00
gregkare
9f4a5b452c Merge branch 'chore/gitea_181' of kosmos/gitea.kosmos.org into master 2019-05-23 14:31:55 +00:00
12fc74d8ff Upgrade Gitea to 1.8.1 2019-05-21 15:15:04 +02:00
gregkare
1d69fad451 Merge branch 'upgrade/22-gitea' of kosmos/gitea.kosmos.org into master 2019-05-02 15:36:14 +00:00
Greg Karékinian
f73c58d7ee Merge branch 'master' into upgrade/22-gitea 2019-05-02 17:35:52 +02:00
gregkare
68771a8e61 Merge branch 'feature/4-label_sets' of kosmos/gitea.kosmos.org into master 2019-05-02 15:27:31 +00:00
gregkare
e3de3af82f Merge branch 'chore/resource_config' of kosmos/gitea.kosmos.org into master 2019-05-02 15:25:13 +00:00
490248909b Update Gitea to 1.8.0 2019-05-02 15:34:12 +01:00
Greg Karékinian
e0741b4438 Ship the customizations as a Docker image
The Docker image is used in the initialization process, to copy
everything in the custom folder to the Gitea data dir (mounted as a
persistent volume). It is built using Packer and is based on the busybox
image, so we can use its minimalist shell system to copy files and set
permissions
2019-04-01 17:01:16 +02:00
Greg Karékinian
8050126d2d Merge branch 'master' into feature/4-label_sets 2019-03-29 15:14:15 +01:00
Greg Karékinian
b5bbc5fa34 Update Gitea to 1.7.5
Running on GKE

Closes #21
2019-03-29 15:04:23 +01:00
915fd7db8a Add resource requests and limits for Gitea
Based on recent usage stats. If these are not set, the scheduler's
capacity check doesn't work and it will place new pods on nodes that are
actually not free enough for them.
2019-03-04 13:48:20 +07:00
Greg Karékinian
bbfa3f2964 Add a script to copy the content of the custom folder to a running pod
For now it is only labels, but adding anything supported will work
(robots.txt, public files, templates, etc)

The content will be copied to the /data/gitea/ folder that is a mounted
persistent volume

https://docs.gitea.io/en-us/customizing-gitea/
2019-02-27 17:47:48 +01:00
Greg Karékinian
0a60d8831c Merge branch 'master' into feature/4-label_sets 2019-02-27 12:43:45 +01:00
Greg Karékinian
cc6f31b4b9 Update Gitea to 1.7.2
Closes #18
2019-02-25 16:54:59 +01:00
Greg Karékinian
069502d056 Bump the gitea data storage to 20GB 2019-02-25 13:29:09 +01:00
Greg Karékinian
278e6a9cd7 Use a 10GB persistent storage volume for gitea data 2019-02-25 13:18:45 +01:00
16 changed files with 208 additions and 49 deletions

2
.gitignore vendored
View File

@@ -1 +1 @@
/kubernetes/custom/config/
/kubernetes/config/

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "vendor/ark"]
path = vendor/ark
url = git@github.com:heptio/ark.git

View File

@@ -1,9 +1,9 @@
# gitea.kosmos.org
This repository contains configuration files and other assets, that are used to
deploy and operate this Gitea instance.
deploy and operate this Gitea instance. Feel free to [open
issues](https://gitea.kosmos.org/kosmos/gitea.kosmos.org/issues) for questions,
suggestions, bugs, to-do items, and whatever else you want to discuss or
resolve.
Feel free to [open issues] for questions, suggestions, bugs, to-do items, and
whatever else you want to discuss or resolve.
[open issues]: https://gitea.kosmos.org/kosmos/gitea.kosmos.org/issues
See `doc/` folder for some technical info.

View File

@@ -1,4 +1,5 @@
#db231d bug ; Something is not working
#ead746 docs ; Documentation
#76db1d enhancement ; Improving existing functionality
#1d76db feature ; New functionality
#db1d76 idea ; Something to consider

View File

@@ -1,36 +1,28 @@
# Backups
We're using [Ark][1] for backing up Kubernetes config and GKE resources. It is
available as a Git submodule in the `vendor/` folder (incl. the `ark`
executable).
We're using [Velero][1] (formerly Ark) for backing up Kubernetes config and GKE
resources. It is available as a compiled binary for your platform [on GitHub][2]
In order to initialize and update submodules in your local repo, run once:
git submodule update --init
Then, to fetch/update the modules, run:
git submodule update
The Ark service is running on the Sidamo cluster and was set up using the
[official docs' GCP instructions and config files][4]. There's a daily backup
The Velero service is running on the Sidamo cluster and was set up using the
[official docs' GCP instructions][3]. There's a daily backup
schedule in effect for Gitea (using the label `app=gitea`).
Please refer to Ark's [ Getting Started ][5] doc for all backup and restore
Please refer to Velero's [ Getting Started ][4] doc for all backup and restore
commands.
## Backup location
Cluster configuration (including all live resources) is backed up to [a Google
Cloud Storage container][3].
Cloud Storage container][5].
## Persistent volumes
Persistent volumes are just GCE disks. Thus, with the current config, Ark
creates volume snapshots as native [GCE disk snapshots][2].
Persistent volumes are just GCE disks. Thus, with the current config, Velero
creates volume snapshots as native [GCE disk snapshots][6].
[1]: https://heptio.github.io/ark/v0.10.0
[2]: https://console.cloud.google.com/compute/snapshots?organizationId=772167872692&project=fluted-magpie-218106&tab=snapshots&snapshotssize=50
[3]: https://console.cloud.google.com/storage/browser/sidamo-backups?project=fluted-magpie-218106&organizationId=772167872692
[4]: https://heptio.github.io/ark/v0.10.0/gcp-config
[5]: https://heptio.github.io/ark/v0.10.0/get-started
[1]: https://velero.io/docs/v1.0.0
[2]: https://github.com/heptio/velero/releases/tag/v1.0.0
[3]: https://velero.io/docs/v1.0.0/gcp-config/
[4]: https://velero.io/docs/v1.0.0/about/
[5]: https://console.cloud.google.com/storage/browser/sidamo-backups-new?project=fluted-magpie-218106&organizationId=772167872692
[6]: https://console.cloud.google.com/compute/snapshots?organizationId=772167872692&project=fluted-magpie-218106&tab=snapshots&snapshotssize=50

View File

@@ -0,0 +1,20 @@
## Customizations image
### Build
To create a new Docker image containing our Gitea customizations (label sets,
styles, page content, etc.):
Edit `packer/custom.json` to increment the tag, then run this script (needs
[Packer](https://www.packer.io/) in your path)
./script/build_customizations_image
### Deploy
Edit `kubernetes/gitea-server.yaml` to use the new tag
(`image: eu.gcr.io/fluted-magpie-218106/gitea_custom:$VERSION`) and apply the
change:
cd kubernetes
kubectl apply -f gitea-server.yaml

View File

@@ -32,13 +32,19 @@ spec:
value: gitea
image: mariadb:10.3.10
name: gitea-db
resources: {}
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- mountPath: /var/lib/mysql
name: gitea-db-data
resources:
requests:
cpu: 250m
memory: 150Mi
limits:
cpu: 500m
memory: 300Mi
restartPolicy: Always
volumes:
- name: gitea-db-data

View File

@@ -0,0 +1,103 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: gitea-server
labels:
app: gitea
spec:
serviceName: gitea-server
updateStrategy:
type: RollingUpdate
replicas: 1
selector:
matchLabels:
app: gitea
template:
metadata:
labels:
name: gitea-server
app: gitea
spec:
initContainers:
- name: init-config
# This is a busybox image with our gitea customizations saved to
# /custom, built using ./script/build_customizations_image from the
# root of the repo
image: eu.gcr.io/fluted-magpie-218106/gitea_custom:0.1.2
command: [
'sh', '-c',
'mkdir -p /data/gitea/conf && mkdir -p /data/gitea/https && cp /root/conf/app.ini /data/gitea/conf/app.ini && chown 1000:1000 /data/gitea/conf/app.ini && chmod 660 /data/gitea/conf/app.ini && cp /root/conf/*.pem /data/gitea/https && chmod 600 /data/gitea/https/*.pem && cp -R /custom/* /data/gitea && chown -R 1000:1000 /data/gitea'
]
volumeMounts:
- mountPath: /data
name: gitea-server-data
- mountPath: /root/conf
name: config
containers:
- name: gitea-server
image: gitea/gitea:1.10.1
ports:
- containerPort: 3000
- containerPort: 3001
- containerPort: 22
volumeMounts:
- mountPath: /data
name: gitea-server-data
resources:
requests:
cpu: 150m
memory: 256Mi
limits:
cpu: 250m
memory: 512Mi
restartPolicy: Always
volumes:
- name: config
secret:
secretName: gitea-config
items:
- key: app.ini
path: app.ini
mode: 256
- key: cert.pem
path: cert.pem
mode: 256
- key: key.pem
path: key.pem
mode: 256
volumeClaimTemplates:
- metadata:
name: gitea-server-data
labels:
app: gitea
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
storageClassName: gcePersistentDisk
---
apiVersion: v1
kind: Service
metadata:
name: gitea-server
labels:
name: gitea-server
app: gitea
spec:
type: LoadBalancer
# preserves the client source IP
externalTrafficPolicy: Local
ports:
- name: "ssh"
port: 22
targetPort: 22
- name: "http"
port: 80
targetPort: 3001
- name: "https"
port: 443
targetPort: 3000
selector:
name: gitea-server

View File

@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: gitea-server
@@ -6,6 +6,9 @@ metadata:
app: gitea
spec:
replicas: 1
selector:
matchLabels:
app: gitea
template:
metadata:
labels:
@@ -14,24 +17,22 @@ spec:
spec:
initContainers:
- name: init-config
image: busybox
# This is a busybox image with our gitea customizations saved to
# /custom, built using ./script/build_customizations_image from the
# root of the repo
image: eu.gcr.io/fluted-magpie-218106/gitea_custom:0.1.2
command: [
'sh', '-c',
'mkdir -p /data/gitea/conf && mkdir -p /data/gitea/https && mkdir -p /data/gitea/options/label && cp /root/conf/app.ini /data/gitea/conf/app.ini && chown 1000:1000 /data/gitea/conf/app.ini && chmod 660 /data/gitea/conf/app.ini && cp /root/conf/*.pem /data/gitea/https && chmod 600 /data/gitea/https/*.pem && cp /root/options/label/* /data/gitea/options/label/ && chown -R 1000:1000 /data/gitea'
'mkdir -p /data/gitea/conf && mkdir -p /data/gitea/https && cp /root/conf/app.ini /data/gitea/conf/app.ini && chown 1000:1000 /data/gitea/conf/app.ini && chmod 660 /data/gitea/conf/app.ini && cp /root/conf/*.pem /data/gitea/https && chmod 600 /data/gitea/https/*.pem && cp -R /custom/* /data/gitea && chown -R 1000:1000 /data/gitea'
]
volumeMounts:
- mountPath: /data
name: gitea-server-data
- mountPath: /root/conf
name: config
# The labels have been created as a ConfigMap from local files using this command:
#
# kubectl create configmap gitea-options-label --from-file=custom/options/label/
- mountPath: /root/options/label
name: label
containers:
- name: gitea-server
image: gitea/gitea:1.7.1
image: gitea/gitea:1.10.1
ports:
- containerPort: 3000
- containerPort: 3001
@@ -39,6 +40,13 @@ spec:
volumeMounts:
- mountPath: /data
name: gitea-server-data
resources:
requests:
cpu: 150m
memory: 256Mi
limits:
cpu: 250m
memory: 512Mi
restartPolicy: Always
volumes:
- name: gitea-server-data
@@ -57,9 +65,6 @@ spec:
- key: key.pem
path: key.pem
mode: 256
- name: label
configMap:
name: gitea-options-label
---
apiVersion: v1
kind: PersistentVolumeClaim
@@ -72,7 +77,7 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storage: 20Gi
---
apiVersion: v1
kind: Service

29
packer/custom.json Normal file
View File

@@ -0,0 +1,29 @@
{
"builders": [{
"type": "docker",
"image": "busybox",
"run_command": ["-d", "-i", "-t", "{{.Image}}", "/bin/sh"],
"commit": true
}],
"provisioners": [
{
"inline": ["mkdir /custom"],
"type": "shell"
},
{
"type": "file",
"source": "../custom/",
"destination": "/custom"
}
],
"post-processors": [
[
{
"type": "docker-tag",
"repository": "eu.gcr.io/fluted-magpie-218106/gitea_custom",
"tag": "0.1.2"
},
"docker-push"
]
]
}

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# fail fast
set -e
cd packer/
packer build custom.json
cd -

View File

@@ -7,7 +7,7 @@ secret = `kubectl get secret gitea-config -o yaml`
yaml = YAML.load(secret)
yaml['data'].each do |key, data|
filename = File.join('kubernetes', 'custom', 'config', key)
filename = File.join('kubernetes', 'config', key)
File.open(filename, "w+") do |f|
puts "Writing #{filename}"
f.write Base64.decode64(data)

View File

@@ -2,8 +2,8 @@
# Delete the gitea-config secrets
kubectl delete secret gitea-config
# Replace it from the local files in kubernetes/custom/config/* (acquired by running
# Replace it from the local files in kubernetes/config/* (acquired by running
# ./script/get_secrets)
kubectl create secret generic gitea-config --from-file=cert.pem=kubernetes/custom/config/cert.pem --from-file=key.pem=kubernetes/custom/config/key.pem --from-file=app.ini=kubernetes/custom/config/app.ini
kubectl create secret generic gitea-config --from-file=cert.pem=kubernetes/config/cert.pem --from-file=key.pem=kubernetes/config/key.pem --from-file=app.ini=kubernetes/config/app.ini
# Force the pod to restart by patching the deployment resource
kubectl patch deployment gitea-server -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"date\":\"`date +'%s'`\"}}}}}"

1
vendor/ark vendored

Submodule vendor/ark deleted from 0fd7872ef4