From 4fb21f33308b8801e4d3b9c308e6d6e1a4013d03 Mon Sep 17 00:00:00 2001 From: Finn Date: Sat, 15 Jun 2024 00:36:26 -0700 Subject: [PATCH] Add Kustomize --- k8s/adsb/config.yaml | 1 - k8s/adsb/kustomization.yaml | 7 + k8s/adsb/namespace.yaml | 4 + k8s/adsb/rtltcp.yaml | 4 +- k8s/adsb/ultrafeeder.yaml | 3 - k8s/forgejo/config.yaml | 214 ------------------ .../forgejo-templates-base/head_navbar.tmpl | 205 +++++++++++++++++ k8s/forgejo/ingress.yaml | 1 - k8s/forgejo/kustomization.yaml | 14 ++ k8s/forgejo/namespace.yaml | 4 + k8s/forgejo/services.yaml | 2 - k8s/forgejo/statefulset.yaml | 1 - k8s/generic-device-plugin/ds.yaml | 1 - k8s/generic-device-plugin/kustomization.yaml | 5 + k8s/invoiceninja/kustomization.yaml | 8 + k8s/invoiceninja/namespace.yaml | 4 + k8s/kustomization.yaml | 11 + k8s/matrix/bridge-init/initialize-bridge.py | 14 ++ k8s/matrix/bridge-init/initialize-bridge.sh | 7 + k8s/matrix/bridge-meta.yaml | 2 +- k8s/matrix/bridge-telegram.yaml | 2 +- k8s/matrix/kustomization.yaml | 14 ++ k8s/matrix/namespace.yaml | 4 + k8s/monica/kustomization.yaml | 8 + k8s/monica/namespace.yaml | 4 + k8s/monitoring/kustomization.yaml | 6 + k8s/monitoring/namespace.yaml | 4 + k8s/namespaces.yaml | 35 --- k8s/s3staticsites/ingress.yaml | 10 + k8s/s3staticsites/kustomization.yaml | 8 + k8s/s3staticsites/namespace.yaml | 4 + k8s/shlink/kustomization.yaml | 6 + k8s/shlink/namespace.yaml | 4 + k8s/shlink/shlink.yaml | 1 + 34 files changed, 359 insertions(+), 263 deletions(-) create mode 100644 k8s/adsb/kustomization.yaml create mode 100644 k8s/adsb/namespace.yaml create mode 100644 k8s/forgejo/forgejo-templates-base/head_navbar.tmpl create mode 100644 k8s/forgejo/kustomization.yaml create mode 100644 k8s/forgejo/namespace.yaml create mode 100644 k8s/generic-device-plugin/kustomization.yaml create mode 100644 k8s/invoiceninja/kustomization.yaml create mode 100644 k8s/invoiceninja/namespace.yaml create mode 100644 k8s/kustomization.yaml create mode 100755 k8s/matrix/bridge-init/initialize-bridge.py create mode 100755 k8s/matrix/bridge-init/initialize-bridge.sh create mode 100644 k8s/matrix/kustomization.yaml create mode 100644 k8s/matrix/namespace.yaml create mode 100644 k8s/monica/kustomization.yaml create mode 100644 k8s/monica/namespace.yaml create mode 100644 k8s/monitoring/kustomization.yaml create mode 100644 k8s/monitoring/namespace.yaml create mode 100644 k8s/s3staticsites/kustomization.yaml create mode 100644 k8s/s3staticsites/namespace.yaml create mode 100644 k8s/shlink/kustomization.yaml create mode 100644 k8s/shlink/namespace.yaml diff --git a/k8s/adsb/config.yaml b/k8s/adsb/config.yaml index 0fb33db..354522a 100644 --- a/k8s/adsb/config.yaml +++ b/k8s/adsb/config.yaml @@ -2,7 +2,6 @@ apiVersion: v1 kind: ConfigMap metadata: name: ultrafeeder - namespace: adsb data: LOGLEVEL: verbose FEEDER_NAME: finn-kube diff --git a/k8s/adsb/kustomization.yaml b/k8s/adsb/kustomization.yaml new file mode 100644 index 0000000..e60c9fc --- /dev/null +++ b/k8s/adsb/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: adsb +resources: + - namespace.yaml + - config.yaml + - rtltcp.yaml diff --git a/k8s/adsb/namespace.yaml b/k8s/adsb/namespace.yaml new file mode 100644 index 0000000..9d1b257 --- /dev/null +++ b/k8s/adsb/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: adsb diff --git a/k8s/adsb/rtltcp.yaml b/k8s/adsb/rtltcp.yaml index caf8515..7b288ed 100644 --- a/k8s/adsb/rtltcp.yaml +++ b/k8s/adsb/rtltcp.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: Deployment metadata: name: rtltcp - namespace: adsb spec: selector: matchLabels: @@ -20,7 +19,7 @@ spec: containers: - image: git.janky.solutions/jankysolutions/rtltcp:latest name: rtltcp - args: ["rtl_tcp", "-a", "0.0.0.0"] + args: ["rtl_tcp", "-a", "0.0.0.0", "-d", "1"] resources: limits: janky.solutions/rtlsdr: "1" @@ -32,7 +31,6 @@ apiVersion: v1 kind: Service metadata: name: rtltcp - namespace: adsb spec: type: NodePort ports: diff --git a/k8s/adsb/ultrafeeder.yaml b/k8s/adsb/ultrafeeder.yaml index 5282449..fe3dcf2 100644 --- a/k8s/adsb/ultrafeeder.yaml +++ b/k8s/adsb/ultrafeeder.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: ultrafeeder - namespace: adsb spec: selector: matchLabels: @@ -56,7 +55,6 @@ apiVersion: v1 kind: Service metadata: name: ultrafeeder - namespace: adsb spec: type: NodePort ports: @@ -69,7 +67,6 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ultrafeeder - namespace: adsb spec: rules: - host: adsb.k8s.home.finn.io diff --git a/k8s/forgejo/config.yaml b/k8s/forgejo/config.yaml index 9ca1d51..5dbd70f 100644 --- a/k8s/forgejo/config.yaml +++ b/k8s/forgejo/config.yaml @@ -2,7 +2,6 @@ apiVersion: v1 kind: ConfigMap metadata: name: forgejo - namespace: forgejo data: FORGEJO__repository__DEFAULT_REPO_UNITS: repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects,repo.packages,repo.actions # this is the default for 1.22, should be safe to remove when we get there FORGEJO__repository__PREFERRED_LICENSES: AGPL-3.0-or-later,LGPL-3.0-or-later,GPL-3.0-or-later,Apache-2.0,MIT @@ -42,216 +41,3 @@ data: # FORGEJO__attachment__MINIO_LOCATION: us-sea-1 # FORGEJO__attachment__MINIO_ACCESS_KEY_ID: aQ0zCsTpCSJ8eKLtGZ3C # FORGEJO__attachment__MINIO_BUCKET: forgejo ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: forgejo-templates-base - namespace: forgejo -data: - head_navbar.tmpl: | - {{$notificationUnreadCount := 0}} - {{if and .IsSigned .NotificationUnreadCount}} - {{$notificationUnreadCount = call .NotificationUnreadCount}} - {{end}} - - diff --git a/k8s/forgejo/forgejo-templates-base/head_navbar.tmpl b/k8s/forgejo/forgejo-templates-base/head_navbar.tmpl new file mode 100644 index 0000000..03b486e --- /dev/null +++ b/k8s/forgejo/forgejo-templates-base/head_navbar.tmpl @@ -0,0 +1,205 @@ +{{$notificationUnreadCount := 0}} +{{if and .IsSigned .NotificationUnreadCount}} + {{$notificationUnreadCount = call .NotificationUnreadCount}} +{{end}} + + diff --git a/k8s/forgejo/ingress.yaml b/k8s/forgejo/ingress.yaml index 9a061f5..3c304f7 100644 --- a/k8s/forgejo/ingress.yaml +++ b/k8s/forgejo/ingress.yaml @@ -2,7 +2,6 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: forgejo - namespace: forgejo spec: rules: - host: git.janky.solutions diff --git a/k8s/forgejo/kustomization.yaml b/k8s/forgejo/kustomization.yaml new file mode 100644 index 0000000..8635c0c --- /dev/null +++ b/k8s/forgejo/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: forgejo +resources: + - namespace.yaml + - config.yaml + - ingress.yaml + - services.yaml + - statefulset.yaml + - secrets.yaml +configMapGenerator: +- name: forgejo-templates-base + files: + - forgejo-templates-base/head_navbar.tmpl diff --git a/k8s/forgejo/namespace.yaml b/k8s/forgejo/namespace.yaml new file mode 100644 index 0000000..6521f89 --- /dev/null +++ b/k8s/forgejo/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: forgejo diff --git a/k8s/forgejo/services.yaml b/k8s/forgejo/services.yaml index 81007bb..4c244ce 100644 --- a/k8s/forgejo/services.yaml +++ b/k8s/forgejo/services.yaml @@ -2,7 +2,6 @@ apiVersion: v1 kind: Service metadata: name: forgejo - namespace: forgejo spec: ports: - name: web @@ -14,7 +13,6 @@ apiVersion: v1 kind: Service metadata: name: forgejo-ssh - namespace: forgejo spec: type: NodePort ports: diff --git a/k8s/forgejo/statefulset.yaml b/k8s/forgejo/statefulset.yaml index 63e87b2..d587903 100644 --- a/k8s/forgejo/statefulset.yaml +++ b/k8s/forgejo/statefulset.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: forgejo - namespace: forgejo spec: selector: matchLabels: diff --git a/k8s/generic-device-plugin/ds.yaml b/k8s/generic-device-plugin/ds.yaml index c3f0997..4709c7f 100644 --- a/k8s/generic-device-plugin/ds.yaml +++ b/k8s/generic-device-plugin/ds.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: DaemonSet metadata: name: generic-device-plugin - namespace: kube-system labels: app.kubernetes.io/name: generic-device-plugin spec: diff --git a/k8s/generic-device-plugin/kustomization.yaml b/k8s/generic-device-plugin/kustomization.yaml new file mode 100644 index 0000000..19421dd --- /dev/null +++ b/k8s/generic-device-plugin/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: kube-system +resources: + - ds.yaml diff --git a/k8s/invoiceninja/kustomization.yaml b/k8s/invoiceninja/kustomization.yaml new file mode 100644 index 0000000..01a2cae --- /dev/null +++ b/k8s/invoiceninja/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: invoiceninja +resources: + - namespace.yaml + - database.yaml + - ingress.yaml + - invoiceninja.yaml diff --git a/k8s/invoiceninja/namespace.yaml b/k8s/invoiceninja/namespace.yaml new file mode 100644 index 0000000..7410114 --- /dev/null +++ b/k8s/invoiceninja/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: invoiceninja diff --git a/k8s/kustomization.yaml b/k8s/kustomization.yaml new file mode 100644 index 0000000..e0524d8 --- /dev/null +++ b/k8s/kustomization.yaml @@ -0,0 +1,11 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./adsb + - ./forgejo + - ./generic-device-plugin + - ./invoiceninja + - ./matrix + - ./monitoring + - ./s3staticsites + - ./shlink diff --git a/k8s/matrix/bridge-init/initialize-bridge.py b/k8s/matrix/bridge-init/initialize-bridge.py new file mode 100755 index 0000000..519fd66 --- /dev/null +++ b/k8s/matrix/bridge-init/initialize-bridge.py @@ -0,0 +1,14 @@ +#!/usr/bin/python +import os + +with open("/config/config.yaml") as r: + c = r.read() + +for i in ["AS_TOKEN", "HS_TOKEN", "TG_API_ID", "TG_API_HASH"]: + value = os.getenv(i) + if value is not None: + c = c.replace(i, value) + print("replaced", i) + +with open("/data/config.yaml", 'w') as w: + w.write(c) diff --git a/k8s/matrix/bridge-init/initialize-bridge.sh b/k8s/matrix/bridge-init/initialize-bridge.sh new file mode 100755 index 0000000..7b6b3a2 --- /dev/null +++ b/k8s/matrix/bridge-init/initialize-bridge.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -euo pipefail +cp /config/config.yaml /data/config.yaml +sed -i "s#AS_TOKEN#${AS_TOKEN}#g" /data/config.yaml +sed -i "s#HS_TOKEN#${HS_TOKEN}#g" /data/config.yaml +sed -i "s#TG_API_ID#${TG_API_ID}#g" /data/config.yaml +sed -i "s#TG_API_HASH#${TG_API_HASH}#g" /data/config.yaml diff --git a/k8s/matrix/bridge-meta.yaml b/k8s/matrix/bridge-meta.yaml index 0e97a87..4acb3da 100644 --- a/k8s/matrix/bridge-meta.yaml +++ b/k8s/matrix/bridge-meta.yaml @@ -63,7 +63,7 @@ spec: - image: dock.mau.dev/mautrix/meta:latest name: bridge-facebook resources: {} - command: ["bash", "-c", "sh /init/initialize-bridge.sh && /usr/bin/mautrix-meta -c /data/config.yaml --no-update"] + command: ["/usr/bin/mautrix-meta", "-c", "/data/config.yaml", "--no-update"] ports: - name: bridge containerPort: 29319 diff --git a/k8s/matrix/bridge-telegram.yaml b/k8s/matrix/bridge-telegram.yaml index bcf8ca4..debf1e3 100644 --- a/k8s/matrix/bridge-telegram.yaml +++ b/k8s/matrix/bridge-telegram.yaml @@ -81,7 +81,7 @@ spec: - image: dock.mau.dev/mautrix/telegram:latest name: bridge-telegram resources: {} - command: ["bash", "-c", "sh /init/initialize-bridge.sh && python3 -m mautrix_telegram -c /data/config.yaml"] + command: ["python3", "-m", "mautrix_telegram", "-c", "/data/config.yaml"] ports: - name: bridge containerPort: 29317 diff --git a/k8s/matrix/kustomization.yaml b/k8s/matrix/kustomization.yaml new file mode 100644 index 0000000..68c6d2d --- /dev/null +++ b/k8s/matrix/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: matrix +resources: + - namespace.yaml + - bridge-meta.yaml + - bridge-signal.yaml + - bridge-telegram.yaml + - secrets.yaml +configMapGenerator: +- name: bridge-init + files: + - bridge-init/initialize-bridge.py + - bridge-init/initialize-bridge.sh diff --git a/k8s/matrix/namespace.yaml b/k8s/matrix/namespace.yaml new file mode 100644 index 0000000..b88de94 --- /dev/null +++ b/k8s/matrix/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: matrix diff --git a/k8s/monica/kustomization.yaml b/k8s/monica/kustomization.yaml new file mode 100644 index 0000000..0038540 --- /dev/null +++ b/k8s/monica/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: monica +resources: + - namespace.yaml + - monica.yaml + - mysql.yaml + - secrets.yaml diff --git a/k8s/monica/namespace.yaml b/k8s/monica/namespace.yaml new file mode 100644 index 0000000..8b7d3aa --- /dev/null +++ b/k8s/monica/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monica diff --git a/k8s/monitoring/kustomization.yaml b/k8s/monitoring/kustomization.yaml new file mode 100644 index 0000000..7e6c453 --- /dev/null +++ b/k8s/monitoring/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: monitoring +resources: + - namespace.yaml + - promtail.yaml diff --git a/k8s/monitoring/namespace.yaml b/k8s/monitoring/namespace.yaml new file mode 100644 index 0000000..d325236 --- /dev/null +++ b/k8s/monitoring/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monitoring diff --git a/k8s/namespaces.yaml b/k8s/namespaces.yaml index d4e003d..052eaae 100644 --- a/k8s/namespaces.yaml +++ b/k8s/namespaces.yaml @@ -10,45 +10,10 @@ metadata: --- apiVersion: v1 kind: Namespace -metadata: - name: invoiceninja ---- -apiVersion: v1 -kind: Namespace -metadata: - name: forgejo ---- -apiVersion: v1 -kind: Namespace metadata: name: browsers --- apiVersion: v1 kind: Namespace -metadata: - name: matrix ---- -apiVersion: v1 -kind: Namespace -metadata: - name: s3staticsites ---- -apiVersion: v1 -kind: Namespace -metadata: - name: monica ---- -apiVersion: v1 -kind: Namespace -metadata: - name: shlink ---- -apiVersion: v1 -kind: Namespace metadata: name: keycloak ---- -apiVersion: v1 -kind: Namespace -metadata: - name: adsb diff --git a/k8s/s3staticsites/ingress.yaml b/k8s/s3staticsites/ingress.yaml index 93252b9..306ebbf 100644 --- a/k8s/s3staticsites/ingress.yaml +++ b/k8s/s3staticsites/ingress.yaml @@ -45,3 +45,13 @@ spec: name: s3staticsites port: name: http + - host: aktivisda.janky.solutions + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: s3staticsites + port: + name: http diff --git a/k8s/s3staticsites/kustomization.yaml b/k8s/s3staticsites/kustomization.yaml new file mode 100644 index 0000000..af2eba8 --- /dev/null +++ b/k8s/s3staticsites/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: s3staticsites +resources: + - namespace.yaml + - deployment.yaml + - ingress.yaml + - secrets.yaml diff --git a/k8s/s3staticsites/namespace.yaml b/k8s/s3staticsites/namespace.yaml new file mode 100644 index 0000000..b1c6d45 --- /dev/null +++ b/k8s/s3staticsites/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: s3staticsites diff --git a/k8s/shlink/kustomization.yaml b/k8s/shlink/kustomization.yaml new file mode 100644 index 0000000..d0563ce --- /dev/null +++ b/k8s/shlink/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: shlink +resources: + - namespace.yaml + - shlink.yaml diff --git a/k8s/shlink/namespace.yaml b/k8s/shlink/namespace.yaml new file mode 100644 index 0000000..86a1660 --- /dev/null +++ b/k8s/shlink/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: shlink diff --git a/k8s/shlink/shlink.yaml b/k8s/shlink/shlink.yaml index 7e6a58f..9eb839b 100644 --- a/k8s/shlink/shlink.yaml +++ b/k8s/shlink/shlink.yaml @@ -85,3 +85,4 @@ data: DEFAULT_DOMAIN: s.janky.bot IS_HTTPS_ENABLED: "true" DISABLE_TRACKING: "true" + RR_NUM_WORKERS: "2"