From 6a2cd2e7e8b3d62947732da5d5a2d28d586464c5 Mon Sep 17 00:00:00 2001 From: patdyn Date: Tue, 9 Jul 2024 10:34:45 +0200 Subject: [PATCH] Add ns --- src/main/cljc/dda/c4k_forgejo/core.cljc | 6 ++++-- src/main/resources/backup/backup-restore-deployment.yaml | 1 + src/main/resources/backup/config.yaml | 1 + src/main/resources/backup/cron.yaml | 1 + src/main/resources/backup/secret.yaml | 1 + src/main/resources/forgejo/appini-env-configmap.yaml | 2 +- src/main/resources/forgejo/datavolume.yaml | 2 +- src/main/resources/forgejo/deployment.yaml | 2 +- src/main/resources/forgejo/middleware-ratelimit.yaml | 1 + src/main/resources/forgejo/secrets.yaml | 1 + src/main/resources/forgejo/service-ssh.yaml | 2 +- src/main/resources/forgejo/service.yaml | 2 +- src/test/cljc/dda/c4k_forgejo/backup_test.cljc | 2 ++ src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc | 6 +++--- 14 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/cljc/dda/c4k_forgejo/core.cljc b/src/main/cljc/dda/c4k_forgejo/core.cljc index ef5c407..99e363a 100644 --- a/src/main/cljc/dda/c4k_forgejo/core.cljc +++ b/src/main/cljc/dda/c4k_forgejo/core.cljc @@ -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) diff --git a/src/main/resources/backup/backup-restore-deployment.yaml b/src/main/resources/backup/backup-restore-deployment.yaml index 163bc14..9c34d07 100644 --- a/src/main/resources/backup/backup-restore-deployment.yaml +++ b/src/main/resources/backup/backup-restore-deployment.yaml @@ -2,6 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: backup-restore + namespace: forgejo spec: replicas: 0 selector: diff --git a/src/main/resources/backup/config.yaml b/src/main/resources/backup/config.yaml index f7252a2..f1c7fe1 100644 --- a/src/main/resources/backup/config.yaml +++ b/src/main/resources/backup/config.yaml @@ -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 diff --git a/src/main/resources/backup/cron.yaml b/src/main/resources/backup/cron.yaml index 6f89bf4..2996efa 100644 --- a/src/main/resources/backup/cron.yaml +++ b/src/main/resources/backup/cron.yaml @@ -2,6 +2,7 @@ apiVersion: batch/v1 kind: CronJob metadata: name: forgejo-backup + namespace: forgejo labels: app.kubernetes.part-of: forgejo spec: diff --git a/src/main/resources/backup/secret.yaml b/src/main/resources/backup/secret.yaml index c5809e0..f4c8fc0 100644 --- a/src/main/resources/backup/secret.yaml +++ b/src/main/resources/backup/secret.yaml @@ -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 diff --git a/src/main/resources/forgejo/appini-env-configmap.yaml b/src/main/resources/forgejo/appini-env-configmap.yaml index 935de1c..348a62a 100644 --- a/src/main/resources/forgejo/appini-env-configmap.yaml +++ b/src/main/resources/forgejo/appini-env-configmap.yaml @@ -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 diff --git a/src/main/resources/forgejo/datavolume.yaml b/src/main/resources/forgejo/datavolume.yaml index 44c8fd0..f874ff3 100644 --- a/src/main/resources/forgejo/datavolume.yaml +++ b/src/main/resources/forgejo/datavolume.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: forgejo-data-pvc - namespace: default + namespace: forgejo labels: app: forgejo spec: diff --git a/src/main/resources/forgejo/deployment.yaml b/src/main/resources/forgejo/deployment.yaml index 81d5dcb..a254a2d 100644 --- a/src/main/resources/forgejo/deployment.yaml +++ b/src/main/resources/forgejo/deployment.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: forgejo - namespace: default + namespace: forgejo labels: app: forgejo spec: diff --git a/src/main/resources/forgejo/middleware-ratelimit.yaml b/src/main/resources/forgejo/middleware-ratelimit.yaml index 0f6c49d..918dd95 100644 --- a/src/main/resources/forgejo/middleware-ratelimit.yaml +++ b/src/main/resources/forgejo/middleware-ratelimit.yaml @@ -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 diff --git a/src/main/resources/forgejo/secrets.yaml b/src/main/resources/forgejo/secrets.yaml index 0c2a224..fbf0eea 100644 --- a/src/main/resources/forgejo/secrets.yaml +++ b/src/main/resources/forgejo/secrets.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Secret metadata: name: forgejo-secrets + namespace: forgejo data: FORGEJO__database__USER: DBUSER FORGEJO__database__PASSWD: DBPW diff --git a/src/main/resources/forgejo/service-ssh.yaml b/src/main/resources/forgejo/service-ssh.yaml index 1694958..2856c85 100644 --- a/src/main/resources/forgejo/service-ssh.yaml +++ b/src/main/resources/forgejo/service-ssh.yaml @@ -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 diff --git a/src/main/resources/forgejo/service.yaml b/src/main/resources/forgejo/service.yaml index e8fed3f..493b5a3 100644 --- a/src/main/resources/forgejo/service.yaml +++ b/src/main/resources/forgejo/service.yaml @@ -2,7 +2,7 @@ kind: Service apiVersion: v1 metadata: name: forgejo-service - namespace: default + namespace: forgejo spec: selector: app: forgejo diff --git a/src/test/cljc/dda/c4k_forgejo/backup_test.cljc b/src/test/cljc/dda/c4k_forgejo/backup_test.cljc index af9eb55..c30f8bb 100644 --- a/src/test/cljc/dda/c4k_forgejo/backup_test.cljc +++ b/src/test/cljc/dda/c4k_forgejo/backup_test.cljc @@ -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"}} diff --git a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc index 54a6070..f3df49b 100644 --- a/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc +++ b/src/test/cljc/dda/c4k_forgejo/forgejo_test.cljc @@ -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}))))