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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@ apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: forgejo-env name: forgejo-env
namespace: default namespace: forgejo
data: data:
#[admin] #[admin]
FORGEJO__admin__DEFAULT_EMAIL_NOTIFICATIONS: "enabled" # Default configuration for email notifications for users (user configurable). Options: enabled, onmention, disabled 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 kind: PersistentVolumeClaim
metadata: metadata:
name: forgejo-data-pvc name: forgejo-data-pvc
namespace: default namespace: forgejo
labels: labels:
app: forgejo app: forgejo
spec: spec:

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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