Compare commits
1 Commits
drone-ci
...
dev/kubern
| Author | SHA1 | Date | |
|---|---|---|---|
| 199b3e94cf |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "vendor/ark"]
|
|
||||||
path = vendor/ark
|
|
||||||
url = git@github.com:heptio/ark.git
|
|
||||||
31
README.md
31
README.md
@@ -7,3 +7,34 @@ Feel free to [open issues] for questions, suggestions, bugs, to-do items, and
|
|||||||
whatever else you want to discuss or resolve.
|
whatever else you want to discuss or resolve.
|
||||||
|
|
||||||
[open issues]: https://gitea.kosmos.org/kosmos/gitea.kosmos.org/issues
|
[open issues]: https://gitea.kosmos.org/kosmos/gitea.kosmos.org/issues
|
||||||
|
|
||||||
|
## Kubernetes
|
||||||
|
|
||||||
|
### Apply changes to resources
|
||||||
|
|
||||||
|
```
|
||||||
|
kubectl apply -f gitea-db.yaml
|
||||||
|
kubectl apply -f gitea-server.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Write the secrets to the local filesystem
|
||||||
|
|
||||||
|
```
|
||||||
|
./script/get_secrets
|
||||||
|
```
|
||||||
|
|
||||||
|
It writes the secrets (currently the app.ini file, as well as auto-generated
|
||||||
|
TLS certificates that are only used when no Let's Encrypt cert is available)
|
||||||
|
to the `kubernetes/config/` folder. These files are not in Git because they
|
||||||
|
contain credentials.
|
||||||
|
|
||||||
|
Once you have edited them locally, you need to delete the secrets stored on
|
||||||
|
Kubernetes before uploading them again. This is done by this script:
|
||||||
|
|
||||||
|
```
|
||||||
|
./script/replace_secrets
|
||||||
|
```
|
||||||
|
|
||||||
|
### Reuse a released persistent volume:
|
||||||
|
|
||||||
|
https://github.com/kubernetes/kubernetes/issues/48609#issuecomment-314066616
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
# 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).
|
|
||||||
|
|
||||||
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
|
|
||||||
schedule in effect for Gitea (using the label `app=gitea`).
|
|
||||||
|
|
||||||
Please refer to Ark's [ Getting Started ][5] 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].
|
|
||||||
|
|
||||||
## Persistent volumes
|
|
||||||
|
|
||||||
Persistent volumes are just GCE disks. Thus, with the current config, Ark
|
|
||||||
creates volume snapshots as native [GCE disk snapshots][2].
|
|
||||||
|
|
||||||
[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,71 +0,0 @@
|
|||||||
# Kubernetes / GKE
|
|
||||||
|
|
||||||
This Gitea instance is currently hosted on Google Kubernetes Engine.
|
|
||||||
|
|
||||||
## Apply changes to resources
|
|
||||||
|
|
||||||
```
|
|
||||||
kubectl apply -f gitea-db.yaml
|
|
||||||
kubectl apply -f gitea-server.yaml
|
|
||||||
```
|
|
||||||
|
|
||||||
## Write the secrets to the local filesystem
|
|
||||||
|
|
||||||
```
|
|
||||||
./script/get_secrets
|
|
||||||
```
|
|
||||||
|
|
||||||
It writes the secrets (currently the app.ini file, as well as auto-generated
|
|
||||||
TLS certificates that are only used when no Let's Encrypt cert is available)
|
|
||||||
to the `kubernetes/config/` folder. These files are not in Git because they
|
|
||||||
contain credentials.
|
|
||||||
|
|
||||||
Once you have edited them locally, you need to delete the secrets stored on
|
|
||||||
Kubernetes before uploading them again. This is done by this script:
|
|
||||||
|
|
||||||
```
|
|
||||||
./script/replace_secrets
|
|
||||||
```
|
|
||||||
|
|
||||||
## Reuse a released persistent volume:
|
|
||||||
|
|
||||||
> When you delete a PVC, corresponding PV becomes `Released`. This PV can contain sensitive data (say credit card numbers) and therefore nobody can ever bind to it, even if it is a PVC with the same name and in the same namespace as the previous one - who knows who's trying to steal the data!
|
|
||||||
>
|
|
||||||
> Admin intervention is required here. He has two options:
|
|
||||||
>
|
|
||||||
> * Make the PV available to everybody - delete `PV.Spec.ClaimRef`, Such PV can bound to any PVC (assuming that capacity, access mode and selectors match)
|
|
||||||
>
|
|
||||||
> * Make the PV available to a specific PVC - pre-fill `PV.Spec.ClaimRef` with a pointer to a PVC. Leave the `PV.Spec.ClaimRef,UID` empty, as the PVC does not to need exist at this point and you don't know PVC's UID. This PV can be bound only to the specified PVC.
|
|
||||||
>
|
|
||||||
>
|
|
||||||
> @whitecolor, in your case you should be fine by clearing `PV.Spec.ClaimRef.UID` in the PV. Only the re-created PVC (with any UID) can then use the PV. And it's your responsibility that only the right person can craft appropriate PVC so nobody can steal your data.
|
|
||||||
|
|
||||||
https://github.com/kubernetes/kubernetes/issues/48609#issuecomment-314066616
|
|
||||||
|
|
||||||
## Update Gitea
|
|
||||||
|
|
||||||
### Released version
|
|
||||||
|
|
||||||
Change the image for the gitea-server container
|
|
||||||
(`kubernetes/gitea-server.yaml`) to `gitea/gitea:TAG`, for example:
|
|
||||||
`gitea/gitea:1.7.0-rc2`
|
|
||||||
|
|
||||||
### Unreleased version
|
|
||||||
|
|
||||||
This is useful to deploy features that are in master but not yet in a release.
|
|
||||||
|
|
||||||
$ docker pull gitea/gitea
|
|
||||||
$ docker tag gitea/gitea:latest kosmosorg/gitea:production
|
|
||||||
$ docker push kosmosorg/gitea
|
|
||||||
|
|
||||||
Set the image for the gitea-server container to `kosmosorg/gitea:latest`, or run
|
|
||||||
this command to force a deployment if it is already set to it
|
|
||||||
|
|
||||||
$ kubectl patch deployment gitea-server -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"date\":\"`date +'%s'`\"}}}}}"
|
|
||||||
|
|
||||||
### Build our own image
|
|
||||||
|
|
||||||
At the root of the [https://github.com/go-gitea/gitea](gitea repo)
|
|
||||||
|
|
||||||
$ DOCKER_TAG=production DOCKER_IMAGE=kosmosorg/gitea make docker # builds and tags kosmosorg/gitea:production locally
|
|
||||||
$ docker push kosmosorg/gitea
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
|
||||||
kind: ClusterRoleBinding
|
|
||||||
metadata:
|
|
||||||
name: kosmos-drone-rbac
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: default
|
|
||||||
namespace: kosmos
|
|
||||||
roleRef:
|
|
||||||
kind: ClusterRole
|
|
||||||
name: cluster-admin
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
apiVersion: extensions/v1beta1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: kosmos-drone-server
|
|
||||||
namespace: kosmos
|
|
||||||
labels:
|
|
||||||
app: kosmos-drone
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
name: kosmos-drone-server
|
|
||||||
app: kosmos-drone
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: kosmos-drone-server
|
|
||||||
image: drone/drone:latest
|
|
||||||
imagePullPolicy: Always
|
|
||||||
env:
|
|
||||||
- name: DRONE_KUBERNETES_ENABLED
|
|
||||||
value: "true"
|
|
||||||
- name: DRONE_KUBERNETES_NAMESPACE
|
|
||||||
value: kosmos
|
|
||||||
- name: DRONE_GITEA_SERVER
|
|
||||||
value: https://gitea.kosmos.org
|
|
||||||
- name: DRONE_RPC_SECRET
|
|
||||||
value: 0500c55b6ae97a7f1e7c207477698b6d
|
|
||||||
- name: DRONE_SERVER_HOST
|
|
||||||
value: drone.kosmos.org
|
|
||||||
- name: DRONE_SERVER_PROTO
|
|
||||||
value: https
|
|
||||||
- name: DRONE_TLS_AUTOCERT
|
|
||||||
value: "true"
|
|
||||||
- name: DRONE_ADMIN
|
|
||||||
value: raucao,gregkare,galfert
|
|
||||||
- name: DRONE_LOGS_DEBUG
|
|
||||||
value: "true"
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /var/lib/drone
|
|
||||||
name: kosmos-drone-data
|
|
||||||
ports:
|
|
||||||
- containerPort: 80
|
|
||||||
- containerPort: 443
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 50Mi
|
|
||||||
limits:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 100Mi
|
|
||||||
volumes:
|
|
||||||
- name: kosmos-drone-data
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: kosmos-drone-data
|
|
||||||
restartPolicy: Always
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: kosmos-drone-data
|
|
||||||
namespace: kosmos
|
|
||||||
labels:
|
|
||||||
app: kosmos-drone
|
|
||||||
spec:
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 3000Mi
|
|
||||||
status: {}
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: kosmos-drone-server
|
|
||||||
namespace: kosmos
|
|
||||||
labels:
|
|
||||||
name: kosmos-drone-server
|
|
||||||
app: kosmos-drone
|
|
||||||
spec:
|
|
||||||
type: LoadBalancer
|
|
||||||
ports:
|
|
||||||
- name: "http"
|
|
||||||
port: 80
|
|
||||||
targetPort: 80
|
|
||||||
- name: "https"
|
|
||||||
port: 443
|
|
||||||
targetPort: 443
|
|
||||||
selector:
|
|
||||||
name: kosmos-drone-server
|
|
||||||
@@ -2,8 +2,7 @@ apiVersion: extensions/v1beta1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-db
|
name: gitea-db
|
||||||
labels:
|
namespace: gitea
|
||||||
app: gitea
|
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
strategy:
|
strategy:
|
||||||
@@ -12,7 +11,6 @@ spec:
|
|||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
name: gitea-db
|
name: gitea-db
|
||||||
app: gitea
|
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- env:
|
- env:
|
||||||
@@ -49,9 +47,9 @@ apiVersion: v1
|
|||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-db-data
|
name: gitea-db-data
|
||||||
|
namespace: gitea
|
||||||
labels:
|
labels:
|
||||||
name: gitea-db-data
|
name: gitea-db-data
|
||||||
app: gitea
|
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
@@ -63,9 +61,9 @@ apiVersion: v1
|
|||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-db
|
name: gitea-db
|
||||||
|
namespace: gitea
|
||||||
labels:
|
labels:
|
||||||
service: gitea-db
|
service: gitea-db
|
||||||
app: gitea
|
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
name: gitea-db
|
name: gitea-db
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
metadata:
|
metadata:
|
||||||
name: kosmos
|
name: gitea
|
||||||
labels:
|
labels:
|
||||||
app: kosmos
|
app: gitea
|
||||||
@@ -2,15 +2,13 @@ apiVersion: extensions/v1beta1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-server
|
name: gitea-server
|
||||||
labels:
|
namespace: gitea
|
||||||
app: gitea
|
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
name: gitea-server
|
name: gitea-server
|
||||||
app: gitea
|
|
||||||
spec:
|
spec:
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: init-config
|
- name: init-config
|
||||||
@@ -25,12 +23,38 @@ spec:
|
|||||||
# This is only used for the initial setup, it does nothing once a app.ini
|
# This is only used for the initial setup, it does nothing once a app.ini
|
||||||
# file exists in the conf/ directory of the data directory
|
# file exists in the conf/ directory of the data directory
|
||||||
# (/data/gitea/conf in our case)
|
# (/data/gitea/conf in our case)
|
||||||
- name: gitea-server
|
- env:
|
||||||
image: gitea/gitea:1.7.1
|
- name: DB_HOST
|
||||||
|
value: gitea-db:3306
|
||||||
|
- name: DB_NAME
|
||||||
|
value: gitea
|
||||||
|
- name: DB_PASSWD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: gitea-mysql-pass
|
||||||
|
key: password
|
||||||
|
- name: DB_TYPE
|
||||||
|
value: mysql
|
||||||
|
- name: DB_USER
|
||||||
|
value: gitea
|
||||||
|
- name: ROOT_URL
|
||||||
|
value: https://gitea.kosmos.org
|
||||||
|
- name: RUN_MODE
|
||||||
|
value: prod
|
||||||
|
- name: SECRET_KEY
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: gitea-secret-key
|
||||||
|
key: password
|
||||||
|
- name: SSH_DOMAIN
|
||||||
|
value: gitea.kosmos.org
|
||||||
|
image: 5apps/gitea:latest
|
||||||
|
name: gitea-server
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 3000
|
- containerPort: 3000
|
||||||
- containerPort: 3001
|
- containerPort: 3001
|
||||||
- containerPort: 22
|
- containerPort: 22
|
||||||
|
resources: {}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /data
|
- mountPath: /data
|
||||||
name: gitea-server-data
|
name: gitea-server-data
|
||||||
@@ -57,8 +81,7 @@ apiVersion: v1
|
|||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-server-data
|
name: gitea-server-data
|
||||||
labels:
|
namespace: gitea
|
||||||
app: gitea
|
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
@@ -70,9 +93,9 @@ apiVersion: v1
|
|||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: gitea-server
|
name: gitea-server
|
||||||
|
namespace: gitea
|
||||||
labels:
|
labels:
|
||||||
name: gitea-server
|
name: gitea-server
|
||||||
app: gitea
|
|
||||||
spec:
|
spec:
|
||||||
type: LoadBalancer
|
type: LoadBalancer
|
||||||
# preserves the client source IP
|
# preserves the client source IP
|
||||||
|
|||||||
1
vendor/ark
vendored
1
vendor/ark
vendored
Submodule vendor/ark deleted from 0fd7872ef4
Reference in New Issue
Block a user