This commit is contained in:
patdyn 2024-07-09 10:34:45 +02:00
parent 48b00899ea
commit 6a2cd2e7e8
14 changed files with 20 additions and 10 deletions

View file

@ -6,7 +6,8 @@
[dda.c4k-common.monitoring :as mon]
[dda.c4k-forgejo.forgejo :as forgejo]
[dda.c4k-forgejo.backup :as backup]
[dda.c4k-common.postgres :as postgres]))
[dda.c4k-common.postgres :as postgres]
[dda.c4k-common.namespace :as ns]))
(def config-defaults {:issuer "staging", :deploy-federated "false"})
(def rate-limit-defaults {:max-rate 10, :max-concurrent-requests 5})
@ -36,6 +37,7 @@
(map yaml/to-string
(filter #(not (nil? %))
(cm/concat-vec
(ns/generate (merge {:namespace "forgejo"} config))
[(postgres/generate-config {:postgres-size :2gb :db-name "forgejo"})
(postgres/generate-secret auth)
(when (contains? config :postgres-data-volume-path)
@ -52,7 +54,7 @@
(forgejo/generate-appini-env config)
(forgejo/generate-secrets auth)
(forgejo/generate-rate-limit-middleware rate-limit-defaults)] ; this does not have a vector as output
(forgejo/generate-rate-limit-ingress-and-cert config) ; this function has a vector as output
(forgejo/generate-rate-limit-ingress-and-cert (merge {:namespace "keycloak"} config)) ; this function has a vector as output
(when (contains? config :restic-repository)
[(backup/generate-config config)
(backup/generate-secret auth)

View file

@ -2,6 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: backup-restore
namespace: forgejo
spec:
replicas: 0
selector:

View file

@ -2,6 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: backup-config
namespace: forgejo
labels:
app.kubernetes.io/name: backup
app.kubernetes.io/part-of: forgejo

View file

@ -2,6 +2,7 @@ apiVersion: batch/v1
kind: CronJob
metadata:
name: forgejo-backup
namespace: forgejo
labels:
app.kubernetes.part-of: forgejo
spec:

View file

@ -2,6 +2,7 @@ apiVersion: v1
kind: Secret
metadata:
name: backup-secret
namespace: forgejo
type: Opaque
data:
aws-access-key-id: aws-access-key-id

View file

@ -2,7 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: forgejo-env
namespace: default
namespace: forgejo
data:
#[admin]
FORGEJO__admin__DEFAULT_EMAIL_NOTIFICATIONS: "enabled" # Default configuration for email notifications for users (user configurable). Options: enabled, onmention, disabled

View file

@ -2,7 +2,7 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: forgejo-data-pvc
namespace: default
namespace: forgejo
labels:
app: forgejo
spec:

View file

@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: forgejo
namespace: default
namespace: forgejo
labels:
app: forgejo
spec:

View file

@ -2,6 +2,7 @@ apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: ratelimit
namespace: forgejo
spec:
rateLimit: # Config options for rate limiting: https://doc.traefik.io/traefik/middlewares/http/ratelimit/
average: AVG

View file

@ -2,6 +2,7 @@ apiVersion: v1
kind: Secret
metadata:
name: forgejo-secrets
namespace: forgejo
data:
FORGEJO__database__USER: DBUSER
FORGEJO__database__PASSWD: DBPW

View file

@ -2,7 +2,7 @@ kind: Service
apiVersion: v1
metadata:
name: forgejo-ssh-service
namespace: default
namespace: forgejo
annotations:
metallb.universe.tf/allow-shared-ip: "shared-ip-service-group"
metallb.universe.tf/address-pool: public

View file

@ -2,7 +2,7 @@ kind: Service
apiVersion: v1
metadata:
name: forgejo-service
namespace: default
namespace: forgejo
spec:
selector:
app: forgejo

View file

@ -13,6 +13,7 @@
:kind "ConfigMap",
:metadata
{:name "backup-config",
:namespace "forgejo",
:labels
#:app.kubernetes.io{:name "backup", :part-of "forgejo"}},
:data {:restic-repository "s3:s3.amazonaws.com/backup/federated-repo"}}
@ -23,6 +24,7 @@
:kind "ConfigMap",
:metadata
{:name "backup-config",
:namespace "forgejo",
:labels
#:app.kubernetes.io{:name "backup", :part-of "forgejo"}},
:data {:restic-repository "s3:s3.amazonaws.com/backup/repo"}}

View file

@ -55,7 +55,7 @@
(testing "non-federated"
(is (= {:apiVersion "apps/v1",
:kind "Deployment",
:metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}},
:metadata {:name "forgejo", :namespace "forgejo", :labels {:app "forgejo"}},
:spec
{:replicas 1,
:selector {:matchLabels {:app "forgejo"}},
@ -82,7 +82,7 @@
(testing "federated-deployment"
(is (= {:apiVersion "apps/v1",
:kind "Deployment",
:metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}},
:metadata {:name "forgejo", :namespace "forgejo", :labels {:app "forgejo"}},
:spec
{:replicas 1,
:selector {:matchLabels {:app "forgejo"}},
@ -134,7 +134,7 @@
(deftest should-generate-middleware-ratelimit
(is (= {:apiVersion "traefik.containo.us/v1alpha1",
:kind "Middleware",
:metadata {:name "ratelimit"},
:metadata {:name "ratelimit", :namespace "forgejo"},
:spec {:rateLimit {:average 10, :burst 5}}}
(cut/generate-rate-limit-middleware {:max-rate 10, :max-concurrent-requests 5}))))